# Basic expression question

## Recommended Posts

Hey guys,

I'm following this tutorial Beginners - Houdini Expressions Tutorial and trying to push it a bit further. I want to make a condition for the uniform scale of my copy and set a limit if the number of copy is greater than 100 stop to cumulate the scale transform . I tried something like that if(\$NCY<100,ch("../scale2"),???) and if it false I want to use the uniform scale of the last copy before 100 and stay with that value until the end of the frame range.

Someone can help me with that?

Thx

Doum

##### Share on other sites

I'd put the scale channel into a clamp expression which will limit the number to the given range.

`if(\$NCY<100, ch("../scale2"), clamp(ch("../scale2"), 0, 100))[/CODE]`

Replace the 0 and 100 arguments for the clamp with whatever you want. If you want those values to be determined automatically it might require more than just expressions, like a for loop (like the For SOP) that keeps track of the values as it goes.

##### Share on other sites

You should make sure to use the proper Variable. \$NCY returns you the total nr of iterations \$CY returns you the current iteration.

so if(\$CY<10,0.8,1) is if the iteration is smaller then 10 then scale with 0.8 else use 1 meaning don't scale down any further.

##### Share on other sites

You should make sure to use the proper Variable. \$NCY returns you the total nr of iterations \$CY returns you the current iteration.

so if(\$CY<10,0.8,1) is if the iteration is smaller then 10 then scale with 0.8 else use 1 meaning don't scale down any further.

Nice, that's a lot cleaner than what I suggested.

##### Share on other sites

You were right Kgoossens, I wasn't using the proper variable. if((\$CY)<100,ch("../scale2"),1) that way it gives me the desire result.

I'll try to keep it to the basic and check this for loop thing later thx luke for the input.

Thanks guys for the helps,

SpiralExpression.hipnc

##### Share on other sites

Btw is there a way to show in the viewport some variable like the \$CY or the ID of each copy ?

## Create an account

Register a new account