Writing out Position/ Rotation Data?

   2442   2   1
User Avatar
Member
3 posts
Joined: Nov. 2013
Offline
So the end goal of what I'm wanting to do is have a text document that contains the position and rotation values of specific pieces of geometry. So for example if I were to have a few barrels that are being interacted with in a rbd sim, they would return for me the position and rotation for all of the objects in the following format:

Barrel1
Barrel2
Barrel3

Being a relatively new user to Houdini, I'm not quite sure where to begin with this.
User Avatar
Member
655 posts
Joined: Feb. 2006
Offline
Depending the task you may want to do it with a script or via Chops.

I guess you are trying to export these transforms only once… here is an example from the Massive forum.

hope it helps

def createGenerators():
import string, math

# Execute this code when Export button were pressed
geo = hou.pwd().geometry()
tuplePoints = geo.points()

masFileParm = hou.pwd().parm('masPath')
print masFileParm.eval()

# Archive to create with point positions
f = open (str(masFileParm.eval()), ‘w’)

# Orient terrain/flow variables
oTerrain = hou.pwd().parm('orientTerrain').eval()
oFlow = hou.pwd().parm('orientFlow').eval()
pOffset = hou.pwd().parm('angleOffset').eval()

# Place block start
f.write ('Place')
f.write ('\n group 5 fromHoudini')
f.write ('\n translate 0 0')
f.write ('\n colour 5')

# Funtion to calculate angle
def pointAngle(vector):
angle = math.degrees(math.atan2(pointNormal, pointNormal))
return angle

for point in tuplePoints:
pointPosition = point.position()
pointNormal = hou.Vector3(point.attribValue(“N”))
pAngle = pointAngle(pointNormal)

f.write ('\n generator point')
f.write ('\n centre %.3f' % pointPosition + ‘ %.3f’ % pointPosition + ‘ %.3f’ % pointPosition)
f.write ('\n normal 0 -1 0')
f.write ('\n number 1')
f.write ('\n distance 0')
f.write ('\n noise 0 0.001')
f.write ('\n angle %.3f' % (pAngle + pOffset) + ‘ 0’)
f.write ('\n height %.3f' % pointPosition + ‘ 0’)
f.write ('\n flow ‘ + str(oFlow))
f.write (’\n terrain ‘ + str(oTerrain))
f.write (’\n groups ')
f.write ('\n end generator')

f.write ('\nEnd place')
User Avatar
Member
3 posts
Joined: Nov. 2013
Offline
Thanks jordibares, from glancing at it that's exactly what I was looking for. I'm trying to pass houdini sim information into Massive.
  • Quick Links