Jump to content
Erik_JE

opinputpath and object_merge

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

Share this post


Link to post
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.

Share this post


Link to post
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))`")

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×