Jump to content

changing curve geometry from a script


Recommended Posts

With the old Curve node, you could change the geometry from python like so:


I had a working python shelf tool that would grab the point positions from some node further down the chain (for instance, an Edit SOP), then copy them back up to the original Curve SOP, allowing you to delete subsequent Edits, Transforms, etc. and bake them into the original curve. This was really useful in the case where you're drawing a bunch of control curves, then having to adjust them a bunch of times, and you don't want a pile of extra nodes cluttering up your network.

With Curve 2.0, the points seem to be generated by a zillion wrangles, operating on history entries that are stored as points in an internal Stash SOP (called parm_points). I say "history entries", because there are a lot more of them than the number of points on the curve itself, and have an "optype" attribute with values like append/delete/transform/etc.

The docs say that hou.Geometry objects are read-only except within a Python SOP, and that a Python SOP actually operates on a frozen copy of any hou.Geometry that it operates on. I assume this means that it doesn't change the contents of the original Geometry.

The Curve SOP also has a hidden parameter "parmpoints" that when you call eval() on it returns a frozen Geometry that corresponds to the "history" Geometry in the parm_points Stash. Setting the parmpoints parameter to None clears out the Stash. So there's clearly some mechanism tying the two together. But the frozen parmpoints Geometry gives read-only errors when you attempt to clear or edit it.

So I guess maybe the way to reset the Curve 2.0 node to a simple set of points with given positions would be: create a new Geometry object from scratch, populate it with the appropriate "append" and "transform" entries, then set the parmpoints parameter to the new Geometry, and hope whatever magic is in there pushes it to the Stash?

Note: While the Curve 2.0 does have better controls for editing, it's still not fully-featured: you can't select and move multiple points without it resulting in an Edit SOP being created, you can't add points to the ends of the curve (I think?) without adding them somewhere in the middle, moving the old end point, then moving the new inserted point to where the end used to be, etc. So baking subsequent changes back to the original Curve is still a useful operation.

Edited by meeotch
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...