Detect Open/Closed Curves in Maya

   2152   2   1
User Avatar
Member
2 posts
Joined: Feb. 2019
Offline
Hi all,

I have two operations depending on whether an input curve is open vs closed. Everything works great within Houdini using a primitive's "closed" intrinsic attribute. However, when using Houdini Engine in Maya, this no longer works.

Some solutions are provided here [www.sidefx.com] but it doesn't work for me. So now my only alternative is to let users indicate whether their curves are open or closed via a toggle, which is not ideal when processing multiple curves.

The Houdini Engine for Maya doc also says there are issues when bringing curves from/to Maya, so I'm not sure if this is completely impossible.

I provided a simple hda to demonstrate the problem. I'd really appreciate your help!
Edited by NebulaBounty - July 12, 2021 21:06:49

Attachments:
detect_closed_curve.hda (6.5 KB)

User Avatar
Staff
465 posts
Joined: Aug. 2019
Offline
Unfortunately it looks like this is a HAPI limitation. I have gone ahead and created an RFE so that it can be tracked in our system.

One way to get around this may be to go ahead and create that attribute, but set its value through a Python script. Something like:

from maya import cmds

input_curve_nodes = cmds.ls(type='houdiniInputCurve')

for input_curve_node in input_curve_nodes:
    curve_nodes = cmds.listConnections(input_curve_node + '.inputCurve', d=False)
    
    if curve_nodes:
        curve_node = curve_nodes[0]
        
        form = cmds.getAttr(curve_node + '.form')
        is_closed = (form == 1) or (form == 2)
        
        cmds.setAttr(input_curve_node + '.myParm', is_closed)

That will set the value of the parm for each input curve node based on whether the input curve is closed or not.
User Avatar
Member
2 posts
Joined: Feb. 2019
Offline
Hello! Thanks for the pointer. I went ahead and tried this in Maya. It seems that simply setAttr doesn't work. It can only work on the existing attributes like "Caching" and "Frozen". Furthermore, I can't access the maya library from inside the HDA. So I assume I will still need the user to press a button to execute this script, which is acceptable but not ideal.

Now, is there a way to run this automatically?

In the meantime, I'll investigate and see if I can hack my way out.
  • Quick Links