Search the Community
Showing results for tags 'hou'.
-
So I am working on a project which is requiring me to extract the point numbers from an arbitrary polygonal object. The most pythonic way to do what I am trying to do is this: geo = hou.Geometry() geo.loadFromFile(path/to/my/file.bgeo.sc) primPoints = [[pt.number() for pt in pr.points()] for pr in geo.prims()] I need to maintain the winding order and get it down to just the ints for the point numbers. I have profiled every function in this, and hou.Prim.points() is god awful slow, taking up 16 of 22 seconds on a 1.5M poly, 800k point file. I am trying to find a way to circumvent hou.Prim.points() but nothing is jumping out to me. I have even moved everything into Pandas, which does make working with the data and doing further transformations easier, but I have not gotten any performance increases as it still relies on calling hou.Prim.points() for every primitive. I have contemplated trying to use hou.Geometry.points() and calling hou.Point.prims() to go at it from the other direction, thinking that it might save me some time since the list of points is always shorter than the list of prims, but it loses the winding order, which I need for my use case. Said use case is parsing cached geometry into a custom format for optimized use elsewhere. I have been able to get the performance up to snuff on just about everything else, and will save even more time on later steps thanks to Pandas data management, but this singular step is so sluggish that it just about tanks the whole project. Literally everything else in the pipeline that I am developing is under 4-5 seconds/frame for huge geometry volumes in the pre-process step (which this is part of) and the final end of the process is so fast I'm not even going to talk about it. Literally just this is bogging things down in an untenable way. Pandas code for reference: import pandas as pd geo = hou.Geometry() geo.loadFromFile(path/to/my/file.bgeo.sc) primsSeries = pd.Series(data=geo.prims()) primsSeries = primsSeries.apply(hou.Prim.points) primsSeries = primsSeries.apply(lambda x: list(map(hou.Point.number, x))) The two take virtually identical amounts of time with the pure pythonic one being a couple seconds faster because it is doing the hou.Point.number in the same step as the list generation, whereas the Pandas code currently does it as a secondary step. I'm sure I could include it in the hou.Prim.points apply, but this was mostly separated for profiling to see where all of my speed was going. Does anyone out there have any idea how to bypass hou.Prim.points in this process in favor of something faster or am I 100% stuck?
-
Hi, Using python in houdini. I'm trying to get the full network path from the network editor that's under my mouse cursor. This is the code I have so far. I put this code in a shelf button. Assigned a hotkey to the shelf button. When I'm over my network editor I press the hotkey and this works, getting the name of the panetab of the network editor under my mouse cursor. paneTabObj = hou.ui.paneTabUnderCursor() print paneTabObj.name() #prints panetab6 in my case I'm trying to find a way to get the network path of this network editor panetab. For example "/ob/geo1/subnet2/"
-
import hou #CreateNode root = "/obj" node = hou.node(root).createNode("geo" , "test") #ParmGRP parm_group = node.parmTemplateGroup() parm = hou.IntParmTemplate("testParm", "TestParameter" , 1) #ParmAppend parm_group.append(parm) node.setParmTemplateGroup(parm_group) #Move To Tranform Folder() parm_group.remove("testParm") parm_group.appendToFolder(parm_group.findIndicesForFolder("Transform"),node.parm("testParm").parmTemplate()) node.setParmTemplateGroup(parm_group) #################### MOVE TO ROOT ####################### #################### ERROR ####################### parm_group = parm_group parm_group.remove("testParm") #parm_group.appendToFolder(parm_group.findIndicesForFolder("Misc"),node.parm("testParm").parmTemplate()) parm_group.appendToFolder(parm_group.findIndicesForFolder("root"),node.parm("testParm").parmTemplate()) node.setParmTemplateGroup(parm_group)
-
Hi. Guys. I got a huge work to do, there is a fbx file export form max,when i import it to houdini, it include too much parameters on Geo interface form max. So i want delete it all since it was useless. I make a sketch show what i want to do. I just want to remove the ss parameter form interface, not just delete the keyframes or expression. If there was something like hou.parm().destory() modules can do this. Thanks.
-
Hi, I am programmatically generating Houdini scene (HIP) files After creating and connecting nodes, I'd like to perform a layout and home so that when the user open up the scene, it is not one ball of nodes in the center. Is there a way to do that in Hython calls, what about C++ ? Cheers
-
Hi there, I'm importing the hou module into a custom python script and I would like to have multiple scenes opened at the same time. This is how it is implemented: import sys from importlib import reload sys.path.append(HOUDINI_PATH) try: import hou except ImportError: print('houdini.py: There was a problem loading the hou module') box_hip = hou.hipFile box_scene = box_hip.load(path/to/box_scene.hipnc) print(box_hip.name()) # ==> box_scene.hipnc CORRECT reload(hou) sphere_hip = hou.hipFile sphere_scene = sphere_hip.load(path/to/sphere_scene.hipnc) print(sphere_hip.name()) # ==> sphere_scene.hipnc CORRECT # Let's print the name of box_hip again print(box_hip.name()) # ==> sphere_scene.hipnc WRONG As you can see, even though I've reloaded the hou module, it's still using the same hou instance for both hip files and therefore always returning the data of the latest loaded scene. Is there a way to have different instances of the hou module so I can load and work on multiple different hip files in the same script? I've also tried to assign hou to different variables with no luck. Any help would be highly appreciated, thanks in advance!
-
Hey guys, I am trying to store some variables into the session source so I can easily get at it at any time. So far the tests I've been running have been working great, but I am not quiet sure how I can expand on the syntax to allow for variables to control the values set into the source. This is the syntax I've used so far: hou.setSessionModuleSource("variablename = 0") However, as far as I've been able to figure out this will only allow for hard coded values, I am looking to insert the value from a variable instead of a hard coded value, like this: mynum = 3 hou.setSessionModuleSource("variablename = mynum") When I try this in the python shell I get the error back that "name 'mynum' is not defined" (along with some more text, most notably of which I guess is that it says the operation failed). Do you guys have any tips on how I could make this work? Sorry if this is very basic, I've been trying to look around for specific syntax examples but I am having kinda a hard time finding examples of actual syntax for the Houdini specific python commands. Thanks for the read!
-
import hou import pprint node = hou.node('/obj/geo1/subnet2/TestNode') number = 5 parm_tuple = node.parmTuples()[number] name = [parm.name() for parm in parm_tuple] group = node.parmTemplateGroup() parm_template = group.entriesWithoutFolders()[number] myIndex = group.containingFolderIndices(parm_template) folder = group.entryAtIndices(myIndex) ContFolder = group.containingFolder(parm_template) name = ContFolder.name() label = ContFolder.label() node = hou.node('/obj/geo1/subnet2') group = node.parmTemplateGroup() folder = hou.FolderParmTemplate(name, label) folder.addParmTemplate(parm_template) group.append(folder) node.setParmTemplateGroup(group) I am not a python guy, and I'm stuck and need some help. What I want to do is, I want to make a custom HDA that has a node(ex.Mantra) inside, and I want to copy all the parm(+folders) in the Mantra Node,and paste it in the HDA parameter. Also I want to reference it each. I tried and figured out how to copy the parm and folder,but when I do this to all the parm,it will make a lot of folder with the same name... Is there any good way to do this? I want do it with python. Thanks, Hiro
-
Dear colleagues, Houdini provides developers with an option to open the File-/Node-Dialog (such as hou.ui.selectFile() and hou.ui.selectNode()). However, in case I call it from the external QWidget, in my case it is PySide2. If I close this PySide2's QWindow, obviously, it causes the Houdini crash, because hou.ui.selectFile() should return a string to the PySide2's QWidget parent. Here is an example: I have a tool on the Shelf, it opens PySide2 QWidget. Imagine there is a button which opens hou.ui.selectFile() or hou.ui.selectNode(). After calling this function, Houdini creates one more subwindow with File-/Node-Dialog respectively. However, if I close QWidget, any of two select functions return a result to non-existed at the moment sub-application. It causes Houdini crash. I am looking for how can I take the reference to this File-/Node Dialog to properly terminate it on closeEvent(self, event), because disabling QWidget's UI, while File-/Node Dialog is open, doesn't seem to be the best solution. One of the possible answers might be: use PySide2's File Dialogs. What seems to be ok for the File-/Path-Dialog, but it might take time to produce custom hou.ui.selectNode(). Thank you in advance!
-
Hey ODFORCE, Does PyCharm integrate with Houdini well? (Auto-completion, external debugging, unit testing?) Just curious. I did find some blog posts on VS Code set up, but I was curious about Houdini and PyCharm specifically. There was an issue with PySide from an earlier post..? (I'm fairly new to IDE set up, so forgive me if it's obvious) There are plugins for Nuke and Maya for PyCharm. Nothing for Houdini though.
-
Hi everyone, I'm trying to have my Python Module in my HDA place another node right below my asset on creation. So my OnCreation script runs my python module from disk, which has the following code: pos = first_node.position() second_pos = (pos[0], pos[1] - 2) second_node.setPosition(second_pos) This does nothing. The second node is always created near (0, 0) in the network editor. But if i run those lines in the Python shell in Houdini, it works just fine. So that tells me that the OnCreated scripts don't wait for the HDA to actually be placed into the scene before running, despite what the docs say (a problem I've run into before). My solution to this was to use hdefereval to wait to run the code until the event loop was idle. This shows promises of working, but I'm running into issues now. The code I'm trying is: pos = first_node.position() second_pos = (pos[0], pos[1] - 2) hdefereval.executeDeferred("second_node.setPosition(second_pos)") but the problem here is that when it goes to execute the code, the variables no longer exist, and the code fails because "Name 'second_node' is not defined". But I use a custom 123.py script every day that has the exact line hdefereval.executeDeferred("hou.hscript(code)") where "code" is a pre-defined variable, and hdefereval has no problem using that variable when it goes to execute. So I'm not really sure what the problem is here. What is the best way to move a node using Python? (and if you know how to get my hdefereval call to work, that'd be even better!) Thanks, ~Chris
-
I have added interpreter " C:\Program Files\Side Effects Software\Houdini 16.0.705\python27\python2.7.exe ". Added paths "C:\Program Files\Side Effects Software\Houdini 16.0.705\houdini\python2.7libs " to pycharm. added "C:\Program Files\Side Effects Software\Houdini 16.0.705\houdini\python2.7libs" to system's PATH variable of win10 but when i type in "from PySide2 import QtWidgets " i get the error message in PyCharm : Unresolved reference 'PySide2'
-
Hello, in Houdini 15 I was using hou.ui.selectFile() dialog to get user's input and I would process it further in python. I used the same function to let user select files or folders, based on the needs of a tool. Now I updated to 16 and the function does not seem to enable user to select a folder, it works only with selecting a file. Does anybody know if there is a way to select a folder in 16? I want to batch process files in a directory and I would like to use file browser dialog to let user set it. In worst case I could use hou.ui.readInput(), and to ask user to enter a path there, but this is super user-unfriendly Thanks, Juraj
-
I imagine this is very simple but I find building ui's with python a bit tricky (compared, for example, to Maya which is very straight forward). I want to create a simple window (or dialog or ui) with several text fields, float fields, int fields etc. I have it working with hou.ui.readMultiInput, but you don't have much control in terms of layout/styling or what data types are allowed/expected. What are the best functions for this kind of thing?
-
Hello, what I would like to do is very simple, just for an exercise. I would like to run Houdini from a Python script using the hou module. What I am trying to get working is something like: import sys import subprocess sys.path.append('/opt/hfs15.0.244.16/houdini/python2.7libs') import hou hou.hipFile.load(file_name='/home/ramon/hello.hipnc') sf_geo = hou.node('/obj').createNode('geo') But I get no UI. I could do subprocess.Popen(['houdinifx', '/path/to/hipfile.hpnc']) but it creates deatached from the python script. Maybe should I create it first through shell (subprocess.Popen) and then load it using hou.hipFile? and start playing with it inside the python script? I would like to have a self-contained example. Just a python file that the user just runs like python script.py no more. Thanks and sorry for the stupid question. EDIT: I think I found out what I was looking for... haha... now i can compile vfls using Popen subprocesses and import them afterwards and doing everything in a self-contained file. cool. import sys import subprocess sys.path.append('/opt/hfs15.0.244.16/houdini/python2.7libs') import hou hou.hipFile.save(file_name='/home/ramon/hello.hipnc') hou.hipFile.load(file_name='/home/ramon/hello.hipnc') sf_geo = hou.node('/obj').createNode('geo') hou.hipFile.save(file_name='/home/ramon/hello.hipnc') subprocess.Popen(['houdinifx', '/home/ramon/hello.hipnc'])
-
Hi I want to import .abc cache containing a maya camera into houdini scene, but I can't seem to find the approriate hscript or hou functions. I mean I can do it manually by file --> import--> alembic scene. But How do I automate this in python script ? there is some animation from frame 1-100 in the .abc file. I tried to compile alembic on windows 8.1 because I want to try the SOP_AlembicIn included in the code, I got lots of error when trying to do so. For geometries I know I can create a geo node, and go inside create a alembic node to import .abc file.I think convert this to hscript is pretty straightforward. But for camera .abc file, this doesn't work, while file --> import--> alembic scene seems working, is there a way to code this camera import in python ? or is there another way ? or someone has compiled this for windows ? Thanks.