Hi all!
I'm trying to create more complex expressions within Houdini, but have run into some serious problems. If I, for instance, want to create something like the following:
if ($TX > 5)
$TX -= .1;
else
$TX += .1;
where would I enter the actual expression? This seems like a fairly simple thing to do, but I just can't figure it out…any help would be GREATLY appreciated!
Thanks,
fixxorion
Expressions
9068 10 1- fixxorion
- Member
- 11 posts
- Joined: July 2005
- Offline
- old_school
- Staff
- 2540 posts
- Joined: July 2005
- Offline
- fixxorion
- Member
- 11 posts
- Joined: July 2005
- Offline
Thanks for the reply!
However, I actually knew about how to do that…my example was a bit too simple. Here's a more practical one. Say I've made a custom attribute, which controls the weight of an object…over time, the object get's heavier until it finally starts to fall and as it falls, it loses weight. So, I want to say say somthing like:
if ($WEIGHT < 5)
{
$WEIGHT+=0.1;
}
else
{
$WEIGHT-=0.1;
$TY-=$WEIGHT;
}
How would I do this with ONE expression? Also, how would I go about creating a custom expression function?
Thanks,
fixxorion
However, I actually knew about how to do that…my example was a bit too simple. Here's a more practical one. Say I've made a custom attribute, which controls the weight of an object…over time, the object get's heavier until it finally starts to fall and as it falls, it loses weight. So, I want to say say somthing like:
if ($WEIGHT < 5)
{
$WEIGHT+=0.1;
}
else
{
$WEIGHT-=0.1;
$TY-=$WEIGHT;
}
How would I do this with ONE expression? Also, how would I go about creating a custom expression function?
Thanks,
fixxorion
- MarkCreer
- Member
- 27 posts
- Joined: July 2005
- Offline
I was wondering the same - surely it would be easy to have a SOP, COP etc that was purely for a bit of code - bridging the gap between full scripting and the single line field in parameter OPs??
when several math OPs are needed to do some basic multiply/divide stuff it's got to be easier to write it in three lines
mark creer
when several math OPs are needed to do some basic multiply/divide stuff it's got to be easier to write it in three lines
mark creer
- goldfarb
- Staff
- 3455 posts
- Joined: July 2005
- Offline
check the expressions pdf for Custom Expressions > a little taste >
Custom Expression Functions are a way of extending the built-in expression language
using a simple C like scripting language. These functions can then be used anywhere you use a built-in function.
BASIC FORM
The basic form of a custom expression is:
# Function to double a number.
double(number)
{
number = number * 2;
return number;
}
Once you have entered this custom expession function, you can use it within any Houdini edit Þeld as if it were a regular function. For example, you could then type:sin( double($F) )into the Centre-X Þeld of a Sphere SOP, and it would provide values to the sin() function that are equal to double that of $F at a given frame.
Custom Expression Functions are a way of extending the built-in expression language
using a simple C like scripting language. These functions can then be used anywhere you use a built-in function.
BASIC FORM
The basic form of a custom expression is:
# Function to double a number.
double(number)
{
number = number * 2;
return number;
}
Once you have entered this custom expession function, you can use it within any Houdini edit Þeld as if it were a regular function. For example, you could then type:sin( double($F) )into the Centre-X Þeld of a Sphere SOP, and it would provide values to the sin() function that are equal to double that of $F at a given frame.
- fixxorion
- Member
- 11 posts
- Joined: July 2005
- Offline
Thanks for the quick reply, but I have looked through the manual and cannot, for the life of me, find where I'm supposed to enter these functions. I've tried typing them directly into the parameter field, but it refuses to work. Creating them isn't the problem…it's where to put them. The answer's there, but I can't find it…please help me!
Thanks,
fixxorion
Thanks,
fixxorion
- EigenAlex
- Member
- 639 posts
- Joined: July 2005
- Offline
- goldfarb
- Staff
- 3455 posts
- Joined: July 2005
- Offline
sorry…
if you read the pdf there is a section right under “Basic Form” called “Editing” that show you a few ways to do it…
BTW - does anyone know how to get rid of the “My eBooks” folder that acrobat creates everytime I open a pdf file in XP…it's really driving me insane…also that “My Pictures” folder is getting to me also…and please don't say ‘get Linux’ :shock:
if you read the pdf there is a section right under “Basic Form” called “Editing” that show you a few ways to do it…
BTW - does anyone know how to get rid of the “My eBooks” folder that acrobat creates everytime I open a pdf file in XP…it's really driving me insane…also that “My Pictures” folder is getting to me also…and please don't say ‘get Linux’ :shock:
- fixxorion
- Member
- 11 posts
- Joined: July 2005
- Offline
Thank you all VERY much for the info! It was definitely driving me insane. :roll: It now works, which is comforting.
I do have another question, though…how am I supposed to access global variables within the expression function? Or better yet, how would I go about changing and accessing a custom attribute I created with an Attribute POP?
Thanks for all the help,
fixxorion
I do have another question, though…how am I supposed to access global variables within the expression function? Or better yet, how would I go about changing and accessing a custom attribute I created with an Attribute POP?
Thanks for all the help,
fixxorion
- old_school
- Staff
- 2540 posts
- Joined: July 2005
- Offline
Just use it in the expression:
double()
{
number = $TX * 2;
return number;
}
where $TX can be your custom attribute if you always expect it to be there with a proper signature added with the Attribute SOP and of the right type.
I would rather pass in the attribute as a variable arguement. Better for tweaking and reuseability.
I wouldn't bother hard coding in an attribute though. Best done with VEX if you want to work internally with a custom attribute and many times faster. Make a custom vex SOP to deal with this.
double()
{
number = $TX * 2;
return number;
}
where $TX can be your custom attribute if you always expect it to be there with a proper signature added with the Attribute SOP and of the right type.
I would rather pass in the attribute as a variable arguement. Better for tweaking and reuseability.
I wouldn't bother hard coding in an attribute though. Best done with VEX if you want to work internally with a custom attribute and many times faster. Make a custom vex SOP to deal with this.
There's at least one school like the old school!
- fixxorion
- Member
- 11 posts
- Joined: July 2005
- Offline
-
- Quick Links