text: Search the Community
  Showing results for tags 'Python'.
  Found 380 resultsil.,.
  Drag and drop QtWidget data to a parameter
  younglegend posted a topic in ScriptingAs the title suggests, how do you drag and drop Qt data on to a parameter? I was able to use this example as reference. But in my case the i couldn't make the drop event register. The code i have now kinda works, but the dropped text is wierd. What's the right way to do this....could use some help! I'm attaching an example code. from PySide2.QtWidgets import * from PySide2.QtCore import * from PySide2.QtGui import * import hou class TreeWidget(QTreeView): def __init__(self): super(TreeWidget, self).__init__() self.setDragEnabled(True) # def dragEnterEvent(self, event): # print "dragEnterEvent" # event.acceptProposedAction() def mouseMoveEvent(self, event): print "MoveEvent" mimeData = QMimeData() data = (self.selectedIndexes()[0]).data() mimeData.setText(data) drag = QDrag(self) drag.setMimeData(mimeData) drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) # def dropEvent(self, event): # print "dropEvent" # mime_data = event.mimeData() class Example(QWidget): def __init__(self): super(Example, self).__init__() self.build_ui() def build_ui(self): self.setGeometry(300, 300, 150, 250) self.setParent(hou.qt.mainWindow(), Qt.Window) mainlayout = QVBoxLayout() self.setLayout(mainlayout) self.tree_widget = TreeWidget() self.tree_widget.setRootIsDecorated(False) self.tree_widget.setHeaderHidden(True) model = QStandardItemModel() self.tree_widget.setModel(model) mainlayout.addWidget(self.tree_widget) for i in range(10): parent_item = QStandardItem('Example_{0} \nnew_line_{0} \n '.format(i)) model.appendRow(parent_item) def dragEnterEvent(self, event): event.acceptProposedAction() # def dropEvent(self, event): # print "dropEvent 2" # str = event.mimeData().text() # event.acceptProposedAction() ex = Example() ex.show()!
  Async Python message listening
  Spike posted a topic in ScriptingHi, i'm using an api whitch uses async and awake calls (i'm not that familiar with threading) - the problem is that these calls are stopping/blocking my whole houdini interface from working I'm connecting houdini with discord by import discord token = "xxxxxxxxxx" client = discord.Client() @client.event async def on_message(message): print(message.content) messages = await channel.history(limit=123).flatten() if message.content.find("hello") != -1: await message.channel.send("hi back") client.run(token) but this blocks my whole houdini application - the python script is running smoothly in the background (and works) Hope you can help me! - really desperate at the moment that this is not working if it i helps: discord api is using asyncio to work with threads
  Python - how to faster export points and prims?
  leota posted a topic in ScriptingHey there, I'm trying to export point locations and prims from e geometry. I wrote a very simple Python script which is looping through points and prims, but it's quite slow. It can take up to 10s for geometries with 8/10k polygons. Is there a faster way to do it? Maybe some python methods that are optimized, which I don't know. Here's my actual code: def getGeo(): return { "vertices": getPoints(), "faces": getPrims() } def getPoints(): pointsList = [] node = hou.node('obj/geo1/OUT') geo = node.geometry() pointsLen = len(geo.points()) p = 0 for point in geo.points(): for comp in range(0, 3): pointsList.append(point.position()[comp]) p = p + 1 return pointsList def getPrims(): primsList = [] node = hou.node('obj/geo1/OUT') geo = node.geometry() primsLen = len(geo.prims()) p = 0 for prim in geo.prims(): for v_index in range(0, 3): primsList.append(prim.vertex(v_index).point().number()) p = p + 1 return primsList as you can see, I call getGeo() to return an object which contains an array of vertices and an array of faces, but it's terribly slow. Any ideas???.
  opunhide all nodes using python
  younglegend posted a topic in ScriptingHow do you opunhide all nodes in a particular category or a bunch of specific nodes using python? I wish to add this in my startup script. a simple hou.hscriptExpression("opunhide Sop point") dosent seem to work. Nor does hou.hscript(). What am i doing wrong?
  Advanced UI Customization
  animatrix posted a topic in Education In this video I will go through the GUI customizations I did for Houdini 18. So let's get into it.
  Houdini Python hou.setPreferance (or if easier, hscript)
  underscoreus posted a topic in ScriptingHello all, I am looking for a way to set a specific preference in Houdini with python. The preference I am looking to set is named "Auto Save Method" in the UI. I've tried to use the hou.getPreferanceNames() to get a list of all the pref name variables I can set but this does not appear in there. I have had a dig through the preference files stored inside the Houdini folder and have found a parameter inside the hcommon.pref file that would seem to match the setting I am looking to change, however, if I were to edit this text file whilst Houdini is running, would that update the setting or would it require a restart of Houdini? And is it even a good idea to be editing these .pref files whilst Houdini is running? Here is a link to the help file for the parameter I am looking to change, sorry I don't have a picture: (Look for the heading "Auto Save Method", this is the setting I am looking to change) You'll have to forgive me if this is very basic stuff, I am kinda new to Python in Houdini and am trying to make tools to learn more. Thanks for the read!
  switch takes and render
  osmeldu posted a topic in ScriptingHello. Im trying to run inside houdini a python script to switch takes and render after every take. It works but it only render the last take: takes_list = hou.takes.takes() for take in takes_list: # if "Main" in take.name(): continue else: print("setting to take: {}".format(take)) hou.takes.setCurrentTake(take) print(hou.takes.currentTake()) rnode = hou.node("/out/Redshift_ROP_CHAR") rnode.render() what`s the problem here? thank you.
  Updating the viewport with python to see change in parameters
  paulkay1902 posted a topic in ScriptingHello guys, I'm new to Houdini and to writing python scripts for Houdini. I'm currently working on a project where I want to change the Rotation, Scale or Transformation of a geometry node by moving physical rotary encoders, which are connected to an Arduino Uno. The serial connection between Houdini and the Arduino works fine. In my script, which I save as a custom shelf tool, I change the parameters of the node by using the set() function of the Parm object. The amount of change comes from the encoders. For example: node.parm('tx').set(change) The problem for me is that while the script is running and I change, for example, the rotation of a cube, like node.parm('rx').set(25), the cube is not rotating in the viewport. The cube is only changing once the script has finished and stopped running. Basically, the viewport is only updated with the new, for example, rotation parameters once the script has finished running. The geometry node is not moving in the viewport while the script is running. My goal would have been to have the script running in the background while working on Houdini like usual, and when changing the rotation of a node via set(), the node is also rotating in the viewport. Therefore, my main question: Is there a way with the hou object to force the viewport to display all the currently new set parameters of a node (like Scale, Rotation and Transformation) while a python script from the shelf is running. Thank you for your help.
  Enable Lock View ( Viewport ) to Camera in Python/Hscript
  mikelafave posted a topic in Scripting Oct. 19, 2017 4:14 P.M. Is it not possible to enable the lock view to camera button via python/hscript? experimenting w/python on this in Apprentice 16.5.634 (_old_ PC) and running into issue(s) ... showed me several things which DO seem to work using the following syntax : import hou, toolutils myCam = hou.node('/obj/').createNode('cam', 'myCam') hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().setCamera(myCam) # hou.hscript('viewhome -s *.*.world.persp1') hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().homeAll() hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().saveViewToCamera(myCam) # ... HOWEVER, when I try something similar, I just get an Error on : >>> hou.ui.paneTabOfType(hou.paneTabType.SceneViewer).curViewport().lockCameraToView() Traceback (most recent call last): File "<console>", line 1, in <module> AttributeError: 'GeometryViewport' object has no attribute 'lockCameraToView' # ... and I have Not found any way to do this using hscript either. Anyone have advice on this?
  Python getting a node name vs getting an instance?
  Outlawed posted a topic in ScriptingOk, this is a simple question, but I've been out of python for so long, I've lost touch. I have a node called geo1. When I run the following script, i'd like the "Node to copy is" to give the same result of "Selected is" ( I think one is called 'getting an instance', and the other is just returning the node name). Noob question I know. if(hou.selectedNodes()): selected = hou.selectedNodes() nodeToCopy = hou.node('/obj/geo1') print "Selected is " + str(selected) print "Node to copy is " + str(nodeToCopy) Instead it returns: Selected is (<hou.ObjNode of type geo at /obj/geo1>,) Node to copy is geo1 How do I get the same return when giving an explicit node path?'))
  Scripted access to Bundle panel
  ftaswin posted a topic in General Houdini QuestionsHi All, Is there any way I can access bundle panel to find out what node is selected in the highlighted bundle? Using python, I assume? Thanks in advance for any directions F
  Context-Sensitive Rule-Based Hotkey System
  animatrix posted a topic in Education In this video I will show you some of the inner workings of the context-sensitive rule-based hotkey system that I implemented and one I have been using for a while to speed up my workflow inside Houdini. It's a very light-weight and flexible system that allows an arbitrary number of actions to be assigned to any key, with extensive modifier key and state support (Ctrl, Shift, Alt, Space, LMB, MMB, RMB, selection state). It's deeply integrated into the overlay network editor workflow.
  Modeler 1.0
  Alexey Vanzhula posted a topic in MarketplaceModel