Jump to content

HOM: how to create a new hou.Geometry instance?


mrice

Recommended Posts

Is it possible to create a temporary hou.Geometry object in a sop?

Seems like the freeze() method should work, but it looks broken to me:

myGeo = hou.pwd().geometry()

tempGeo = myGeo.freeze()

inside a sop, and the sop's geometry still seems to be linked to tempGeo.

I tried creating a temporary node to work with, but I get a permission error if I attempt to modify its geometry, even if its frozen.

The hou.Geometry.__init__() method is disabled, and copy.deepcopy() doesn't work.

Link to comment
Share on other sites

Unfortunately it's not possible to create temp geo objects with HOM. hou.Geometry.freeze() is more of a way to prevent the geometry from being modified, as opposed to creating a copy. I think it basically returns a const pointer to the original geo so you can't touch, but of course any changes to the main gdp are visible through that. One kind of neat thing you can do with it though is store a list of frozen objects somewhere to give you access to geometry from different frames. Each frame a SOP creates a new GU_Detail and freezing that will keep around the reference to that so you can access it later.

You can't really do much else I'm afraid since there is no way to construct an empty hou.Geometry object. Trying to access geometry from any SOP node, outside of the cook code for that node will result in you getting an unmodifiable frozen hou.Geometry. You can merge in other hou.Geometry objects into your geometry inside of the Cook code but that's about it.

Ideally HOM would have methods to create empty Geometry objects, make unassociated copies of geometry, create copies from specific groups/points/prims, etc. but alas it doesn't. I've got some RFEs in for them so it's all about the waiting game.

Edited by graham
Link to comment
Share on other sites

Thanks Graham for the clarification. I swear hou.Geometry.freeze() used to return a deep copy :P This is a big omission from the HOM, hope your RFE's come true!

I would at least expect hou.Geometry.freeze() to return a pointer-to-const though..

constGeo = hou.pwd().geometry().freeze()

constGeo.clear()

?

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.

Guest
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...