python question

   2872   2   0
User Avatar
Member
53 posts
Joined: 7月 2005
Offline
Hey guys.

I am trying to start using python to some degree and I thought I would start by using it inside expressions instead of hscript.

So, I read a bunch of the docs, and tried to make an if statement but completely failed.

Here is what I am trying to do.

I have an arch that is made from an open circle. This arch creates a polygon that is then cookied out of a rectangle.

So it creates an archway. At the end of it I have a polyreduce that triangulates the end result.

Where I want to use the if statement is.. if the arch becomes just 2 points, making a line, I want to switch the cookie node off by bypassing it all together and keeping the original rectangle only.

So. the if statement if written in English, would go like:

( inside the switch input )

if circle division == 1 then
make the value of the switch node = 0
else
make the value of the switch node = 1

There is an example of an if statement in the docs, but my main problem is, how do I make a relative channel reference within python.

I tried it also in Hscript and I cant really get the relative references to work in there either.
I use them all the time to grab values from one node and pipe them into another and then put that all within brackets and do some math to it.. but never inside if statements.. Only if statement I have done that works is within the OTL when turning on or off UI elements based on a local variable.

Back to topic. My current Hscript looks like this.

if ('ch("../circle1/divs")' == 1 ) then 
return 0
else
return 1
endif

So, where am I going wrong here, and then… how would it look in python.

I'd love to know

Cheers

( EDIT:
if (ch("../circle1/divs") == 1,0,1)

works. so now I am wondering about the python version.
Edited by ambient-whisper - 2016年12月14日 16:55:58
-m-k-
User Avatar
スタッフ
3464 posts
Joined: 7月 2005
Offline
this is the best place to start:
http://www.sidefx.com/docs/houdini/hom/expressions [sidefx.com]
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
2129 posts
Joined: 9月 2015
Offline
Result = 1

if ch("../circle1/divs") == 1:
Result = 0

return Result


I put == 1 because I don't know what your doing with == 1,0,1

I don't know much Hscript, when I started Houdini I pretty much dove in Python.

Having said that, unless your doing something with Hscript that I am not familiar with the div parameter of a circle is an integer.
  • Quick Links