Jump to content

opinputpath and object_merge


Erik_JE

Recommended Posts

Im writing a python script for setting up an avalanche rig for a school project. I have created a subnetwork with a dop setup. To the first input of the subnetwork i connect a painted grid which specifies on what and where on an object the avalanche should start.

Inside the subnetwork i have geometry nodes with various stuff in them. I connect the sub network input #1 to these nodes. To then inside the geometry nodes grab the geometry i use

`opinputpath("/obj/subnetwork/geometry1",0)` in an object_merge node.

Continuing to the problem that when the python script creates the subnetwork there is nothing connected to the subnetwork so it do not work. If i after i have added a grid as input forces updates of the values by disconnecting and connecting the geometry nodes the RBD setup works fine. So my question is: Is there a way to force an update of the opinputpath expression or another better way to solve my problem?

Regards

Erik

Link to comment
Share on other sites

Im writing a python script for setting up an avalanche rig for a school project. I have created a subnetwork with a dop setup. To the first input of the subnetwork i connect a painted grid which specifies on what and where on an object the avalanche should start.

Inside the subnetwork i have geometry nodes with various stuff in them. I connect the sub network input #1 to these nodes. To then inside the geometry nodes grab the geometry i use

`opinputpath("/obj/subnetwork/geometry1",0)` in an object_merge node.

Continuing to the problem that when the python script creates the subnetwork there is nothing connected to the subnetwork so it do not work. If i after i have added a grid as input forces updates of the values by disconnecting and connecting the geometry nodes the RBD setup works fine. So my question is: Is there a way to force an update of the opinputpath expression or another better way to solve my problem?

Regards

Erik

Hi,

Not sure if I understand your correctly, but if I'm right, you can instead of hard wiring subnet input to object merge sop, use parameter reference with chs(). Add spare parameter to a subnet that will point to your external object, then add chs() to an object_merge.

Link to comment
Share on other sites

Hi,

Not sure if I understand your correctly, but if I'm right, you can instead of hard wiring subnet input to object merge sop, use parameter reference with chs(). Add spare parameter to a subnet that will point to your external object, then add chs() to an object_merge.

Thanks for the response. I think you got what i meant even tho the explanation were not the best. I added chs() as

objectmerge.parm("objpath1").set("`chs(opinputpath(\"" + mountain_geometry.path() + "\",0))`")

and this seems to be almost working. It updates the path when connecting and seems to get the correct path /obj/grid_object1 but the object merge node screams "Bad parameter reference: "/obj/grid_object1""

Here is a code snippet with important parts of what i am doing

subnetwork = root.createNode("subnet", "Subnetwork")

inputs = subnetwork.indirectInputs()

geometry.insertInput(0,inputs[0])

objectmerge.parm("objpath1").set("`chs(opinputpath(\"" + geometry.path() + "\",0))`")

Link to comment
Share on other sites

could you provide simplified version of this asset? I think we're still in a fog here :)

:rolleyes:

I put it up on my page. Currently it is in a py file so we can run it with hython and code outside houdini but it will be moved into an shelf tool later.

http://www.evegard.se/skola/avalancheCreate.py

Haven't used Houdini or python too much so be gentle.

Regards

Erik

Link to comment
Share on other sites

:rolleyes:

I put it up on my page. Currently it is in a py file so we can run it with hython and code outside houdini but it will be moved into an shelf tool later.

http://www.evegard.s...lancheCreate.py

Haven't used Houdini or python too much so be gentle.

Regards

Erik

See the example. I added operator path on a subnet level, and referenced it inside object_merge.

hth.

ps I think you should avoid using object level inputs as a way of referencing geometry since it parents your object to another node (trans/rot/scale changes). It's technically possible, but conceptually misleading.

ps2 is there any reason besides educational, you're doing it in a script, not in HDA?

avalancheCreate.hip

Link to comment
Share on other sites

See the example. I added operator path on a subnet level, and referenced it inside object_merge.

hth.

ps I think you should avoid using object level inputs as a way of referencing geometry since it parents your object to another node (trans/rot/scale changes). It's technically possible, but conceptually misleading.

ps2 is there any reason besides educational, you're doing it in a script, not in HDA?

Ahh yes that is a good solution, I got a little too focused on the whole connecting nodes part. Thank you for the help ill go with that setup it updates perfectly when switching between different grids.

There is no reason besides educational for doing it as script. The course is focused on developing for houdini and we have also coded SOPs and VOPs with HDK earlier. It could have been done alot easier rigging it up in houdini inside a HDA. Especially the whole rbd part and spare parameters for the node.

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