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


Forums

  • 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 410 results

  1. 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!
  2. I am trying to render 2 hda simultaneously and I decide to using python threading it works on the houduni's python shell but it don't work on hyton. What is the problem here? How can I solve this? PythonShell hyton Code import hou import time import threading def nodeRender(nodeName,path,fileName,nodeCnt): start_node_time = time.time() node = hou.node("/obj") sp_name = "{}{}".format(nodeName, nodeCnt) file_save_name = "{}{}.png".format(fileName, nodeCnt) node.createNode(nodeName, sp_name) nodepic = hou.node("/obj/{}".format(sp_name)) nodepic.parm("output").set("{}/{}".format(path, file_save_name)) nodepic.parm("render").pressButton() nodepic.destroy() ex_time = '{:.2f}'.format((time.time() - start_node_time)) print("--- %s seconds ---" % ex_time) def renderThread(): start_time = time.time() t1 = threading.Thread(target = nodeRender, args=["Masa", "C:/Users/emnrdl/Desktop/New Folder (13)", "MasaTest" , "1"]) t2 = threading.Thread(target = nodeRender, args=["Masa", "C:/Users/emnrdl/Desktop/New Folder (13)", "MasaTest" , "2"]) t1.start() t2.start() t1.join() t2.join() total_ex_time = '{:.2f}'.format((time.time() - start_time)) print("--- Total execution time: %s seconds ---" % total_ex_time)
  3. Hi All, I am creating a flipbook using below python code and calling those image seq. in nuke but while importing it's colorspace is set to paintspace if I change this to sRGB then things look fine but the issue is I don't have any controls on NUKE function as it's implemented in database and works simply if i pass a image seq in it. Is there any other way I can fix issue while exporting from houdini itself. There are 2 things I came to know about it but don't know this are the actual cause of issue. Houdini Menu > Edit > ColorSetting > Colorcorrection MPlay > Colorcorrection Bar If above are the solution to fix this issue then what exactly has to be done in python way ? If above are not the solution then how to fix this issue ? flip_book_seq_path = '/u/{}/Desktop/flip.$F4.exr'.format(USER) cur_desktop = hou.ui.curDesktop() scene = cur_desktop.paneTabOfType(hou.paneTabType.SceneViewer) flip_book_options = scene.flipbookSettings().stash() flip_book_options.output(flip_book_seq_path) start_f = 1001 end_f = 1002 flip_book_options.frameRange((start_f, end_f)) flip_book_options.outputZoom(100) flip_book_options.useResolution(1) x = 1980 y = 1020 flip_book_options.resolution((x, y)) flip_book_options.cropOutMaskOverlay(1) scene.flipbook(scene.curViewport(), flip_book_options)
  4. Python Viewport NDC Transform

    Hey, I am currently building an HDA with python viewer states and I want to display an image/grid in the upper left corner of the viewport. This is what I currently use to move the grid to the current viewport postion. viewport = hou.ui.curDesktop().paneTabOfType(hou.paneTabType.SceneViewer).curViewport() cam = viewport.viewTransform() hou.parmTuple('/obj/geo1/transform1/t').set(cam.extractTranslates()) hou.parmTuple('/obj/geo1/transform1/r').set(cam.extractRotates()) I also transform the grid in the negative z direction afterwards. This results in the image beeing in the center of the viewport. But I'm not sure how I can move the image to the corner of the viewport and keep it in the correct postion when the viewport is beeing resized. Maybe with the viewport.viewportToNDCTransform() or viewport.mapToWorld() methods. But I couldnt figure out how. I found a promising vex based result here:https://youtu.be/7UuVhbTRcew?t=1890 string cam = chs("camera"); vector bb = relbbox(0,@P); vector4 crop = chp("crop"); bb.x = fit(bb.x, 0, 1, crop.x, crop.y); bb.y = fit(bb.y, 0, 1, crop.z, crop.w); bb.z = chf("zoffset"); @P = fromNDC(cam,bb); But this one requires a camera node and I'd rather have this logic in the python states if possible. Thanks
  5. Hi all, I have a hard time understanding how to programmatically add values to a multiparm folder. I want to add new items to a multiparm I added on my HDA. I can see all sorts of code for multiparm template groups and how to construct and add them to a node, but hardly any code that actually adds data to the multiparm. Any pointers are greatly appreciated! Thanks, -Johan
  6. Hello, I got two specific questions in simulation right now, as they were described in title. First, I want to use python node to program a few lines of statement that could add color points on the ramp of my color nodes, since I need to add 200 points in order to give my geometry layers of different colors. (I only know the syntax of how to set node's attribute values with Python, but I did not find out the syntax that can tell the node automatically add points) Also, as my first screenshot shows, I want to know how to set values to color vector, since color parameter's name is “rampcr#rampgr#rampbr#”, I don't know how to syntax that with values and expressions. The second question is about generating a bounding box in order to delete exactly half of my volume, but I want the effect operated in the end of my network, because I want the color be set well(i.e. color changes from shell to shell of my spherical volume), and then cut it half, make the cross section of my spherical volume be seen, so that the rings of different colors could be seen more obviously~ I used a delete node as the second screenshot shows, but it did not work, it seems all my volume was disappeared, the whole volume was ghosted in the scene so that you can see what I constructed. I don't know if I set something wrong or I should use another node to achieve my final effect? It is ok if you can only solve one of my questions, I would be grateful. Thanks a lot in advance!
  7. Hey guys! Once again, I have to seek out your precious help ^.^ I am currently creating my own asset browser and I am working on feeding assets from Houdini into the library. So far, everything was going pretty smoothly up until I got stuck with something that seems so simple: the frameSelected() function of the hou.GeometryViewport class. When I use the Python shell inside Houdini and do this, it is working correctly: import toolutils viewer = toolutils.sceneViewer() view = viewer.curViewport() node = hou.node('/obj/geo1/DZK_Asset_Export') node.setCurrent(True,True) view.frameSelected() My section in the HDA is not. Broken down to the essential part (with hard coded selection of node as above for the sake of the example): import toolutils viewer = toolutils.sceneViewer() view = viewer.curViewport() [...] cam = obj_level.createNode('cam', 'asset_cam') node = hou.node('/obj/geo1/DZK_Asset_Export') node.setCurrent(True,True) view.frameSelected() view.saveViewToCamera(cam) view.setCamera(cam) All the other functions work as expected (lockCameraToView, saveViewToCamera, setCamera all work fine). I only have trouble with frameSelected(), even when adding the code from the shell to my script, basically hard coding selecting the correct node. After running my export process which does not frame the view, I can go to the shell and call frameSelected() and from there it works again :/ I also have sections where I first set the camera, lock the view, then try framing but it is the same result: all working, except the framing. I wonder what I am doing wrong in my code and hope you can help me out. Any pointers, comments are greatly appreciated!
  8. Heyya, I'm currently developing our project-internal filecache node with a couple of fancy features for usability / productivity. The current workflow is starting a seperate Houdini instance with Juraj Tomori's Tool here: Background Render Now I also wrote a couple of scripts that update the progress of the currently ongoing cache by analyzing the output directory and showing the progress. (as well as some info on the output like time per frame and size). [This was primarily developed for the use within a TOPs-Render network, however, the background process variant turned out to be much superior for a variety of reasons.] Now what I built was a script in a seperate TOP-Network which is supposed to execute this analysis every couple of seconds for a given amount of time using the time.sleep(t) function. Now usually this does exactly what I want, keeping this process/sleeping in the BG and execute the analysis function while Houdini stays functional. However, the problem is that sometimes (quite unpredictably, but mostly when aborting/refreshing this TOP-network) this sleeping switches to the foreground, causing Houdini to freeze for however long the ticker was set. And this is game-breaking when you sometimes have to wait for five minutes. You get the point. Here is the (admittedly clumsy) bulk of code: import time import hou import os PARENT = hou.node("../../..") ticker_s = PARENT.parmTuple("ticker_s").eval() break_at_end = 0 node = hou.node("../../../mnp_cacher") fstart = node.parm("f1").eval() fend = node.parm("f2").eval() totalframes = int(fend - fstart) dir = PARENT.parm("outputfile").eval() dir = os.path.dirname(dir) def outputchecker(dur=20, tick=1, confirm=1): iterations = dur / tick warning_message = "Starting updateticker for {} seconds.".format(dur) if hou.ui.displayConfirmation( warning_message ): i=0 while i < iterations: i += 1 #print "Iteration: " + str(i) #SCAN OUTDIR LOCAL CODE ---------------------------- counter = 0; duration_list = [0] folder_size = 0 for (path, dirs, files) in os.walk(dir): for file in files: if ".hip" in file: #exception for backup #print str(counter) + ": SKIPPING" continue filename = os.path.join(path, file) folder_size += os.path.getsize(filename) # --- GET FOLDER SIZE mytime = os.path.getmtime(filename) # --- GET CACHE TIME counter += 1 if counter==1: counter #print str(counter) + ": EXCEPT" else: prevtime = os.path.getmtime(filename_prev) myduration = mytime - prevtime #print str(counter) + " - " + str(mydur) if myduration > 0: duration_list.append(myduration) filename_prev = filename #------------------------------------------------------------- scan end frame = fstart + (counter-1) allframes = fend-fstart curframes = frame-fstart progress = curframes/allframes percent = "{:.0%}".format(progress) # ----- SCAN OUTDIR AND UPDATE COMMENT scan = PARENT.hdaModule().scan_outdir(dir, 1) #print message running_message = "" running_message = "CACHING: {} (Fr.: {} / {})\n".format(percent, int(frame), int(fend)) running_message += scan running_message += " [Update Ticker: {} / {}]\n".format(i, iterations) PARENT.setComment(running_message) time.sleep(tick) outputchecker(ticker_s[0], ticker_s[1]) This looks something like this if executed properly, and I've fallen in love with the info I get from this: Now what I don't get is why this sleeping switches to the FG-process of Houdini. The python-script-TOP is set to evaluate In-Process, but when executing cleanly, it works in the BG nicely. I'm grateful for any clue or alternative approach. Thanks, Martin
  9. In order to write code in SOP python node, do I need to have a python software in my local computer? Because I tried to write some code in python node to import my data files, it seemed not working. What I have coded is attached. Thanks!!
  10. Get polygon and normals in Python

    Hey all- I have a simulation running that is controlling the position and orientation of a grid that comprises just a single square polygon. Trying to use python to output the normal and center point of that grid. I can access the first hou.Prim, but I can't figure out how to get the polygon to get the normal. How do I do that? Thanks! Dave
  11. Un-hide Nodes

    Hey guys! Sharing a simple tool to reveal hidden/deprecated houdini nodes, incase you need them or just miss them. It's free, hope you find it useful. cheers! Use with caution, some nodes might make your scene unstable! https://gitlab.com/kishenpj/unhide_nodes
  12. Hi folks, i have a Python Processor with 5 work items and i would like to create a dependencies based on a attribute WorkItemID that increase for each work item. How can i create dependency to cook those work items exactly in the order that i want and not in parallel ? Thanks in advance
  13. Hey guys (and gals)! I'm working on a small project to simulate max style auto backups for Houdini wrapped up in an HDA. For this HDA I have a few functions in the python module that need to be able to read the values of the parameters of the HDA, like a string field where the user can say where to place the auto backups, determine the auto save intervals etc. However I am having some issues reading the parm values. So far I've been trying the normal method of first getting a referance to the node itself and then running: node = hou.node('.') node.parm('parmname').eval() However this is proving to be very unreliable, whenever I save and match definition the hda this approach no longer seems to work and I immediately get errors indicating that the first line trying to get a reference to the node returns none/NoneType. I have even tried to define it with a full path to the node like such: node = hou.node('/obj/autosaver1') But it still seems to encounter the same issue. I have seen some mentions of other methods but I am not really sure I fully get how they work. Any advice on the best and most reliable approach to getting the values from the different parameters of an HDA from within the python module? Thanks for the read! Stay safe out there!
  14. Python - Select Folder?

    Hi! I'm writing a shelf tool that allows users on Linux to search a directory and its sub-directories for a certain file-type / keyword. To do this I've used a readMultiInput like below - start_popup = hou.ui.readMultiInput(start_message, ("Path to Search", "File to Look For"), initial_contents=(home_dir, ".exr"), title="File Finder", buttons=('OK', 'Cancel'), default_choice=0, close_choice=1) In this version of the script, users need to manually type in / paste the directory they want to search, but I'd like for there to be a pop-up dialog allowing users to select a folder, the same way hou.ui.selectFile() allows you to select a file. Is there a way to do this?
  15. hotkey combined with ctrl

    hi - while writing a python script i run into a problem: with kwargs['shiftclick'] I can recognize if a shelf tool was activated by clicking in combination with the ctrl key - so by clicking on it in the shelf tool but is there a way to recognize if the script was activated by ctrl and its HOTKEY? thank you for any information about that!
  16. Hi guys, I'm currently experimenting with packages for setting up Houdini's environment variables. Is there a way to update the HOUDINI_PACKAGE_DIR while Houdini is already open or do the packages only get scanned during startup? It looks like the packages don't get processed if I just change the HOUDINI_PACKAGE_DIR from inside Houdini via hou.putenv() or hou.hscript('setenv …'). What I'm practically trying to do: I'd like to switch project specific packages with the corresponding env variables being updated when the user opens a file that's located in another project. I also actually don't want to relaunch Houdini. I guess another more basic way would be to just set all the variables being inside the package manually in the 456.py?! Thanks for your help! Michael
  17. Hi everyone, I'm very new to hscript and python, I just started learning it very recently. I'm trying to add a Pre-Render Script in a rop geometry output in Python. I could do it with hscript with: opparm -C /obj/geo1/ray1 method project I'm trying to find a command that would do the same thing with opparm -C in Python. So far, i only found .pressButton(), which isn't exactly what I need. Please help and thank you very much in advance. Phiphat
  18. Hi folks, I am actually coding some basic operators like divergence, gradient in vex and python to demistify them and wanted to share the file with you. Feel free to update or correct the file since i might not be sure of some operators. it contains : - Divergence (voxel and points) - Gradient (voxel and points) - Curl (voxel) : the curl seems to not have the same order as vdb curl so still in wip - Laplacian (voxel) : The computed laplacian is somehow less precise than vdb laplacian - Covariance matrix and eigen vectors (points) : It works but the scale is normalize - Laplacian matrix of a mesh (python) - Bernstein polynomials basic_operators_001.hiplc
  19. Python 3

    Is there any way to use python 3 in Houdini. I tried to use different packages in Houdini, for example, the discord API. All my python scrips work fine on their own. But if I try to use them in Houdini, I get a lot of errors. I assume it happens because of oft pyhon2.7. But I'm not 100% sure cause I'm quite new to python in Houdini. Hope anybody can give me some advice
  20. Hi, Is it possible to set up the normals of these points procedurally using vex or python? I just set point attribute to every point with vex, but could I make it more procedural if I had more or less points, for example?
  21. Hi people, I had some code which I was running to find the rendered image in the "Render View" pane and save it to file. _desktop = hou.ui.curDesktop() _ipr = _desktop.paneTabOfType(hou.paneTabType.IPRViewer) _ipr.saveFrame(_file) This was running fine in Houdini 17. However, since updating to Houdini 18 (I'm using 18.0.440), the desktop object seems like it can't find the IPR pane, the paneTabOfType method is returning None. Anyone have any ideas what I can do to get this working? Thanks, Henry
  22. Hi all; I seem to be having a strange issue where I create a button on a null that is suppose to be a control system for a paint node; however, the button does not select the paint node. I have tried to use callback scripts by using a function like hou.cd("../path to the node") however I'm not getting any results and the button is not activating I'm not sure what is happening?. I appreciate all help anyone has to offer & I'm going to link the file that is isolating the issue underneath if anyone would like to take a look at it thanks. Kind Regards Rusty.M A simplified HIP file version of the same issue: cd_Button.hipnc
  23. Hi. I want to select all the parent nodes of the selected node. For example, if you select null3 and click the Python shelf, the parent node null2 is selected, and if you press the Python shelf again, the parent node above it is selected, and all the parent nodes are selected. Please refer to the image. Please check my script. Thank you. node = hou.selectedNodes()[0] b= node.inputs()[0] b.setSelected(True)
  24. Hi. Is there any python code to move the node with the arrow keys? Or have you seen it? I am wordering if i can move the node with the arrow keys. Please share any way you know. Thank you.
  25. Hi, Can a viewport (presp) transformation be stored and later restored back again. I was searching for the memory toolbars in python but I could not find. Thanks G
×