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 549 results

  1. Hey Everyone has anyone used hou.hotkeys ? I've made a tool and would like to have a shortcut assigned to it when its loaded. I can create a shelf and add tools to it through python with the hou.shelves library. But assigning a shortcut to the tool is . I tried to understand how the shortcut was assigned to the tool by doing it manually. For example Ctrl + Alt + Shift + T to the tool called My Custom Tool Then I was curious to find what the hotkey symbol the tool was using hou.hotkeys.hotkeySymbol. The examples of the documentation show a strict dot notation but running this command will return something along these lines with a colon ? >>> hou.hotkeys.hotkeySymbol("Houdini/My Custom Tool") h.tools:my_custom_tool Regardless, with that info, trying to assign this through python seemed to work. The edit tool window will register and show the assignment, as well as the HotKey Manager. However pressing the shortcut doesn't work and doesn't trigger the tool code hou.hotkeys.addCommand("h.tool:my_custom_tool","My Custom Tool", "This is a custom tool") hou.hotkeys.addAssignment("h.tool:my_custom_tool","Alt+Ctrl+Shift+T") Weird behaviour is deleting the shortcut in the Hotkey manager and reassigning it doesn't work either. I need to manually run hou.hotkeys.removeHotkeySymbol("h.tool:my_custom_tool") for it to work again when setting it through the Hotkey Editor manually. It seems the hou.hotkeys.addCommand is missing something ? its not linking to the command to the tool correctly to the shortcut even though visually in the Hotkey editor and the edit tool window hotkeys tab shows properly. Did anyone face this issue ? Is this how we assign hotkeys to a tool through python ?
  2. Launch gplay using on linux

    I'm not able to launch gplay from python script with QtCore.QProcess() agent = QtCore.QProcess() agent.start("gplay", [name]) initial Qt widget is working fine but when i try to load the selected geometry file in gplay nothing happens. I'm not sure what went wrong. note:I'm working on a linux machine and using python 2.7. Thanks in advance.
  3. Set quickmarks via python

    Hey everyone! Like the title suggests I am trying to find a way to set quickmarks in Houdini via python (or if it is considerably easier to do via hscript I am totally open to doing it there as well). So far I've come across the "nodegraphview" module with it's "Quickmark", "createQuickMark" and "setQuickMark" functions but that's about as far as I have gotten. The documentation I've been able to find here is a little bit too sparse for my skill level. Mostly I am unsure of/confused about what the function wants as its inputs, as it is only listed by variable names with no further description. What does 'net' mean? Or 'bounds', or 'items'? This is what I have tried so far just to test and see what error messages I got which I hoped could lead me towards what to google for (Yeah the empty string are there just because I have no idea what to put there): import nodegraphview as view net = hou.ui.currentPaneTabs()[0] qmark = view.QuickMark(net, '', '', hou.node('/obj')) view.setQuickMark(8, qmark) And this is the error I got: AttributeError: 'NetworkEditor' object has no attribute 'isSelected' Has anyone out there done this before and could give me some tips or know of any more in depth documentations about how to use this module and these functions? Thank you so much for your time!
  4. Python Performance Issues

    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?
  5. I have an HDA with a parameter that allows users to return a selection from the viewport (same type of parameter used on blast nodes etc.). I have a callback script that I want to run whenever the artist makes a selection, however, the script only seems to execute when the string portion of the parameter is edited. For example if I manually type the name of an object into the parameter the callback script executes as expected, but if I use the arrow button to select the objects in the viewport and hit enter to confirm my selection the callback script is not executed. This obviously isn't very useful or intuitive for artists. Does anyone have any workarounds or suggestions on how to get this functioning the way one would expect it to?
  6. PDG index sorting

    Hello; I'm just getting into PDG and have an interesting problem I'm trying to solve. I have a list of files that I'm trying to sort using PDG. The files are labelled x0y0,x0y1,x0y2.....x7y7. When I load them with the "filepattern" TOP, it sorts them as x0y0, x0y1, x0y2, x0y3 etc. Instead, I would like to re-sort them as x0y0,x1y0,x2y0,x3y0,x4y0 ..... x0y1,x1y1,x2y1,x3y1,x4y1 etc. What would be the best approach for this? Any python algorithm that may be suitable for this that can be executed in TOPS? Maybe a feedback loop?
  7. Return Item name of ordered Menu

    Hi, I have been struggling with this for the past 2 days. I need help in returning the name of the selected item in an ordered menu. What I am trying to achieve is to dynamically populate the ordered menu with the list of projects via menu scrip (python) import os path="k:/Projects/" dirList = os.listdir(path) dirs = [] for dirName in dirList: fullPath = os.path.normpath(os.path.join(path, dirName)) if os.path.isdir(fullPath): #dirs += [fullPath, dirName] dirs += [dirName, dirName] return dirs This code scans for folders in directory(k:/Projects/) and lists them in the menu. All works fine till here. Now I need to return the name value of the selected menu item from another parameter. So I have tried this listItemName = hou.pwd().parm("parmList_Projects").eval() and this listItemName = hou.pwd().parm("parmList_Projects").evalAsString() but it returns only integer values from (0,1,2,...) How can I get the name or label value ?
  8. Hi all, Is there a way I can use a shelf tool python script to select a joint in the rig tree window pane when I have a rig pose SOP selected?
  9. So it seems the only way to procedurally expand all the variants is using the explore variants LOP. The problem I get when using this is that the file I am exploring variants on which Is brought in using a reference LOP gets an error of not having a save path and it defaults to creating a new usd file for the layer instead of reading the one from the reference LOP. I tried to look inside the network and noticed the reference lop there is what was causing the problems, but it was too complicated for me to fix. I tried just bypassing the reference LOP inside the network which worked but then I get the default prim name "/__variants" set in the python script and I was not able to make any changes to the primName variable without getting invalid null prim error. Please help! Edit: I realize after messing around a bit more that the reference LOP causes the separate USD file to be written out whereas other methods like extracting the variants manually or using a stage manager use write out the same data but inside the final usd layer from the usd rop. So basically I am just wondering how to procedurally get all variant prims to use for point instancing since the explore variants method that is often shown does not appear ideal.
  10. Hi, I have found how to set the template flag ( setGenericFlag( hou.nodeFlag.Termplate ) but how the shaded template could be set ( click on the flag with CTRL ) ? I see all the flags but I could not figure out what that is .. Thx, G
  11. Hi, I have found how to set the template flag ( setGenericFlag( hou.nodeFlag.Termplate ) but how the shaded template could be set ( click on the flag with CTRL ) ? I see all the flags but I could not figure out what that is .. Thx, G
  12. Hi There, I'm trying to grab all attributes on the current work item in TOP and assign them to points in SOP. I wrote a python script and it works fine in SOP lively but I'm getting an error or crush when I kick off ROP Geometry Output TOP. I used python approach because I have several attributes to transfer and the attributes can be changed in the future so I'd like to avoid using @xxxx with hardcoded attribute names in SOP. It would be great to have some suggestions. Thanks you ~
  13. Hello, When I copy and run the following code in a python sop node, editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor) image = hou.NetworkImage() image.setPath('$HFS/houdini/pic/Mandril.pic') image.setRect(hou.BoundingRect(0, 0, 5, 5)) editor.setBackgroundImages([image]) (which can be found here in the sideFX documentation: https://www.sidefx.com/docs/houdini/hom/hou/NetworkImage.html ) it does indeed create the background image in the network editor. However, should you change context and then go back to the sop context where you created the background image (example: /obj/geo/python >>> /out >>> /obj/geo/python), it will have disappeared. This doesn't happen when creating the background image through the network editor's dedicated button, but I need to be able to do it with python, because I'm setting up a shelf tool template that would need to do this. Any idea why the image is disappearing with the python script? Thanks Attached is a simple scene with the python node set up. Just activate the python node, see the background image pop in place, change context, go back, and see that the background image has disappeared. background_image.hip
  14. Object Selection Button

    Hi all! I had a bit of a question re scripting selections. Ive been using the excellent soputils.selectGroupParm() in a few of my tools but Ive recently needed the ability to select objects in a similar way. Ive done some looking into it and there doesn't seem to be a simple way to get an object selection state in a viewport after clicking an action button. Does anyone know how one would go about implementing like this or is it going to be a case of learning how the python state system works (I wouldnt know where to start with it right now). The image demonstrates what Im trying to achieve. You click the little arrow and the viewer enters an object/geo selection mode (similar to selectGroupParm) and on completion it returns a list of object node paths. Thanks!
  15. root = hou.node("/obj/") netbox = root.findNetworkBox("Mynetworkbox") nodes = netbox.nodes() print(nodes) i am trying to get all nodes inside a specific network box but print(netbox) returns None
  16. Multiparm Editing in Python

    I am working to build a tool which contextualizes updates options in a multiparm block based on an option selected in the block itself. I have been able to get ahold of the information for which index in the multiparm everything is going and have been able to extract information just fine, but I cannot seem to update the UI. I really feel like I am just missing a function somewhere in the documentation. Right now I'm essentially doing this to update what I have now: def load(): node = hou.pwd() ptg = node.parmTemplateGroup() baseAttribs = ["list", "pulled", "in", "from", "elsewhere"] multiparm = hou.FolderParmTemplate("attrib", "Attrib Item", folder_type = hou.folderType.MultiparmBlock) collapsibleFolder = hou.FolderParmTemplate("settings#", "Settings", folder_type = hou.folderType.Collapsible) attribList = hou.MenuParmTemplate("root_attribs#", "Select Attribute", tuple(baseAttribs), menu_labels=tuple(baseAttribs), script_callback="hou.phm().attribType(kwargs)", script_callback_language=hou.scriptLanguage.Python, menu_use_token=True) collapsibleFolder.addParmTemplate(attribList) multiparm.addParmTemplate(collapsibleFolder) multiparm.setDefaultValue(1) ptg.appendToFolder(ptg.findFolder("JSON Settings"), multiparm) node.setParmTemplateGroup(ptg) def attribType(kwargs): node = hou.pwd() p = kwargs["parm"] parent = p.parentMultiParm() multiParmIndex = int(kwargs['script_multiparm_index']) menuIndex = int(kwargs['script_value']) container = parent.parmTemplate().parmTemplates()[0] selected = p.menuItems()[menuIndex] a = hou.LabelParmTemplate("test#", f"Testing that this works {multiParmIndex} {selected}") container.addParmTemplate(a) I know what the name should be and I have the correct multiparm index from within kwargs, which is amazing. So how can I put things into the collapsible folders? For the first entry I know I have the settings1 folder and I want to add in that label, but I cannot seem to figure out how to do that.
  17. Houdini Buttons to Radial Menu

    Hi there, I`m looking for a way to add the "jump back" and "jump forward" (Alt+Arrow) functionality to the network editors radial menu. After having found the nodegraphview module in the python2.7-folder I`m still have no clue on how to use it in the desired way. In general: Is there a way to get to the scripts the default UI buttons are using? Any help is much appreciated, many thanks in advance. Cheers, Hannes.
  18. 3d subdivide Packed?(SOLVED)

    Problem ..some Pictures tutorial from Asia ..error ..its Like Spanish village for me .. need Help. Packed3d.hiplc
  19. Hey everyone, I want to share my HDA. By that tool you can easily create hard surface objects, such as building, spacecraft and other constructions. by it you can generate, delete cut and unite blocks. It's free and I would love if you could use this tool: https://vimeo.com/679178527
  20. I am learning python in Houdini, can anyone help with the reason for this error. I want to set multiple keyframes for the 'tz' parm of a geo in houdini >>> zBox = box.parm('tz') >>> zBox.keyframes() () >>> keys = zbox.keyframes() Traceback (most recent call last): File "<console>", line 1, in <module> NameError: name 'zbox' is not defined >>> keys = zBox.keyframes() >>> for key in keys: ... key.setFrame(key.frame()+1) ... key.setValue(key.frame()+2) ... zBox.setKeyframes(keys) File "<console>", line 4 zBox.setKeyframes(keys) ^ SyntaxError: invalid syntax >>>
  21. I started off creating shelf tools, worked fine then I wanted to read modules on disk so i used the PYTHONPATH variable which worked great. However the second I go to run functions from my module I get the error 'module has no attribute' as shown below. import mymodule mymodule.my_function() it returns the error: module 'mymodule 'has no attribute 'myfunction'. My workaround right now is just symlinking my .py file into the /python3.7libs directory which reads fine for the moment.
  22. Hi, Is there a way to cancel picking of the selectGeometry process ( sceneViewer ) by script ? THX! G
  23. I have a tuple that I'm looping over like this: 'for name in tuple:'. Inside the loop I say something like createNode('group', name) but I get the error "invalid node name". Please help I am not sure why this is as it returns a string properly elsewhere! I also tried the .setName but got the same result.
  24. Hello I am new to Python. I have been avoiding it for sometime. I have an object which is split into 100 tiles via connectivity and a class attribute which I would like to export into Unreal engine but as 100 separate static meshes. Therefore I would like to split the geometry into 100 different Geometry nodes in a subnetwork, appropriately named. How would I go about achieving this using Python? Thanks in advance
  25. Hey Guys, I'm trying to update attributes with a python sop and seeing downstream results live. I'm using the executeInMainThreadWithResult() function that comes with hdefereval.py and I am able to print the values live in the python shell / console while maintaining an interactive viewport during runtime, but the attributes don't update until the script finished. Im running this code (HIP is also attached): node = hou.pwd() geo = node.geometry() import hou import hdefereval import threading import time points = geo.points() def houdini_command(): for i,point in enumerate(points): point.setAttribValue("move", float(n)) print("running") def updateUI(): hou.ui.triggerUpdate() def worker(): global n n = 0 while n < 5: hdefereval.executeInMainThreadWithResult(houdini_command) hdefereval.executeInMainThreadWithResult(updateUI) time.sleep(.5) print(n) n += 1 thread = threading.Thread(target=worker) thread.daemon = True thread.start() Is there a way to hack this together to be able to view the changes of each loop live without having to wait until the full script is processed? I also tried writing the attributes to a different node & piece of geometry but that didn't work because python sop only gets read access to geometry owned by other respective node. Any pointers would be much appreciated! Thanks in advance Best, j execInMain.hiplc