Jump to content

using node.parm().clickButton() without UI


tom.vujnovic

Recommended Posts

I'm trying to python script maya->houdini transfer script via alembic.
I've sorted out most of kinks, but there is one hurdle that's giving me a headache for days now ...
I have to use alembicArchive because I need node tree.

In script I create a alembicArchive node, set all params as desired and execute aNode.parm("buildHierarchy").pressButton()

While I was testing this in houdini's python shell pane everything worked great.

Once I left houdini UI and went to python I can't generate subtree. I need that because I need to assign shaders and some other things before I save a file.

I tried to force cook node (aNode.cook(force=true)) but it didn't solve it.

Any ideas how to force this node to rebuild hierarchy?

thanks.

edit:
of course that i meant pressButton() method instead clickButton … lapsus.
Also I found that I can call calback script on this button (item.hdamodule().BuildHierarchyRoot(item)) or do i via hscript's “opparm -c” but that also does not work without UI … so I'm still on square one.
I know that there is a possibility to build alembic hierarchy myself, but I would like to avoid that if possible.

tom.

Edited by tom.vujnovic
updated info
Link to comment
Share on other sites

seems to work for me, this was executed in hython process run from command line

aa = hou.node("/obj").createNode('alembicarchive')
aa.parm('fileName').set("default.abc")
print("Has UI: {}".format( hou.isUIAvailable() ))
print("Subnet Content before update: {}".format( aa.children() ))
aa.parm('buildHierarchy').pressButton()
print("Subnet Content after update: {}".format( aa.children() ))

output

Has UI: False
Subnet Content before update: ()
Subnet Content after update: (<hou.ObjNode of type alembicxform at /obj/alembicarchive1/gabc>,)

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Hi Tomas, thanks for answer ...

It's soooo wierd ...

You are right, when I execute those commands in python shell they work as expected. But when I execute script in same shell it does nothing.

This is part of script that is handling import into houdini ...

tempTime = time.clock()
print "Importing into Houdini ... ",
m = hou.node("/obj").createNode("alembicarchive", ns[1:],run_init_scripts=True, load_contents=True, exact_type_name=False)
# m.parm("fileName").set(os.path.normpath(os.path.join(abcPath, ns[1:] + '.abc')))
print "Node",m.name()
m.parm("fileName").set("$HIP/../anim/sceneABCexport/"+ns[1:]+'.abc')
print("Subnet Content before update: {}".format(m.children()))
m.parm('buildHierarchy').pressButton()
print("Subnet Content after update: {}".format(m.children()))
# hou.hscript("opparm -c /obj/"+str(ns[1:])+" buildHierarchy")
# m.hdaModule().BuildHierarchyRoot(m)
# m.parm("buildHierarchy").pressButton()
# m.parm("buildHierarchy").eval()
# m.cook(force=True,frame_range=(1001,1001))
m.moveToGoodPosition()
print "done. ("+str(time.clock() - tempTime)+" sec)"

No error, no warning ... just nothing :(((

(commented out are things that I've tried and didn't work)

This is output ...

Importing into Houdini ...  Node ttv_prop_oldsafe_rig_mr_MASTER
Subnet Content before update: ()
Subnet Content after update: ()
done. (0.00554966969401 sec)

Superstrange. I'm digging into it but still have no idea what is wrong.

Is there a chance that callbacks are executed in different thread and I have to wait (timer.sleep(100) or something) for .pressButton() to finish??

How I can find when it's done?

Edited by tom.vujnovic
Link to comment
Share on other sites

No. :(

just found that.

It's weird combo of "\\" and "/" mixup between python and houdini internals.

I wouldn't mind that some Hou.Error was raised, like "File not found" or something. :)

For some reason while in python $HIP variable get wrong value.

I save my houdini scene to r"U:\projects\ttv\episodes\e408\work\sq010\sh070\Houdini" but $HIP gets reseted to "u:/"

After some experimentation, I found that houdini want to set $HIP to something like "U:projects tvepisodese408worksq010sh070Houdini" (notice space instead of \t - hou must interpret it as tab escape char :)))

I think I'm on right track now. Thanks a lot for initial push :)))

Link to comment
Share on other sites

hipFile='U:/projects/ttv/episodes/e408/work/sq010/sh070/Houdini'

Version 1:

print "before",
print hou.hscript('echo $HIP')
hou.hipFile.save(os.path.join(hipPath,"ttv_"+shotBaseName+"v001.hip"))
print "after",
print hou.hscript('echo $HIP')

output:

before ('U:/posterToolsBase/mayaScripts\n', '')
after ('U:/projects/ttv/episodes/e408/work/sq010/sh070\n', '')

Version 2:

print "before",
print hou.hscript('echo $HIP')
pa=os.path.join(hipPath,"ttv_"+shotBaseName+"v001.hip")
pa=pa.replace("\\","/")
hou.hipFile.save(pa)
print "after",
print hou.hscript('echo $HIP')

output:

before ('U:/posterToolsBase/mayaScripts\n', '')
after ('U:/projects/ttv/episodes/e408/work/sq010/sh070/Houdini\n', '')

WTF????

Where is Houdini folder gone in version 1?

in both versions .hip file is saved in correct location (in 'U:/projects/ttv/episodes/e408/work/sq010/sh070/Houdini' folder)

But it works now :))

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