Adding points to a curve using Python?

   12051   6   0
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
Hey guys,

I have a curve which was defined as such:



curve = hou.node('/obj').createNode('geo', ‘curve’)
curve.node('file1').destroy()
curve.createNode('curve')



And I am accessing the data in the curve as follows:



curve = hou.node('/obj/curve/curve1').geometry()



How do I add points to this curve procedurally using Python? I looked into createPoint(), but that just confused me further. :?
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Nodes such as SOP are meant to create the geometry data from its parameters. So modifying the output of the node is not a good idea. So you have two choices:
- Manipulate the node's parameters instead, OR
- Create a Python SOP operator, which then you can write the code for that creates the geometry.
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
Hmmm, is there any way to declare a curve and all of its points in one fell swoop then?
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Setting point positions on the Curve SOP's parameters (in python) should be ok, no?
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
edward
Setting point positions on the Curve SOP's parameters (in python) should be ok, no?

I'm not quite sure what you mean. Can you elaborate please?

I think I should have been more specific in the outset of this thread…what I'm trying to do is to make a curve which follows the geometry of a polygonal object. That is to say, given that I have an object in the scene, I want to make a curve whose set of points is a superset of the verticies of a polygonal object.
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Here's how to do it using the Curve SOP. If you want to do it in python, then it's just a matter of setting the Curve SOP's parameter to the appropriate point numbers.

Attachments:
curve_snap.hip (35.0 KB)

User Avatar
Member
10 posts
Joined: 1月 2007
Offline
edward
Here's how to do it using the Curve SOP. If you want to do it in python, then it's just a matter of setting the Curve SOP's parameter to the appropriate point numbers.

Cool, thanks for taking the time to upload that file. I guess what I'm really having trouble with is figuring out just how to set the parameters using Python.
  • Quick Links