Trying to configure a digital asset: I want to run a callback script for a button parameter. The callback should call myFunction() from the one of the python modules that I created in the “Scripts” section of the Operator Type Properties.
I get the following error when I press the button parameter:
AttributeError: ‘module’ object has no attribute ‘myFunction’
Any idea how to setup the callback script?
Thanks!!
ps. I've already searched forums and looked at relevant doc, but probably I'm to new with python to understand everything.
ok finally found what was wrong. I spent two bloody hours on this dumb thing.
For future generations:
THE NAME OF THE MODULE MUST STRICTLY BE: “PythonModule”.
Don't change the name of the module (like I did) if you want to use this simple callback script for your paramater:
hou.phm().myFunc()
that calls the function myFunc() stored in your module in the Scripts section.
This is mentioned in the documentation, although not super clear:
Each digital asset type has a Python module, similar to the scene file’s hou.session module. You can use this module to store functions, classes, and objects specific to the asset type. The module source code is stored in a section of the asset named PythonModule (on the Extra files tab of the type properties window). You can create this section manually, or Houdini will create it automatically if you create a “Python Module” event handler on the Scripts tab.
I had this exact same problem, and the fix was to use the 'PythonModule' name.
I think what got me was that I renamed the module in the scripts tab late in the day, Houdini must have kept a reference to the function around when it was previously named PythonModule because it worked for hours with the new module name. The next day I re-open Houdini and nothing is working.
So, a friendly reminder to always restart and test before calling something done!
Also thanks for posting the fix! This was like the 3rd or 4th post I've found asking about this error, but the only one that posted a solution.
1. in scripts panel click add empty section 2. make syre the name ects is PythonModule 3. add function to module. 4. add function to callback scripty as follows hou.phm().function()
NicTanghe Anyone know how to make an INT slider run a callback script on parm change ?
add callback script to it in Edit Parameter Interface dialog fore spare parms or Type Properties dialog for HDA parms that will be triggered every time the value is changed manually callback scripts are not triggered when parm value is changed by it's expression though