Okay, I think it had something to do with script caching or whatever, because when I deleted everything from the Type Properties->Scripts, I noticed that the HDA was still working as if nothing has happened(!). Saving operator type and locking it up didn't help either. I had to delete the HDA node from my scene and restart Houdini. And only then it finally forgot that blasted script.
Then, I pasted the newest version of the script and now everything is working perfectly fine. Phew!
Found 477 posts.
Search results Show results as topic list.
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Hm. This is weird. I just created a simple scene for testing purposes and it works just fine there - no stripping occurs. The code I used is exactly the same as in my main HDA. :shock:
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Brilliant! This explains a lot! Thank you for taking your time to create this example.
However, there's a problem when I pass the callback script as an arg:
myButton = hou.ButtonParmTemplate('my_button',
‘My Button’,
script_callback=“hou.node('/obj/myHDA').hdaModule().test('foo!')”,
script_callback_language=hou.scriptLanguage.Python)
If I do this, and then click the button, I'm presented with a “NameError: name ‘test’ is not defined” error. And when I inspect the callback field of my button inside the control node, I see that it only stores the:
test(“foo!”)
function call, stripped of the path to my HDA node. So no wonder it can't find the function.
Do you have any suspicions as to why this happens?
However, there's a problem when I pass the callback script as an arg:
myButton = hou.ButtonParmTemplate('my_button',
‘My Button’,
script_callback=“hou.node('/obj/myHDA').hdaModule().test('foo!')”,
script_callback_language=hou.scriptLanguage.Python)
If I do this, and then click the button, I'm presented with a “NameError: name ‘test’ is not defined” error. And when I inspect the callback field of my button inside the control node, I see that it only stores the:
test(“foo!”)
function call, stripped of the path to my HDA node. So no wonder it can't find the function.
Do you have any suspicions as to why this happens?
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Hello.
I need to ask another question. I don't want to create another thread, so I'll just post here as it's still regarding Python in Houdini.
I have an HDA node with Python code in its Type Properties->Scripts. It basically contains a class and a dozen of functions with which I generate a network of OBJ and SOP nodes, with “one control node to rule them all”.
I create interface parameters of this control node from within the code inside my HDA. However, amongst those parameters there are some buttons to which I'd like to assign callback scripts. And this the problematic part, because the code of my HDA is invisible to the control node, so I can't just assign a function from my main script to the callback, because it will simply be inaccessible.
There are also some lists containing instances of various nodes that I need to pass to the callback function for processing.
I found this thread on OD|Force forum: http://forums.odforce.net/topic/9607-buttons-callback-script/?hl=%2Bscript+%2Bcallback [forums.odforce.net]
Some suggestions are made there to simply import Python module. But how do I import a module that is embedded into my HDA?
How should I approach this problem? What's the right way of doing it?
I need to ask another question. I don't want to create another thread, so I'll just post here as it's still regarding Python in Houdini.
I have an HDA node with Python code in its Type Properties->Scripts. It basically contains a class and a dozen of functions with which I generate a network of OBJ and SOP nodes, with “one control node to rule them all”.
I create interface parameters of this control node from within the code inside my HDA. However, amongst those parameters there are some buttons to which I'd like to assign callback scripts. And this the problematic part, because the code of my HDA is invisible to the control node, so I can't just assign a function from my main script to the callback, because it will simply be inaccessible.
There are also some lists containing instances of various nodes that I need to pass to the callback function for processing.
I found this thread on OD|Force forum: http://forums.odforce.net/topic/9607-buttons-callback-script/?hl=%2Bscript+%2Bcallback [forums.odforce.net]
Some suggestions are made there to simply import Python module. But how do I import a module that is embedded into my HDA?
How should I approach this problem? What's the right way of doing it?
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
As a workaround I ended up using the hou.InterruptableOperation class to display a progress window with some info on what is going on. The class is so clever that apart of user-specified string, it even provides some info on what Houdini is currently doing under the hood.
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Hi.
I have one more question, loosely related to this subject.
I've noticed that any print() functions and parameter changes are displayed AFTER the script reaches its end. Is there any way that I can feed them to standard output or, when it comes to parameters display, update them during run-time?
I have this String parameter called ‘hdaStatus’ in my HDA node, which I want to display information on what the HDA is currently processing, and I'm breaking my head trying to figure out how to do it. There's a line in which I'm loading a hi-res geometry and before it, I placed the:
self.hdaNode.parm('hdaStatus').set('Loading reference mesh. This may take a while…')
…but the UI representation of the ‘hdaStatus’ parameter updates AFTER the script finishes its job.
I have one more question, loosely related to this subject.
I've noticed that any print() functions and parameter changes are displayed AFTER the script reaches its end. Is there any way that I can feed them to standard output or, when it comes to parameters display, update them during run-time?
I have this String parameter called ‘hdaStatus’ in my HDA node, which I want to display information on what the HDA is currently processing, and I'm breaking my head trying to figure out how to do it. There's a line in which I'm loading a hi-res geometry and before it, I placed the:
self.hdaNode.parm('hdaStatus').set('Loading reference mesh. This may take a while…')
…but the UI representation of the ‘hdaStatus’ parameter updates AFTER the script finishes its job.
Technical Discussion » Viewport blocking problem.
- ajz3d
- 477 posts
- Offline
CyberikaI too have noticed this particular problem. The cursor changes into a hand, like in View mode, and stays like this even when I hoover over different pane tab types. I can't select anything, click on buttons, etc.
One more thing. Sometimes whole interfaces of houdini converts to viewport navigation area. I mean even if my mouse is outside of viewport I can tumble, dolly and track camera so this way all panels are inactive.
Most of the time minimizing Houdini window, changing focus, repeatedly tapping ALT and ESC escape keys in no particular order - helps. Sometimes though, I need to restart Houdini.
There are also times when the cursor permanently changes into arrows that you see when resizing windows. This fortunately doesn't prevent me from using UI components.
I'm on Houdini Apprentice 13.0.498 and Win7 Pro 64-bit.
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Excellent! This is exactly what I was looking for!
Many thanks Master Joker386. Your help was invaluable.
Many thanks Master Joker386. Your help was invaluable.
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Thank you Joker386, but that's not what I'm after.
I just took another look at the hou module and I think it's the hou.ParmTemplate class I should look into. I need to test it out.
I just took another look at the hou module and I think it's the hou.ParmTemplate class I should look into. I need to test it out.
Houdini Indie and Apprentice » Python: Is it possible to dynamically edit interface parms?
- ajz3d
- 477 posts
- Offline
Is it possible to dynamically create, edit, hide/show, remove and create dependencies (disable/hide when…) between interface parameters of nodes with just python code?
Simple example:
geo = hou.node('/obj').createNode('geo')
null = geo.createNode('null')
file = hou.node(geo.path()+'/file1')
Let's say I need to hide the copyinput and cacheinput parms of my null SopNode, create a button and a Float parameter that will reference data of some other node. Or maybe promote reload parameter (button) of the file SopNode to my geo node.
Can it be done?
Simple example:
geo = hou.node('/obj').createNode('geo')
null = geo.createNode('null')
file = hou.node(geo.path()+'/file1')
Let's say I need to hide the copyinput and cacheinput parms of my null SopNode, create a button and a Float parameter that will reference data of some other node. Or maybe promote reload parameter (button) of the file SopNode to my geo node.
Can it be done?
Houdini Indie and Apprentice » Automatic geometry separation, depending on group membership
- ajz3d
- 477 posts
- Offline
pezetkoThanks for your reply, Pezetko.
Put * in the Group Mask parameter of for each sop to process all groups.
If you want just save them, put File SOP inside forEach and set the name based on current loop (FORIDXVALUE or FORVALUE stamp expression).
I'm running into some problems with this one.
I use “$HIP/output/$FORVALUE.obj” string as a “Geometry File” parameter inside file SOP. I expected from $FORVALUE to assume values of each PrimGroup.name() of the input, similar to loops:
for primGroup in geo.primGroups(): # (…)
with $FORVALUE stamp being the equivalent of the primGroup variable in the example above. Turns out I'm wrong, because when I place the file node just before the ‘each’ node inside the forEach SOP, all I get is just one output file called ‘.obj’ - it doesn't even have a name, just an extension. It contains all groups from the input. What am I doing wrong here?
Yes, this is how I do it ATM.
import hou
#select file sop
selectedNode = hou.selectedNodes()
groups = selectedNode.geometry().primGroups()
for group in groups:
blastNode = selectedNode.createOutputNode('blast')
blastNode.setName(“keep”+group.name())
blastNode.parm('group').set(group.name())
blastNode.parm('negate').set(1)
I understand that it is not possible to fork the flow into n-streams without scripting?
Houdini Indie and Apprentice » Automatic geometry separation, depending on group membership
- ajz3d
- 477 posts
- Offline
Hello.
I'm trying to find an automated solution to separate geometry into multiple SOPs depending on group membership.
In the uploaded example. The file SOP contains a geometry that has predefined four groups: smallBox, medBox, largeBox and sphere.
I have separated them manually, by linking multiple Delete SOPs (Delete Non-Selected) to the file SOP - one for each group, but while it's okay when there are only a few groups, it gets tedious when there are more.
What would be the best approach to this problem?
Maybe forEach node? But if so, then how do I determine names of groups to iterate on, if they don't follow some sort of pattern? And how do I fork the pipes later on?
P.S. I realise I can do this with a Python script, but I'd rather like to use nodes if possible.
I'm trying to find an automated solution to separate geometry into multiple SOPs depending on group membership.
In the uploaded example. The file SOP contains a geometry that has predefined four groups: smallBox, medBox, largeBox and sphere.
I have separated them manually, by linking multiple Delete SOPs (Delete Non-Selected) to the file SOP - one for each group, but while it's okay when there are only a few groups, it gets tedious when there are more.
What would be the best approach to this problem?
Maybe forEach node? But if so, then how do I determine names of groups to iterate on, if they don't follow some sort of pattern? And how do I fork the pipes later on?
P.S. I realise I can do this with a Python script, but I'd rather like to use nodes if possible.
Houdini Indie and Apprentice » Keep hard edges on import and export?
- ajz3d
- 477 posts
- Offline
I wrote a very simple OBJ exporter in Python. It preserves points order, uvs, and most importantly, vertex normals.
And all would be perfectly fine and dandy, if it didn't flip primitive facing in the exported file. So, in order to export geometry with correct facing, I need to place a Reverse SOP first.
I suspect I might have messed something up in a loop that iterates through vertices of primitives. But it does so in order from Prim.vertices().
I tried reversing the loop (reversed(Prim.vertices()) but then, while the primitives indeed get reversed, it also causes a change in their winding, which of course leads to a slightly different shading (due to reversed tessellation) and is unacceptable.
Until I find where the problem lies, I'd like to reverse facings of all polygons of a given instance of a Geometry class with the code. Does hou module contain a function that is an equivalent of a Reverse SOP? I looked for it, but in vain.
Having to place Reverse SOP before each export is way too tedious, even as a makeshift solution. :roll:
—–
Update:
I've resolved this by making my exporter an HDA and by placing two reverse SOPs inside it (one for reversing faces before the export, the latter - to reverse them back).
And all would be perfectly fine and dandy, if it didn't flip primitive facing in the exported file. So, in order to export geometry with correct facing, I need to place a Reverse SOP first.
I suspect I might have messed something up in a loop that iterates through vertices of primitives. But it does so in order from Prim.vertices().
I tried reversing the loop (reversed(Prim.vertices()) but then, while the primitives indeed get reversed, it also causes a change in their winding, which of course leads to a slightly different shading (due to reversed tessellation) and is unacceptable.
Until I find where the problem lies, I'd like to reverse facings of all polygons of a given instance of a Geometry class with the code. Does hou module contain a function that is an equivalent of a Reverse SOP? I looked for it, but in vain.
Having to place Reverse SOP before each export is way too tedious, even as a makeshift solution. :roll:
—–
Update:
I've resolved this by making my exporter an HDA and by placing two reverse SOPs inside it (one for reversing faces before the export, the latter - to reverse them back).
Houdini Indie and Apprentice » Keep hard edges on import and export?
- ajz3d
- 477 posts
- Offline
MartybNzSo, a point is Houdini's term for naming what other 3d packages simply call vertices. On the other hand, Houdini's vertices are… vertices that constitute a single primitive (polygon). Nice.
Have a read through this page on an explanation of geometry attributes:
http://www.sidefx.com/docs/houdini13.0/model/attributes [sidefx.com]
Anyway, I'd like to return to my main question.
I'll rephrase it:
Is it possible to import a mesh that has predefined hard edges (or smoothing groups), and then export it from Houdini with normals intact, while preserving vertex order at the same time?
—–
EDIT: I was browsing the forum in order to find an answer to my question, and I stumbled upon this post by Antoine Durr: https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=88831#88831 [sidefx.com]
(…)The process of saving to .obj (which uses the gwavefront standalone) converts point normals and calls them vertex normals inside the .obj. Vertex normals are ignored. It is probably time to refile that RFE for gwavefront to handle vertex normals.
It looks like gwavefront.exe might be the culprit. It doesn't matter if I have vertex normal attributes or not, because they are ignored by the exporter. And if I make points unique and promote my vertex normals to point normals, I end up with separated faces (and no soft-edges), which is not what I want.
I guess that in order to accomplish what I need, I'd have to write a custom OBJ exporter that respects vertex normals. Unless somebody already did this, and is kind enough too share it perhaps?
Houdini Indie and Apprentice » Keep hard edges on import and export?
- ajz3d
- 477 posts
- Offline
MartybNzCool! Many thanks MartybNz. This fixed the problem with normals being ditched by xform transformations.
no time to check your file but try unchecking ‘Recompute Point Normals’ on Transform node
But another (off-topic) question arises. When is it useful to recompute point normals? I mean, in what part of Houdini having this option enabled is the most helpful?
I still have difficulties understanding the point entity, how it relates to a vertex, and how it is different from it.
Houdini Indie and Apprentice » Keep hard edges on import and export?
- ajz3d
- 477 posts
- Offline
Hello Cradders, and thank you for your response.
It turns out it's more trickier than I thought it is. When I import the object, at first it seems that Houdini preserves object's vertex normals (the model looks correct after the OBJ is imported into the scene), but they break immediately after I transform the mesh with xform.
What is interesting, is that transformations on object level do not cause vertex normals to break. Why?
I've prepared a very simple scene as an example, so you can see what I mean.
Regarding my second question. You can try to export the mesh with either the ROP Driver or with RMB->“Save Geometry…” command, and compare the vertex normals from the original OBJ file to what Houdini exported. You'll notice that the exported mesh contains only hard edges.
I'm sure the original vertex normals are somewhere out there… I can see them as vertex attributes in the details view. I tried promoting these attributes to points, but it was a bad idea, since there are fewer points than vertices.
I have no idea how to extract those normals and re-apply on the geo before exporting it back to file.
CraddersI'd like to avoid re-creating vertex normals inside Houdini, and rather re-use existing hard edges from imported OBJ file.
I fully admit I'm a relative newbie to the Houdini giants on this forum, but I'd suggest you look at the Facet SOP. There are check boxes for computing normals, as well as an option to cusp polygons to ‘permanently’ set their hardness.
It turns out it's more trickier than I thought it is. When I import the object, at first it seems that Houdini preserves object's vertex normals (the model looks correct after the OBJ is imported into the scene), but they break immediately after I transform the mesh with xform.
What is interesting, is that transformations on object level do not cause vertex normals to break. Why?
I've prepared a very simple scene as an example, so you can see what I mean.
Regarding my second question. You can try to export the mesh with either the ROP Driver or with RMB->“Save Geometry…” command, and compare the vertex normals from the original OBJ file to what Houdini exported. You'll notice that the exported mesh contains only hard edges.
I'm sure the original vertex normals are somewhere out there… I can see them as vertex attributes in the details view. I tried promoting these attributes to points, but it was a bad idea, since there are fewer points than vertices.
I have no idea how to extract those normals and re-apply on the geo before exporting it back to file.
Houdini Indie and Apprentice » Keep hard edges on import and export?
- ajz3d
- 477 posts
- Offline
Hello everyone.
I'm a very fresh Houdini Apprentice user. I'm barely a week into it, so I might be asking about some obvious things. ops:
I ran into two problems when importing and exporting geometry.
1. Is it possible to retain hard edges from an OBJ file imported with a File SOP? The object gets smoothed on import, and all vertex normals seem to be lost. I've read some threads here on the forum about this, but I still have no clue on how to get those normals back.
Oops. This was a user-error. I picked the wrong file version. But the second question is still valid.
2. If I write a geometry to an OBJ file with a ROP Output Driver, I end up with all edges hardened. How do I tell Houdini to keep vertex normals in the exported file?
AJ
I'm a very fresh Houdini Apprentice user. I'm barely a week into it, so I might be asking about some obvious things. ops:
I ran into two problems when importing and exporting geometry.
1. Is it possible to retain hard edges from an OBJ file imported with a File SOP? The object gets smoothed on import, and all vertex normals seem to be lost. I've read some threads here on the forum about this, but I still have no clue on how to get those normals back.
Oops. This was a user-error. I picked the wrong file version. But the second question is still valid.
2. If I write a geometry to an OBJ file with a ROP Output Driver, I end up with all edges hardened. How do I tell Houdini to keep vertex normals in the exported file?
AJ
-
- Quick Links