[need example file] Python invoke compiled block/graph

   798   2   1
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Could anybody provide a simple example file for calling and executing an Invoke Compiled Block and an Invoke Compiled Graph, with Python?

I attach my failed attempts.

Thanks


Edit*
I deleted the attachments, will post more relevant example next post.
Edited by Andr - Sept. 20, 2023 09:26:00
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Does anyone know how to invoke a graph with Python?

This is the code I'm using in the Python Sop: in the left branch, it's able to call input1 (subdivide sop), execute its verb on input0 geometry, and finally return the modified geo. The very same code doesn't work on the right branch, it's not able to execute the verb of the invoke sop, it just return the unmodified geo from input0.

node = hou.pwd()
geo = node.geometry()

input1 = node.inputs()[1]

invoke = input1.verb()

 
resultgeo = node.geometry()
invoke.execute(resultgeo, [geo])

node.geometry().clear()
node.geometry().merge(resultgeo)

Attachments:
pyinvoke_graph2.jpg (120.4 KB)
python_invoke_example2.hiplc (143.7 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Thanks to SideFX Support and one developer for enlightening me.
I upload a working example for the people of the future.

NOTE:
One important detail I learned: ABSOLUTE PATHS are mandatory when setting path parameters for a sopverb.
Now this makes more sense to me, as I better understand the agnostic nature of sop verbs..
Edited by Andr - Sept. 20, 2023 12:50:36

Attachments:
python_invoke_example_OK.hiplc (141.9 KB)

  • Quick Links