Jump to content

Search the Community

Showing results for tags 'python'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Lounge/General chat
    • Education
    • Jobs
    • Marketplace
  • Houdini
    • General Houdini Questions
    • Effects
    • Modeling
    • Animation & Rigging
    • Lighting & Rendering
    • Compositing
    • Games
    • Tools (HDA's etc.)
  • Coders Corner
    • HDK : Houdini Development Kit
    • Scripting
    • Shaders
  • Art and Challenges
    • Finished Work
    • Work in Progress
    • VFX Challenge
    • Effects Challenge Archive
  • Systems and Other Applications
    • Other 3d Packages
    • Operating Systems
    • Hardware
    • Pipeline
  • od|force
    • Feedback, Suggestions, Bugs

Found 509 results

  1. Hello everyone, Is it possible to add a callback that runs everytime a node is created ? At my studio we have a library of hda (hundreds of nodes) and I'd like to check if the node comes from the general library, or the project library and simply set a color depending on its definition path. I tried scripts/OnCreated.py with a package and appending the path to the Houdini path but nothing is happening. I also thought appending a few lines of code using nodeDefinition.sections()["OnCreated"].setContents("print('Hello')") but doing this for hundreds of hda's, and everytime one is created, requires a bit more work than what I can do for now. Is there a solution ? I've looked at ui event but I haven't found anything interesting. Cheers,
  2. HDA Module double evaluates

    i am using on Update script to test a function, it was working fine until it started double printing data. i replaced everything with just a print function and still the problem remains. is there a fix for this? i tried the same in a python sop and it only evaluates once as it should
  3. Help with Python hierarchy syntax

    Hello! Python & programming newbie here having problems with syntax and hierarchy. I want to use... not sure what the right description is but: full function calls / paths with the complete path from root (hom module) to leaf (a method inside a class which is inside the hom module) In order to better visualize the hom module structure. The default Python SOP with the 2 starting lines "node = hou.pwd()" and "geo = node.geometry()" creates some kind of typing shortcut and this hiding method might be good for seasoned programmers but for someone new like me it's confusing! Sorry about the rant! Here is the basic task I'm trying to accomplish in the Python SOP. 1: Create a vector 3 variable 2: Create a point 3: Set new position of point with the created vector 3 variable Here are the 3 terrible lines I tried to write: position = hou.Vector3((5.0, 5.0, 5.0)) newpoint = hou.pwd().geometry().createPoint() newpos = hou.pwd().point().setPosition(position) Result: Python error: Traceback (most recent call last): File "<stdin>", line 7, in <module> AttributeError: 'SopNode' object has no attribute 'point'" Q1: How do I fix the syntax here? Q2: Is there a better method of accomplishing the same thing in the Python SOP? (I'm aware VEX is better for data manipulation but this part of the process requires Python) **EDIT** Discovered the 2 problems (both in line 3). 1:Missing a self argument '0" in the point class's "setPosition" method/function. The Doc doesn't mention anything about this argument requirement. 2:The full path of the point class is inside the geometry class but the Doc help has them listed side by side "hou.point" & "hou.geometry" without hierarchy consideration. Here is the working 3 line code with full paths. Please let me know if there's any improvements or better methods position = hou.Vector3((5.0, 5.0, 5.0)) newpoint = hou.pwd().geometry().createPoint() newpos = hou.pwd().geometry().point(0).setPosition(position)
  4. how can i delete/create nodes in a locked hda from the python module? i am using a button with a callback script that runs a delete() function for n in node.children(): n.destroy(True) i get an error message that i don't have permissions because the asset is locked. Is there a way around this? callback_parm_kwargs_hda_node.hip
  5. i am using python to create a file SOP assign a path and import a bgeo file. After that i am creating some more nodes in my graph and i need a primitive name attribute from that bgeo. From primitive 0 prim = filenode.prim(0) #get first primitive of node filenode name = prim.attribValue("name") #get primitive attribute name This throws an error ----> AttributeError: 'SopNode' object has no attribute 'prim' Is it possible to read the attribute?
  6. I have observed a very weird bug. I am using a python node to create a bunch of file SOP nodes and bring in fbx files from a folder. The bug is that the uvs are messed up in comparison to doing it manually where i place a file sop node and select my model - the uvs are fine. Anyone else noticed that? Is this a bug or is my code broken? demo_scene.hip
  7. Hi there, I have been making a HDA that contains a python script in the 'python module' section. The goal is to wire multiple mantra nodes into this single HDA and then correctly generate multiple setups inside the HDA that configure the rendering setup to be handled by our farm running Afanacy. The tool is working pretty nicely on its own, but once I put multiple nodes in the OUT network and generate a second one it also affects the other nodes. I thought this was because I had global variables in my python script, so I got rid of them and made a 'dataObject' class that is generated on the single nodes and passed down to all functions. however, this did not solve the issue. I figure it has something to do with scope but can't figure out what it is. I'll put the code down here below. Feel free to give any tips, I don't have much experience with Houdini python in particular. import hou import os import re from os import path alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] class dataObject: renderasset = hou.Node base_ifd_generator = hou.Node base_distributed_renderer = hou.Node base_afanacy_merger = hou.Node master_merger = hou.Node mantra_duplicates = [] # List of all mantra nodes that will be compied from inputs. Ordered by input index ifd_generators = [] # List of all Afanacy nodes that are configured as IFD generators distributed_renderers = [] # List of all afanacy nodes that are configured as renderers afanacy_mergers = [] # List of all afanacy nodes that are only used for merging the different stages. def reset(data): for mantra in data.mantra_duplicates: mantra.destroy() for ifd in data.ifd_generators: ifd.destroy() for renderer in data.distributed_renderers: renderer.destroy() for merger in data.afanacy_mergers: merger.destroy() del data.mantra_duplicates[:] del data.ifd_generators[:] del data.distributed_renderers[:] del data.afanacy_mergers[:] def getOptions(data): autoversioning = data.renderasset.parm('autoversion').eval() print("automatic versioning set to; " + str(autoversioning)) def generate(thisnode): data = dataObject() data.renderasset = hou.node(thisnode.path()) print(data.renderasset.name()) data.base_ifd_generator = hou.node(thisnode.path()).glob("ifd_generator_SETUP") data.base_distributed_renderer = hou.node(thisnode.path()).glob("distributed_renderer_SETUP") data.base_afanacy_merger = hou.node(thisnode.path()).glob("afanasy_merge_SETUP") data.master_merger = hou.node(thisnode.path()).glob("*MASTER_MERGE*") reset(data) getOptions(data) configureRenderers(data) print("Internal network for node '" + data.renderasset.name() + "' has been generated.") def submit(): getOptions() size = len(data.mantra_duplicates) if size < 1: print("WARNING: render asset should first generate an internal network before submitting.") else: checkVersions() data.master_merger[0].parm('submit').pressButton() def configureRenderers(data): data.master_merger[0].setParms({ "job_name" : data.renderasset.parm('jobname').eval() }) inputs = data.renderasset.inputs() print("name: " + str(data.renderasset.name())) for idx,value in enumerate(inputs): configureRenderSetup(data,idx, value) connectRenderSetup(data,idx) setIfdSettings(data,idx) setRendererSettings(data,idx) setMergerSettings(data,idx) layoutNetwork(data,idx) connectMasterRenderer(data) data.renderasset.layoutChildren() def computeVersion(outputPath, patternName): if path.exists(outputPath): ifd_directories = os.listdir(outputPath) pattern = re.compile(patternName) version = 0 for dir in ifd_directories: if pattern.search(dir): version += 1 return alphabet[version] def checkVersions(data): for idx, mantra in enumerate(data.mantra_duplicates): render_version = computeVersion(data.renderasset.parm('renderroot').eval(), data.renderasset.inputs()[idx].name()) ifd_version = render_version ifd_destination = data.renderasset.parm('ifdroot').eval() + "/" + "ifd_" + data.renderasset.inputs()[idx].name() + "_" + ifd_version + "/" + data.renderasset.inputs()[idx].name() + "_ifd.$F4.ifd" img_destination = data.renderasset.parm('renderroot').eval() + data.renderasset.inputs()[idx].name() + "_" + render_version + "/" + data.renderasset.inputs()[idx].name() + ".$F4.exr" mantra.setParms( { "soho_diskfile" : ifd_destination, "vm_picture" : img_destination }) def configureRenderSetup(data,inputIndex, node): data.mantra_duplicates.append(node.copyTo(data.renderasset)) data.mantra_duplicates[inputIndex].setName("MantraInput_" + str(inputIndex)) render_version = "_" + str(computeVersion(data.renderasset.parm('renderroot').eval(), data.renderasset.inputs()[inputIndex].name())) ifd_version = render_version ifd_destination = data.renderasset.parm('ifdroot').eval() + "/" + "ifd_" + data.renderasset.inputs()[inputIndex].name() + "/" + data.renderasset.inputs()[inputIndex].name() + "_ifd.$F4.ifd" img_destination = data.renderasset.parm('renderroot').eval() + data.renderasset.inputs()[inputIndex].name() + "/" + data.renderasset.inputs()[inputIndex].name() + ".$F4.exr" if bool(data.renderasset.parm('autoversion').eval()): print("autoversioning") ifd_destination = data.renderasset.parm('ifdroot').eval() + "/" + "ifd_" + data.renderasset.inputs()[inputIndex].name() + ifd_version + "/" + data.renderasset.inputs()[inputIndex].name() + "_ifd.$F4.ifd" img_destination = data.renderasset.parm('renderroot').eval() + data.renderasset.inputs()[inputIndex].name() + render_version + "/" + data.renderasset.inputs()[inputIndex].name() + ".$F4.exr" data.mantra_duplicates[inputIndex].setParms( { "soho_outputmode":1, "soho_diskfile" : ifd_destination, "vm_inlinestorage" : 1, "vm_writecheckpoint" : 0, "vm_picture" : img_destination }) data.ifd_generators.append(data.base_ifd_generator[0].copyTo(data.renderasset)) data.distributed_renderers.append(data.base_distributed_renderer[0].copyTo(data.renderasset)) data.afanacy_mergers.append(data.base_afanacy_merger[0].copyTo(data.renderasset)) def connectRenderSetup(data, inputIndex): data.ifd_generators[inputIndex].setInput(0,data.mantra_duplicates[inputIndex]) data.afanacy_mergers[inputIndex].setInput(0,data.ifd_generators[inputIndex]) data.afanacy_mergers[inputIndex].setInput(1,data.distributed_renderers[inputIndex]) def setIfdSettings(data, inputIndex): data.ifd_generators[inputIndex].setParms( { "f1" : data.mantra_duplicates[inputIndex].parm('f1'), "f2" : data.mantra_duplicates[inputIndex].parm('f2'), "enable_extended_parameters" : 1, "hosts_mask" : data.renderasset.parm('ifdhosts').eval(), "priority" : data.renderasset.parm('priority').eval() }) def setRendererSettings(data, inputIndex): data.distributed_renderers[inputIndex].setParms( { "f1" : data.mantra_duplicates[inputIndex].parm('f1'), "f2" : data.mantra_duplicates[inputIndex].parm('f2'), "cmd_files" : data.mantra_duplicates[inputIndex].parm('soho_diskfile'), "enable_extended_parameters" : 1, "hosts_mask" : data.renderasset.parm('renderhostmask').eval(), "priority" : data.renderasset.parm('priority').eval() }) def setMergerSettings(data, inputIndex): data.afanacy_mergers[inputIndex].setParms( { "f1" : data.mantra_duplicates[inputIndex].parm('f1'), "f2" : data.mantra_duplicates[inputIndex].parm('f2'), "enable_extended_parameters" : 1, "hosts_mask" : data.renderasset.parm('renderhostmask').eval(), "priority" : data.renderasset.parm('priority').eval(), "job_name" : data.renderasset.inputs()[inputIndex].name() + "_afanacy_renderer" }) def layoutNetwork(data, inputIndex): data.mantra_duplicates[inputIndex].moveToGoodPosition() data.renderasset.layoutChildren() def connectMasterRenderer(data): for i,v in enumerate(data.afanacy_mergers): print("i: " + str(i)) print("v: " + str(v.name())) print("mm: " + str(data.master_merger[0].name())) data.master_merger[0].setInput(i,v)
  8. Hello, I wrote a little python snippet which load a preset of an HDA when conditions are met. The only thing I haven't succeed is to get the HDA path without writing it exactly (if I copy paste the HDA the path need to change automatically or if I change the name of the HDA). My python node is inside the HDA so maybe there's an expression for something like this. Thank you ! EDIT : a very simple work around is just to use the opfullpath in vex and read the path back in Python.
  9. FLood attribute Paint with Python

    Hello I am trying to add a button or just a shelf script that will allow me to flood the current selected attribute Paint node but I am struggling understating how. Any help will be greatly appreciated Thank you
  10. n = hou.node("/path/to/node") g = n.parmTemplateGroup() p = hou.StringParmTemplate("test", "Test", 1) g.append(p) n.setParmTemplateGroup(g) So, the above code creates the first image, without the floating panel type chooser. What I like to create is the second one. One with camera filter and other with geo filters. Can someone help me with it? didn't find anything so far, or may be looking in the wrong place. Ignore the Label. Looking for some help here. this is my first post, so!!
  11. Hi There, I'm trying to set the background image of the default render view via python and having absolutely no success! I can get the current render view doing something like this: panes = hou.ui.paneTabs() ipr = [x for x in panes if x.type()==hou.paneTabType.IPRViewer][0] but I can't find the display settings associated with the pane, am I even looking in the right place? I'm a bit lost on this one so any help would be greatly appreciated :s
  12. Soft Boolean

    Soft Boolean technology, which was previously part of Modeler for Houdini addon, is now available as a separate product. Soft Boolean tools allow you to stitch polygonal meshes with boolean operations and adding accurate fillets to the resulting geometry. Houdini node can be used with the classical procedural way as well as with the help of special shelf tools. Also, the node can be used in other programs using Houdini Engine. The package contains a plugin for Houdini and some scripts for Maya. Release video: https://vimeo.com/592734907 Product link: https://alexeyvanzhula.gumroad.com/l/iWQyT
  13. auto-execute python on a node

    HI, I am learning python script. So far, I can execute python code by clicking a custom button, and it sets parameters of today(string) and switch(integer). I wonder how we can automatically execute that python code. For instance, when I select the node SOP, or houdini accesses node network from somewhere as need, these parameter values are automatically calculated or updated. Question 1 When I directly write python code in the parameter like second screenshot, it works for integer but not strings. Why did not the string work? Question 2 Let's say I have 20 parameters, and ideally I want to control all the parameters from one master python script in the code parameter, instead of writing python code each parameter 20 times. Then I was thinking : code parameter{string) > Callback script > exec(kwargs['node'].parm('code').eval()) However, auto-execution happens only when I change code's strings. And this is not what I am looking for. Execution should happen when I select the node or Houdini access it during node network calculation. If anyone knows how I should change, it would be appreciated. Thanks!
  14. Python 3

    I have two questions 1) how can i can update python 3.7.4 to the latest version Houdini 18.5.596 installed python 3 as far as i can tell, i previously had only 2.7 installed on my pc. Does this mean python 3 is available only for Houdini? How can i update 2) How can i pip install packages to that directory? This has been a problem before and i had to change pip to install by default inside the houdini python directory. Before that i would copy the packages from the default directory in C:/Python27 to the Houdini one. Is this really that complicated or am i doing something wrong? ideally i would like to have one place to store packages outside Houdini - the default directory that gets created when installing python on your computer. Just install python 3, pip install anything i need and have houdini use those.
  15. Hi all, I'm trying to remap the hotkey SPACE + G (Center the view on all selected objects/geometry) to a thumb mouse button. I'm not the greatest at Python but I think I'm close to finding the relevant functions. This is what I got: import stateutils scene_viewer = stateutils.find_scene_viewer() cur_view = hou.ui.paneTabUnderCursor().curViewport() cur_view.frameSelected() I have no idea if this will work, because I have no clue how to run this code in Houdini. I think I read that I need to create a tool first, and then call that tool from the UI. I have no idea how to do that though. Is there a chance someone could help me out here? I have this function mapped the same way in all 3D apps I use, and it would be really nice in Houdini as well.
  16. Blue Text Under Node

    Hey friends quick question for you. I've searched far and wide without any success - I'm trying to add the blue text under a sop, like the mantra node has: How on earth does one go about this? It's driving me up a wall over here. Thanks fellas, mavencolby
  17. Hey, bit of a specific use case here, but has anyone successfully used the .asCode() Python function with the SOP solver? I can't seem to get it to save and recreate the nodes inside of the sop level solver node. I spent some time researching it but haven't found anyone even mentioning this problem. Everything else seems to work fine with the function even the DOP level SOP solver. It's just the SOP level solver that has this issue. I'm kind of at my wit's end trying to figure this out. I might be missing something super simple or obvious here, but I'm hoping someone else has encountered this and figured out what is happening. I suppose it could also be a bug, I haven't taken the time to dig through all the change logs on the SideFX website. I'm currently encountering this in Houdini 18.0.348 (which has known issues with the .asCode() function) as well 18.0.597 (where those issues have supposedly been resolved). If anyone has any insight I'd really appreciate a nudge in the right direction. Cheers, Brandon
  18. Hi, I have an asset which operates quite wrongly in some way. The problem is when the asset is selected it adds a 'hou.Parm.set' to the Houdini undo history. So it makes the undo process dirty. How could it be tracked back which parameter is changed that time ? I thought a wrong menu script set but i could not track where it happens. And the worst case is when I open the asset's Property page floating and a not floating one is shown on the Houdini desktop too , it adds the 'hou.Parm.set' continously to scene. So the mem runs out. Any Idea ? THX!
  19. version 18.0.287, 18.5.462 I am trying this manually (right click on parameter name >> lock parameter) and using python hou.geometry.SetHardLocked(True) but nothing is working on this. In addition, it will crash if I try to change that parameter after lock. Any other choices or reason why this doesn't work?
  20. i want to call a method when OTL's parameters are updated . that is easily done with the callback script . this works ... hou.node('.').hdaModule().blah() but i want the same method to be called when there is an event. in my case when the (input) connection is changed. the problem is the even doesnt recognize hou.node('.').. after a trying a few different things... kwargs seem to work. but now the method now needs to take in the kwarg arguments to work .. dummy.hdanc scene.hipnc here is a test scene & hda for reference ... can this be done cleaner / better ?
  21. Hey again, Got a problem that I'm not sure how to tackle. Here is the current setup: Points within Houdini are being transformed into position using an xml. There are 2 python nodes that accomplish the above to give the points unique info about what they represent with an x,y,z cord and rotation x,y,z. I've made some edits to a few of the points, too many for me to update the xml manually, and I'd like to update the xml with the new x,y,z cord and rotation x,y,z. I believe I can modify the xml with python, but I'm unsure on how I would be able to grab the moved point data from Houdini. Any ideas on how to bridge the gap between Houdini and the xml?
  22. I am curious if it is possible to clock how long it takes to cook a surface operator and interrupt if it goes above a certain limit, preferably within a python SOP? Backstory; there are cases when a polyexpand2D node takes excessively long time to cook. I've contacted SideFX for this unexpected behavior. Long story short, this is what they recommended: And it does, when you translate the input geometry of the ‘polyexpand2d’ SOP the results do vary. So now I am trying to figure out a way to clock a particular section of the network tree, and if it takes longer than X amount of time, I want to translate the input ever so slightly. Hopefully this will help it so it doesn't take +1 hour to cook (average is somewhere between 1-5 seconds). I have been looking into hou.perfMon but that didn't really lead me anywhere. Let me know if anyone has any suggestions. Pseudo Code: import time trans_node = hou.node("../translate1") cook_node = hou.node("../COOK_THIS") start = time.time() time_limit = 5.0 rot= 0.0 while current_time < time_limit: try: cook_node.cook() except Timeout: rot= random(0.0, 360.0) trans_node.parm("rx").set(rot) cook_node.cook() continue Thank you!
  23. 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/"
  24. Align Tool for Houdini

    Now you can align multiple objects with Aligner like in 3ds max. Just select object or objects, press button and select the target. https://gumroad.com/l/Aligner Installation: 1. Create new shelf 2. Add new shelf tool 3. Copy and paste script from aligner.py 4. Edit ui_file path to the file aligner_gui.ui P.S. Asign the tool on Shift+A hotkey. Enjoy!
  25. Python Genetic Grid in Houdini

    Hello Guys, Is there someone who understand python in houdini? Because i don't I wanna trying remake this > Video I read one interview where Albert Omoss talking he rebuild this code from Processing to Python in Houdini, but i dont find any tips how to make it or how i can rebuilt GeneticGrid.mp4