How to hole the homes

   8272   12   3
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
How do I subtract one block shape from another when controlling Houdini through Python (Boolean operation in Houdini)? Have a house, want a window.

Attachments:
Town.jpg (204.1 KB)
Wedge win.jpg (100.8 KB)

UR2BNE1U12B
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
Please; does anybody know how you subtract one shape from another under Python program control?
UR2BNE1U12B
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
If you can create the node network that performs that result, then it should be trivial to recreate that in Python. As a handy tip, you can ask Houdini to show you the code to create that node like this in the Python Shell window:
print hou.node(“/obj/path/to/node”).asCode()
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
When I try that I get a

NoneType' object has no attribute ‘asCode’

error message. Any suggestions?
UR2BNE1U12B
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Replace “/obj/path/to/node” with the real path of your node.
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
I call up the Python shell window, it says “source editor” but remains blank.
Then I type in

'print hou.node(“/obj/box_object2/boolean1/to/node”).asCode()'

but it generates no response. What am I doing wrong?
UR2BNE1U12B
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
Got it. Was typing path wrong.
Now let's see if I can figure out the code for the boolean operation.
Great help so far. Thanks.
UR2BNE1U12B
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
OK Wow, I got a lot more than I bargained for.
About 100 or so lines of code, in almost repeating stanzas that start with a cryptic comment, then an if statement to check for existence of object
The the following follows:

hou.parm = hou.node.parm('different parameters')
hou.parm.set('different parameters')
hou.parm.setAutoscope(False)
hou.parm.lock(False)

The first set of parameters include things like:autojoin, keepsourcecode, consolidateto1, dojitter, seed, overlapA, overlapB, closedA, closedB, insideAgroup, insideBgroup, insidetest, creategroup and many more

The second set of parameters include: Boverlap, Aoverlap, Ain, Bout, groupswitcher, 0, 1 and the hugely encouraging AminusB

How much of this is indispensable. Is there a short set of instructions, such as hou.parm.set(AminusB), and a couple more lines to establish who A and B are, that would do the job? I'm a bit swamped here. Help would be good.
UR2BNE1U12B
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
Could anyone please tell me in simple terms how to perform a boolean operation on 2 volumes in Houdini under Python control?
UR2BNE1U12B
User Avatar
Member
345 posts
Joined:
Offline
I certainly wouldn't go this route. Why do you want to build this in python? Procedural workflow in houdini gives you much better options. Have you tried fore each loop or feedback sop?
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
Writing code is what I do.

With the guy I'm helping on a CGI project,
we feel limited on how much cityscape we can
produce creating the objects directly in Houdini.
Whereas with some random numbers and a few
do loops and object oriented programming, the
virtual environment can be made to go on forever.

Come on somebody, there must be a simple
way to perform a Boolean operation on Houdini
objects under Python program control.
UR2BNE1U12B
User Avatar
Member
700 posts
Joined: 3月 2009
Offline
I must agree with Kuba, if you were doing it in the GUI would be much easier. Have you thought of turning the house models into Digital Assets that you could then place in the scene using python? That might make things a bit easier. Also you can use ForEach SOP nodes to repeat operations like you'd do in a python loop. It'll probably reduce your memory footprint for large scenes…

Cheers
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
User Avatar
Member
44 posts
Joined: 7月 2011
Offline
Hi Rafaels
OK, that might be the easiest route, but in our case, each house is different.
For the windows, for instance, their height, width and spacing will differ from house to house. Also a random function will determine whether at each interval there is either a window, blank wall, or a full length door. Some colonial houses have all doors. The only constant is that you must have at least one door. So the asset, controlled by Python might not allow for such flexibility unless it had it's random function incorporated.
UR2BNE1U12B
  • Quick Links