Jump to content

Python ROP ?


sebkaine

Recommended Posts

Hi Guys,

 

I would like to know if it's possible to make Python ROP inside a Houdini ROP tree.

Basically you create a node :

- you can in this node enter inline code in Python 

- this inline code will be executed when the node is evaluated 

- the node can be evaluated like a mantra ROP on the current frame or on the frame range

 

The Shell ROP node is the closest thing i have find to this idea. But i need to link a file on disk.

I would like to be able to enter inline python directly and execute this in the ROP tree canvas.

 

Thanks for your time !

 

Cheers 

 

E

Edited by sebkaine
Link to comment
Share on other sites

as well have a look at Wedge ROP for the possible workflow

it's essentially a HDA with Shell ROP inside, which upon execution calls the Python Function function from HDA module

but essentially all the logic of Wedge ROP is Python

Edited by anim
Link to comment
Share on other sites

Many Thanks for your help Guys ! :)

 

@Atom

I want to keep things logic as much as i can and for what i want to do, it's definitly ROP tree task.

Like for exemple.

- generating maya / blender scene in command line

- run executable like isixpack

- run fusion compositing etc ...

 

@Tomas

Very interesting to disect this Wedge ROP. the closest good enough solution without custom tools.

 

@Graham

This is exactly what i want, extremely cool ! i will test this asap. I don't know the HDK part. so if want to compile your otl on windows

i need to load your code in the correct visual c++ release and compile ? or is there more exotic steps ?

 

I will ask this little tool as a default node, it could really be great to build scene procedurally in external package.

 

Cheers

 

Edited by sebkaine
Link to comment
Share on other sites

Thanks again for your answer Graham. There are still things that are not crystal clear. :)

 

i'm quite confuse beetween .otl .hda and the outpout from a HDK pluggin. from what i get

 

The first link you give is an HDK pluggin. So if i compile it under windows it will outpout a compile .dll that i will have to put in my /dso folder.

So to use this one :

1 - compile

http://www.sidefx.com/docs/hdk15.0/_h_d_k__intro__compiling.html

2 - load

http://www.sidefx.com/docs/hdk15.0/_h_d_k__intro__creating_plugins.html#HDK_Intro_CreatingPlugins_Intro

=> You have to recompile it for each new H release.

 

The second link you give me is an .otl from what i get this is the old name for .hda. So basically .hda = .otl = houdini asset,

that you put in the /otl folder, or wherever you want with HOUDINI_OTLSCAN_PATH

 

To build an asset you have several methods :

- build it from a node tree that you put in a subgroup

- build it with the new operator type tool

 

The one you give me was thus produce with new operator type but there are no codes involves ?

So does i must conclude that to do what i want i just need to

- Layout the parameters needed

- put in the script tab :

# This code is run as a script by the Python ROP.
exec hou.pwd().evalParm("code")

and that's it ? a working Python ROP ?

 

I would have one more question how would you proceed to deal with other versions of python.

for exemple some Python ROP will be blender code in Py 3.4.2

some other could be Maya code in Py 2.7

Would it be possible to specify which version the code is ?

Edited by sebkaine
Link to comment
Share on other sites

Well Graham i'm afraid your .otl will not work in my case in fact i use a indie license and i get  :

 

With this trivial inline code :

print 'foo'

The following error :

'oupout driver not supported in houdini indie'.

If i execute 'python fooPrint.py' from a shell node it does works ... 

Edited by sebkaine
Link to comment
Share on other sites

 

The first link you give is an HDK pluggin. So if i compile it under windows it will outpout a compile .dll that i will have to put in my /dso folder.

So to use this one :

1 - compile

http://www.sidefx.co..._compiling.html

2 - load

http://www.sidefx.co...ngPlugins_Intro

=> You have to recompile it for each new H release.

 

That's about right.  It's a black box operator you would need to be able to compile for each build you have installed.  It's somewhat annoying but sometimes necessary.

 

 

 

The second link you give me is an .otl from what i get this is the old name for .hda. So basically .hda = .otl = houdini asset,

that you put in the /otl folder, or wherever you want with HOUDINI_OTLSCAN_PATH

 

To build an asset you have several methods :

- build it from a node tree that you put in a subgroup

- build it with the new operator type tool

 

The one you give me was thus produce with new operator type but there are no codes involves ?

So does i must conclude that to do what i want i just need to

- Layout the parameters needed

- put in the script tab :

# This code is run as a script by the Python ROP.
exec hou.pwd().evalParm("code")

and that's it ? a working Python ROP ?

 

Yes, .hda files are equivalent to .otl files.  But they aren't equivalent to Houdini assets.  This is why I think it was dumb of them to rename the file extension from .otl to .hda since an HDA is an operator type definition, not a file format that can contain multiple HDAs.  To me otl (operator type library) makes more sense since it's a library of one of more HDA definitions.  But whatever.

 

There are definitely various ways to create digital assets.  This otl was created using the File > New Operator Type dialog because I needed to create an actual output driver, not a container containing other existing drivers.  Because it's an actual driver itself it requires some SOHO parameters, which make it actually work.

 

If you look at the Type Properties and show hidden parameters you'll see a couple ones (soho_program and soho_outputmode).  The soho_program is a script that will be executed when the ROP renders.  If you unhide the parm (or look at the default expression) you'll see that it's got an expression that constructs a reference to that custom Script section (opdef:Driver/python?Script) so when the node runs it runs that code as is.  The soho_outputmode (set to 2) tells SOHO that no files are being opened so it doesn't complain that it doesn't have a command or file to deal with.  A regular old Mantra ROP runs IFD.py which handles all the fun of dumping an ifd.

 

Since the script the node points to just executes the block of code in the parameter you've got a ROP that now runs Python code as its primary job, complete with the normal pre/post render/frame scripts as well.

 

 

It is unfortunate that custom output drivers such as this don't work with Indie licenses.  Compiled operators will still work okay (I'm pretty sure...) but yeah, your best bet would be to construct something out of a Shell ROP, similar to the Wedge as Tomas suggested.

  • Like 1
Link to comment
Share on other sites

Thanks for your very helpful answer Graham. In fact i finally get exactly what i want with Tomas idea.

I can execute non houdini related python code inside the ROP tree under Indie License.

 

Here is a small exemple to generate a latlong map from 6 cubemap.

my HOM skills sucks so there must be some mistake , but it work and give the idea.

 

I will try to test this with blender scene creation later.

 

 

python_rop.hiplc

Link to comment
Share on other sites

Well i have found a way to make inline python ROP work, by mixing both technics.

 

The Node work to execute non related houdini  python code. 

- maya / blender python cmd work

- pipeline stuff work

 

But when i try to execute HOM command it doesn't work.

I have not a very good understanding of HOM so i am missing something here.

 

If you have any idea on how to be able to build geo in python within the ROP tree

That would be cool !

python_rop2.hiplc

Edited by sebkaine
Link to comment
Share on other sites

@sebkaine: I took a look at your file and noticed this code in the Out network.

import os
os.system('blender')
I wondered are you trying to import Blender into Houdini?

import os as bpy
os.system('blender')

print dir(bpy)
I tried this code and it failed,however.
Link to comment
Share on other sites

Well there was an env var that was missing for you, i've update the scene.

import os
path = 'C:/Program Files/Blender Foundation/Blender'
os.environ["PATH"] += os.pathsep + path
os.system('blender')

Basically if you push render it will start Blender.

The idea behind this is to use the ROP tree as the core of various process that assemble a shot.

 

You can use the inline to assemble maya scene / blender scene 

Lunch compositing etc ...

 

All external operation work, my problem is that as a bonus i would like to be able to build houdini scene in ROP 

by using the HOM stuff. But it fail at the moment.

 

 

Edited by sebkaine
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...