How I can. Output mantra nodes (use Python or another)

   4320   8   0
User Avatar
Member
45 posts
Joined: Aug. 2012
Offline
Hi to all, dear community of houdini. Give me the right way, please. I want to automate the creation “mantra output nodes” and make such, to in the parameter “Output Picture” automatically generate numbers in path, like: \\master\data\“..”\name of file_“..”.$F5.exr, where “..” generated number that I will ask. And automatically generate name of output node. What me need do to start, where to go, what to look for, what to read? Thanks!

Ok. Let me explain better! Usually, I have to do share the same operation. I just tired and want change this routine work. I want to understand, I have enough brains for it or not.

In a scene there is many cameras and for each I create a new output node (or copy paste), and then I'm doing some changes in path output picture, like name, number of shot, L eye or R eye.

I would like to optimize this process, make it to automatic (now it necessary to do by hand). Just give me some advice, where to dig, how to connect, or just tell me what will need to know for it.
Edited by Felix6699 - Sept. 18, 2016 17:30:07

Attachments:
111.jpg (64.6 KB)
222.jpg (38.1 KB)

User Avatar
Member
2539 posts
Joined: June 2008
Offline
Here are two shorts functions. One creates a Camera and the other creates a Mantra node. Once you have created a node you can populate that node's fields by assigning values to the parameters on that node. You can discover any parameter name by simply hovering over and waiting for the tool tip to popup.

The output parameter on a Mantra node is named vm_picture for instance.

def createCamera():
root = hou.node("/obj/")
if root != None:
n = root.createNode("cam")
n.parm("focal").set(35)

def createMantra():
root = hou.node("/out/")
if root != None:
n = root.createNode("ifd")
s = "c:\my_filename_0001.exr"
n.parm("vm_picture").set(s)
Edited by Enivob - Sept. 18, 2016 19:16:05

Attachments:
ap_create_mantra_camera.hiplc (56.7 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
45 posts
Joined: Aug. 2012
Offline
Holy moley! It's looks good.
Could I use the same method, to make the automatic generation of letters and numbers in the path? For example: c:\data\L\shot01\my_filename_0001_L.exr, where L, shot01, will change to R or 01,02,03…
Plus, is it possible to change the name of a node output in the same way?
And another one thing, where from do you know about: hou.pwd(), createCamera(), hou.node, root.createNode?.

Will be good, if someone will give me advice or direction, what me need read, to learn and better understand the Python programming language. For these purposes, whether good suitable book “Learning Python, Mark Lutz”?
For many, many …. and … very many years, I began to think that I'm not working correct. For me became necessary to know language to describe many monotonous things.

It seems to me or people here are became less to talk about different topics.
Edited by Felix6699 - Sept. 19, 2016 05:18:07
User Avatar
Member
2539 posts
Joined: June 2008
Offline
Could I use the same method, to make the automatic generation of letters and numbers in the path?
Sure, that is just python string manipulation via the modulus character.
shot_revision = 17
s = " c:\data\L\shot01\my_filename_0001_%.exr" % shot_revision
print s
# Or in your case.
n.parm("vm_picture").set(s)

And another one thing, where from do you know about:
Watch the SideFX Master Class video on python. Heck, watch them all!
Also just Google terms with the first term as Houdini. Like houdini createNode, or houdini vex, or houdini python

One thing to remember about python and it's integration into 3D apps, not just Houdini but all of them. Is that python has many versions and syntax does differ between versions and apps. Houdini is currently on python 2.7.5 but the latest version of python is 3.4. So don't waste your time learning the latest python version learn the python version related to Houdini.

Another way to learn is through the built-in Houdini help card system. Just drop down a python node then click the ? icon in the upper right corner where the properties are located. The help system will take you to related information for any selected node.
Edited by Enivob - Sept. 19, 2016 10:37:37
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
the python documentation is here:
http://www.sidefx.com/docs/houdini15.5/hom/_index [sidefx.com]

and you'll want to look through
http://www.sidefx.com/docs/houdini15.5/hom/hou/_index [sidefx.com]
for things like hou.pwd(), createCamera(), hou.node, hou.createNode()

also, open a python shell (Windows > Python Shell)
select a node in your network - like a camera
and in the python shell type
node = 
and drag the camera node into the python shell
you should now see this
>>> node = hou.node('/obj/cam1')
hit enter
then type this:
node
you should get this
<hou.ObjNode of type cam at /obj/cam1>

now type this:
print node.asCode(brief=True)

you'll get all the python code that represents the camera object
not all of this is needed to make a camera
you can just type:
hou_node = hou_parent.createNode("cam", "cam1", run_init_scripts=False, load_contents=True, exact_type_name=True)

Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
45 posts
Joined: Aug. 2012
Offline
Good stuff! Gosh, this is really helpful info. I have to learn a lot of things right now. Houdini well helps to develop the brain. If is anyone can give good advice, direction, I will be happy, cuz it help me in the way.
P.S. I just deleted some of my message.
Edited by Felix6699 - Sept. 19, 2016 11:36:44
User Avatar
Member
45 posts
Joined: Aug. 2012
Offline
First of all, I want to ask the staff. In fact, I do not know exactly, is only me have a problems. At the moment I began to study the Python language in Houdini program, how it works. But, I was faced with the fact that the editors, where I can write code and get feedback (errors, notes, instructions, tips), totally not informative and not comfortable. Honestly, it is very difficult to write code in the existing editing windows. It is more about checking the final result. When I encounter with mistakes in the code - it's a real problem.

This problem is just me?

I like how this is implemented in Maya program, but it also has disadvantages. Can I (we all users) expect more friendly code editors in future? Thanks a lot of much!
Edited by Felix6699 - Sept. 30, 2016 19:17:32

Attachments:
maya.jpg (136.3 KB)

User Avatar
Member
2539 posts
Joined: June 2008
Offline
This problem is just me?
No we all know these editors stink. The MEL editor is ugh and Blender's will drive you crazy. You'll be typing a long and the mouse will drift into the line number area and the next number you type jumps you to that line.

I think there are some ways to link external editors to Houdini. You may want to search around on that. I think under preferences you can specify which editor comes up when you press CTRL-E in a text field.

One thing I do like about X-Code is the text editor, I like Visual Studio's text editor as well. There are even open source editors which I like better than the integrated one.

Sometime I wonder why the dev team does not integrate one of these better open source editors, which are free for all uses, into the program?
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
45 posts
Joined: Aug. 2012
Offline
Enivob, the really I agree with you. I think the question here in reality. Inside development department SIdeFX need to appoint a person who will deal with this issue. To do this, most likely, it is necessary to allocate resources and rewrite the existing code. While at the same time it looks strange, against the background of constant innovation.

As always, thank you for the excellent advices! Thanks to this forum and the humans here, I can learn something new, learn and receive great advices.

I would also like to add here links for those who will be looking for any information about Python (old site documentation contains these useful links):

Scripting Learning Python [archive.sidefx.com]
Fantastic tutorial [docs.python.org]
Little tutorial, how to start in houdini:
deborahrfowler.com [deborahrfowler.com]
Edited by Felix6699 - Oct. 1, 2016 17:56:54
  • Quick Links