jsmack No need for 3rd party packages, all you need is built in.
Attribute randomize in “custom discrete” distribution is what you want. Configure different weights for each token value to control object scattering. Use the foreach loop to assign copies based on the token values.
Hi, I'm not sure how to help you with the for-loop.
Regarding a vex a possible approach: for each point create an array attrib and populate it with neighbours points (up,left,right,down). Then in another wrangle (detail or numeric) you loop over each point (even randomly) to place the blocks. When a block is placed you flag the points occupied by it, so you skip them in the iteration, and also you remove those points from the arrays.
This is just out of my mind, I don't if I'm overlooking some important step.
If you name your multiparm block parm as “myparmName”, it will be automatically converted to myparmName1, myparmName2, as you add new instances… So you can access a specific a multiparm block instance parm by compositing the general parm name + the instance id.
stringinstanceName = "myparmName" + itoa(id); // itoa() converts int to stringfloatheight = ch("path/to/controlNode/" + instanceName);
one thing to rmb is that multiparm instances indices generally start from 1. So keep that in mind when you compose the name.
I'm very new to Python States so maybe I'm overlooking something trivial. I'm getting a strange error every time I launch a new blank session, it's seems that Houdini is trying to register a custom event handler from a digital asset (that is not even existent in the new session). Do you know what is the reason for this or how can I check what event handlers are registered?
Error running event handler: Traceback (most recent call last): File “opdef:/Sop/Brainstorm_preview::0.0.5?PythonModule”, line 9, in <module> File “C:/PROGRA~1/SIDEEF~1/HOUDIN~1.327/houdini/python2.7libs\toolutils.py”, line 1749, in createModuleFromSection node_type.definition().sections().contents()) File “C:/PROGRA~1/SIDEEF~1/HOUDIN~1.327/houdini/python2.7libs\toolutils.py”, line 1730, in _createModule eval(code, module_dict) File “pystate”, line 3, in <module> File “C:/PROGRA~1/SIDEEF~1/HOUDIN~1.327/houdini/python2.7libs\toolutils.py”, line 88, in sceneViewer primarypane = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer, index) File “C:/PROGRA~1/SIDEEF~1/HOUDIN~1.327/houdini/python2.7libs\hou.py”, line 57135, in paneTabOfType return _hou.ui_paneTabOfType(*args) NotAvailable: Not available in this context. The UI is not created yet
Error running event handler: Traceback (most recent call last): File “opdef:/Sop/Brainstorm_preview::0.0.5?OnInstall”, line 4, in <module> File “C:/PROGRA~1/SIDEEF~1/HOUDIN~1.327/houdini/python2.7libs\hou.py”, line 34998, in __getattr__ def __getattr__(*args): return _hou.HDAModule___getattr__(*args) AttributeError: ‘module’ object has no attribute ‘createViewerStateTemplate’
I need to know which object (and which primnum) is under the mouse pointer during a custom viewport python state. I could find only node.geometry().intersect() method, but indeed it works only for a single node/geometry, while I need to check different objects.
Workarounds I can think of: 1) Merge the different objects together, which result in a single messy geometry, full of useless attributes merged together. I don't like it but could be fast. 2) Or throw a ray for every object I need to check. Cleaner but, in case of many objects, could it potentially lead to lag in my viewport python state as the intersect is triggered at every mouse movement?
Regarding 2), I just needed to call a custom function during the python state when ‘S’ is pressed. I've found that I can temporarily clear the ‘S’ assignment during my python state (and reload it on exit)
I was experimenting with the onKeyEvent(), following the Python States documentation, but I'm facing a couple of issues.
If I press a key NOT in the group, the ELSE statement is executed, but I'm getting anyway the aforementioned output error in the console, which is quite annonying.
If I press the ‘s’ key, instead Houdini would exit the viewer state and switch to the Selection State, which is understandable, being ‘s’ the hotkey for that, BUT the IF statement is not getting evaluated. So you can't know if an already assigned hotkey is being pressed in your custom node viewer state.
defonKeyEvent(self,kwargs):ui_event=kwargs['ui_event']self.key_pressed=ui_event.device().keyString()ifself.key_pressedin('a','s','shift a','ctrl g'):# returns True to consume the eventprint('key pressed')returnTrueelse:print('No')