Jump to content

create .geometry() in hdaModule (Python)


kellerkind

Recommended Posts

Sup Houdini Coders,

I'm pretty new to coding. Atm I'm writing my thesis about implementing a SphSolver in Houdini.

Problem I have is that I cant create geometry inside a Operater Pythonmodule (hdaModule).

Is there a way to modify the permission or is my workflow plain stupid? :D

 

Ty for your time, regards Kellerkind

 

PS: I pass kwargs['node'] in the callback script for testGeo(self)

geoOnlyhdaModule.jpg

Link to comment
Share on other sites

Thank you for your fast answer. Atm I'm using a button from the parameters. How comes you only can use the code section? 
How I build my node system at the moment:

--> Geometry to use (in szene layer)

---------------------------------------------------------------------------(Houdini Digital Asset)-------------------------------------------------------------------------------------------------------------------------------

--> Python Script instances all Points form that Geometry Node

--> Geometry Operator gives all points from the instance to the solver (external)

--> now the problem is I want to setPosition the points from the instance to the position the solver has solved, which doesnt work beacuse it "only reads geometry"

---------------------------------------------------------------------------(Houdini Digital Asset)-------------------------------------------------------------------------------------------------------------------------------

 

At the moment all my parameters etc. are instanced to my Digital Asset (in Szene Layer), where i can input the length of the simulation etc. and start it with the 'render button' which is just an instance of the callback parameter from my Geometry Operator. 

Hope you understand ;)

Link to comment
Share on other sites

So this was my setup, my question now is, how do i manipulate geometry best in a custom geometry operator?

Do I make some functions and methods in the hdaModule and execute them in the code area? But then how do I instance the exec to my Houdini Digital Asset in Scene Level?

 

Link to comment
Share on other sites

It works like code in Python node. You can read and write to input's Geometry object. It is up to you where to store functions. For example, you may write everything inside PythonModule and just call do_everything(args) in Code section. Once the new Python SOP operator is defined, you then place it like a normal SOP node. You probably cannot have a Python OBJ with such writable geometry object anywhere. Python OBJ is a OBJ subnet for another OBJ nodes, not SOPs.

Edited by f1480187
  • Like 1
Link to comment
Share on other sites

Thank you very much! It helps ;)

Now I have another problem:  I used the python module to store the variables etc. for the solver.

I use the Code Area from the Operator the solve per Frame and the Module to set the Attributes of the Solver (Density, Viscosity, Boundaries etc.).

Problem now is, that I want to load the Module one time at the start (for all the variables etc.) and the rest of the code per Frame.

How do I best pack them both in the Code Area? Any Ideas?

PS: Do you know how to cache the geo automatically to the timeline so you can scrub through?

 

Thank you very much!

Link to comment
Share on other sites

If you want to maintain some global data, you may write it to hou.session module. If you execute it once, you then may access hou.session.x variable and edit it everywhere within same Houdini instance.

hou.session.x = [1, 2, 3]

You have several types of events in drop-down list where you selected "PythonModule". For example, it is possible to set variables on node creation time. You need to handle cases where two nodes was created. It is also possible to store some data in dictionary fomat on the placed node itself:

ID = 123
hou.pwd().setUserData('ID', ID)

 

Otherwise, I didn't understand the problem you facing now.

 

1 hour ago, kellerkind said:

how to cache the geo automatically to the timeline so you can scrub through?

I think it is not possible to manage such cache from python, but you may cache in RAM with Cache SOP.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Heyho Again, my solver implementation works at the moment, thank you for your answers!

Yes I outsourced the variables to the pyModule and got them via x = hou.phm().x, for cache i used the cache node from Houdini.

Now I just need 2 more things ;) :

1. How do I reset / reload / force re-read a Script?

At the moment I instance an objects points. But the problem is, the instanced points stay the same, even if i change the object from which i instance (e.g. make more vertecies, move it, scale it, etc.)

Same goes for my solver, it  gets set 1 time at the start of the simulation. So if i want to reset the solver, i have to go to my node properties and accept to them to reset the script.

So I somehow want the script to renew  (Or the SOP itself, doesent matter which one).

 

2. is there a way to make a script / node timedependent?

I found nothing (I work at the geometry level right now), so I just set the node 'pseudo time dependent'  with:

hou.setFrame(hou.frame())

But I have the feeling it slows the script with that term and also its not nice to read ^-^

 

 

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