Python callback script from button parameter not executing in UE4

   4565   5   1
User Avatar
Member
2 posts
Joined: 4月 2019
Offline
Hello,

In our digital asset which we export to UE4, I wanted to add a button that runs some python code.
After discovering that it doesn't work, I tried to move a box using Python for testing, but couldn't get it to work.

I tried the following:
The button has
hou.phm().MovePython()
as its callback script.

This function is defined in a PythonModule in the Scripts tab of the Asset properties as
def MovePython():
    print "Move called"
    exec(hou.node('/obj/geo1/python1').parm('python').eval())
    MoveBox()
and refers to a python node with the following code:
def MoveBox():
    objPath = "/obj/geo1/box1/tx"
    parm = hou.parm(objPath)
    origVal = parm.eval()
    parm.set(origVal + 0.1)

I also tried a more direct approach by defining the following function in the same PythonModule:
def MoveGraph():
    print "MoveGraph called"
    objPath = "/obj/geo1/box1/tx"
    parm = hou.parm(objPath)
    origVal = parm.eval()
    parm.set(origVal + 0.1)
which we call in a similar way using a button.

When pressing either of the buttons in the Houdini Editor, the box moves as expected, however, when doing the same in the Unreal Editor, the box does not move.

Is there a solution to this problem, or is this a limitation of the way Houdini interacts with Unreal Engine?


Thanks in advance!
User Avatar
スタッフ
534 posts
Joined: 9月 2016
Offline
Hi,
I haven't tried to reproduce your issue yet, but have you tried marking your Python SOP as editable in the HDA?
User Avatar
Member
2 posts
Joined: 4月 2019
Offline
Hi,

I had already set both ‘python1’ and ‘box1’ as editable nodes in the Node tab of the Asset Properties.
However, should this be visible within the engine, since it is not? Maybe I am missing something when exposing these parameters.
User Avatar
Member
5 posts
Joined: 1月 2019
Offline
Don't know if the problem is resolved, but perhaps doing “node.allowEditingOfContents(True)” makes it work?
Grant Lee
User Avatar
Member
11 posts
Joined: 6月 2019
Offline
i have the same issue with v2 also. i'm basically trying to execute a hou.phm()callback via button, which works in houdini but not in unreal. i'm trying to dynamically add file nodes to that graph via button press.
User Avatar
スタッフ
534 posts
Joined: 9月 2016
Offline
Hi,

Just realized you're using absolute paths, "/obj/geo1/python1" which might be the issue.

You generally want to always use relative paths when using HDAS with HEngine.
  • Quick Links