Simple Python copy-like sop

   3505   3   1
User Avatar
Member
26 posts
Joined: 9月 2010
Offline
Hello!

What I'm trying to do is create a sop to copy a set of points, assign additional values to them and find their midpoints.

In layman:

1. Import geo.

2. Create a curve with as many points in the same location as the original points. (I'm guessing that I need to get a list of points and their XYZ values, and then set the new points to those).

3. Duplicate this newly created curve upwards.

4. Create midpoints on each edge per each vertical copy. (Using the hou.edge maybe?)

5. Add point attributes based on their Y value (I know how to do this).


I'm just getting into Python and this Tutorial [aiworks.eu] seems relevant but only explains how to create actual geometry in a new node.

I've followed/read several tutorials and understand the premise of evaluating parms, using simple for loops but I'll be thankful of anyone can suggest any hypthon code specific to this sort of thing!
User Avatar
Member
26 posts
Joined: 9月 2010
Offline
Ok so this is what I'm trying:

for i in range(0,levels):
point = geo.createPoint()
point.setAttribValue(“Py”, 1)

This returns the error “no attribute with this name exists”, which is strange because don't all newly created points have Px, Py & Pz values?

I tried point.setPosition but that requires x,y,z values, but I only want the points translated up…
User Avatar
Member
401 posts
Joined:
Offline
http://www.sidefx.com/docs/houdini10.0/hom/hou/Point [sidefx.com]

point.setPosition((x, y, z))
# is the same as
point.setAttribValue(“P”, (x, y, z))


Any reason why you can use a copySOP, apart from this being slower?
this is not a science fair.
User Avatar
Member
26 posts
Joined: 9月 2010
Offline
Thanks for your reply!

I already solved my problem with:

for point in geo.points():
for i in range(-1,levels):
if i == -1:
pos = point.position()
else:
pos = point.position() + hou.Vector3((0, level_height,0))
point = geo.createPoint()
point.setPosition(pos)
point.setAttribValue(pointlevel, i+1)
point.setAttribValue(building, cluster)

rdg
Any reason why you can use a copySOP, apart from this being slower?

My reason? I want to have a central place in which I can manipulate a specific type of geometry. I didn't want a copy sop, because this way I can duplicate points and create attributes in one!

My next step is to create a line connecting each point per level attribute, this should avoid me having to use an ‘add’ sop.
  • Quick Links