Jump to content

Accessing functions in code tab of a Digital Asset?


Adrian

Recommended Posts

I'm trying to create a python asset (or "operator type" or whatever these things are called).

I read that geometry is read-only, unless accessed from code contained in the code tab.

Here are two problems i can't get past:

1) I would like to create a parameter interface and have value changes in it call a function in the code tab. The callback field however only seems to recognize functions from the script tab, so no luck there. Can i get to code somehow, or is this in conflict with Houdini's node paradigm?

WVlkV.png ?

2) The kwargs arguments passed by the callback field only seem to apply to the parameter-item that called them. Can i make a button trigger a function, but pass the value of e.g. an integer field to that function, or alternatively retrieve the value from within the function without it having been passed?

Edited by Adrian
Link to comment
Share on other sites

1) I would like to create a parameter interface and have value changes in it call a function in the code tab. The callback field however only seems to recognize functions from the script tab, so no luck there. Can i get to code somehow, or is this in conflict with Houdini's node paradigm?

2) The kwargs arguments passed by the callback field only seem to apply to the parameter-item that called them. Can i make a button trigger a function, but pass the value of e.g. an integer field to that function, or alternatively retrieve the value from within the function without it having been passed?

1) I don't think it has anything to do with the node paradigm, but with how they designed the workflow. Is there a specific reason why you need the button triggered function in the code tab instead of the script tab? The code tab is for scripts that run every time the node is cooked, while the script tab would be for, say, when a user interacts with the node's interface or something;

2) you can access the integer parm from within a function defined the in the python module very easily, just use the pwd() method to return the node from which the button was triggered.

Cheers

sample_python.hip

testPy.otl

Link to comment
Share on other sites

Thanks for the answer and files rafaelfs, i will have a look at them. I'm a bit too eager and impatient sometimes, this will take time to learn.

The reason I was interested in running python from the code tab was due to what appears to be a restriction/limitation of the script tab regarding geometry manipulation. It seems code within the code tab has more permissions, unless i am mistaken.

Edited by Adrian
Link to comment
Share on other sites

The writable hou.Geometry object is only available inside the Code tab, but you can pass it to functions that exist in the PythonModule and they can manipulate it with whatever means you see fit.

But then is it possible to pass geometry objects back and forth between scripts in the code tab and the scripts tab?

the only pathway I can envision is the parms being manipupated by scripts in the python module and scripts in the code tab calling those parms whenever the node is cooked. I can't see how scripts in the python module can return data directly to the code tab, so to speak...

Cheers

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