mic Posted November 17, 2008 Share Posted November 17, 2008 (edited) hello! i am writing a very easy script, which copies the selected nodes N times, renames them and changes some parameters. The question is how should i query the copied nodes? # selecting the node set selected = `opselect("/obj")` #copy-pasting this node once opcp "/obj/"$selected "/obj" but how can i get my new copy to rename it and to change the parameter? I want smth like set copy = `run('opcp "/obj/"$selected "/obj"')` but it's not right, $copy is empty. So, i need my copies in a variable.. Thank you! Edited November 17, 2008 by mic Quote Link to comment Share on other sites More sharing options...
symek Posted November 17, 2008 Share Posted November 17, 2008 (edited) you just need to give your copy a name to be able to refer to it. opcp /obj/$selected /obj/`$selected + _copy` Edited November 17, 2008 by SYmek Quote Link to comment Share on other sites More sharing options...
mic Posted November 17, 2008 Author Share Posted November 17, 2008 oh, thanks) Quote Link to comment Share on other sites More sharing options...
edward Posted November 18, 2008 Share Posted November 18, 2008 Note that it's probably easier to do these types of tasks in Python (via HOM) instead these days. Quote Link to comment Share on other sites More sharing options...
mic Posted November 18, 2008 Author Share Posted November 18, 2008 Note that it's probably easier to do these types of tasks in Python (via HOM) instead these days. few months ago i have the strange and unsolved problem with one scene, i had to recook many nodes each time i started it, possibly it was smth like a bug.. and i wrote a simple script-`recooker` in hscript and tried to write the same in py. but there was the 'updateui' command, which haven't yet implemented in HOM, so i thought it was better to wait until HOM would be implemented wider =)) and this script (if these few strokes are the 'script')) i'll translate to py for studying) maybe for the very newbies these nine strokes will be useful. # copy camera N times with left/right crop offset set selected = `opselect("/obj")` set N = 10 for i = 0 to `$N - 1` set j = `$i + 1` opcp /obj/$selected /obj/`$selected + _CROP_`$i opparm /obj/`$selected + _copy`$i cropl `$i/$N` opparm /obj/`$selected + _copy`$i cropr `$j/$N` end Quote Link to comment Share on other sites More sharing options...
edward Posted November 19, 2008 Share Posted November 19, 2008 For manipulating nodes, I think HOM is easier these days. For anything that HOM doesn't have implemented yet, there's hou.hscript() def copySelectedCam(n): """ Copy the selected cameras N times with left/right crop offset """ net = hou.node("/obj") selected = net.selectedChildren()[0] for i in xrange(0,n): copied = hou.copyNodesTo([selected], net)[0] copied.setName(selected.name() + "_CROP_" + str(i)) copied.parm("cropl").set(float(i) / n) copied.parm("cropr").set(float(i + 1) / n) Quote Link to comment Share on other sites More sharing options...
mic Posted November 19, 2008 Author Share Posted November 19, 2008 (edited) thank you very much, Edward, the only thing i'm still using 9.1.244 build and.. "hou.Node.selectedChildren method This is not implemented yet" =)) and the last question is.. to execute python function we have python source editor and hou.session.our_function() in python shell. and in Hscript i haven't found how to execute function, only .cmd script.. so i had to write "set N = 10". That's not very convenient =) Edited November 19, 2008 by mic Quote Link to comment Share on other sites More sharing options...
edward Posted November 19, 2008 Share Posted November 19, 2008 Isn't that all the more reason to use python? Quote Link to comment Share on other sites More sharing options...
mic Posted November 20, 2008 Author Share Posted November 20, 2008 quite it is) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.