# Beginner's question: centroid vs \$CEX vs bbox

## Recommended Posts

Hello!
I am new to coding. I assume my problem is that I don't fully understand Hscript's syntax and also I seem to struggle with explanation provided by official documentation.

Quote

"Centroid expression function: Returns centroid information for a surface node."

1) First, just to make it clear, does "returns" mean: This function "gives/provides/sends"?

2) By "centroid information" it implies world coordinates of the object's centroid?

3) And by "surface node" it implies individual parameter cell where I write in my values? (btw how should I properly call those "cells/windows", are those parameter channels? confused...)

4) centroid type D_Z, what does "D" stand for?

a. I placed a box and move it -4 in Z direction; b. I created Transform node and wrote centroid function in Z translate parameter cell: centroid("../box1", D_Z)  = -4;  c. -4-4=-8...; d. Oh... Ok... So when I put (-) before this function it looks like that -(-4) = +4 Which translates box into the world center. It means that I kind off answered to the first 3 questions myself. Right? : D

Quote

a. b. c. d.

5) What is the difference between centroid and \$CEZ? Why would I use one over the other? What are those "Global variables" and how do they differ from "Expression functions"?

6) Is bbox type D_ZSIZE just the distance value between D_ZMIN and D_ZMAX?

Thank you!

Edited by Serafim_Chayka

##### Share on other sites

1) return => function int sum(int x, int y) { return x+y; } takes 2 integers and returns their sum .. so yeah it gives you back something

2) yes

3) surface node is any SOP. those "cells/windows" are parameters. They can have 1 or more channels (= "cells" per row)

4) probably Dimension. Don't care, I'm lazy and use 0, 1, 2

5) centroid() is a function, \$CEX, etc are global variables. Difference is centroid() can grab centroid of any SOP whereas \$CEX always returns the centroid of the SOP you use it on

6) yes

Edited by 3dome
• 2

##### Share on other sites
16 hours ago, 3dome said:

1) return => function int sum(int x, int y) { return x+y; } takes 2 integers and returns their sum .. so yeah it gives you back something

2) yes

3) surface node is any SOP. those "cells/windows" are parameters. They can have 1 or more channels (= "cells" per row)

4) probably Dimension. Don't care, I'm lazy and use 0, 1, 2

5) centroid() is a function, \$CEX, etc are global variables. Difference is centroid() can grab centroid of any SOP whereas \$CEX always returns the centroid of the SOP you use it on

6) yes

1) Very clear!

3) Here is what I found in the documentation:

Quote
 Edit a parameter value Click in a parameter value box and type a new value.

Parameter value box = channel; Right?

Aren't channels specifically related to animation? Is channel just a value that is bound to a keyframe?

4) Where should I look for that kind of information, if I want to start defining parts of a code? Is it a waste of my time and should I just memorize each code as it is?

...I do not understand what you mean by "use 0, 1, 2"

5) Is there somewhere a full list of global variables? Found one here but it doesn't seem to be complete... At least I can't find the one we discussed...

Sorry for deluging you with questions...

##### Share on other sites
On 2/14/2019 at 7:19 AM, Serafim_Chayka said:

Parameter value box = channel; Right?

right.

On 2/14/2019 at 7:19 AM, Serafim_Chayka said:

Aren't channels specifically related to animation? Is channel just a value that is bound to a keyframe?

no and no. For every parameter (no matter if one or more channels) there is a function defined somewhere in the code that takes the values you enter in the channel(s) as function arguments. Keyframes is a different story.

On 2/14/2019 at 7:19 AM, Serafim_Chayka said:

4) Where should I look for that kind of information, if I want to start defining parts of a code? Is it a waste of my time and should I just memorize each code as it is?

...I do not understand what you mean by "use 0, 1, 2"

you will memorize the syntax of the most common functions over time. If you're not sure, open help or when you type a function name and then the first open bracket houdini should pop up a help to this function where you can see how it's being used

centroid("/path/to/sop", 0) instead of centroid("path/to/sop", D_X) and so on

On 2/14/2019 at 7:19 AM, Serafim_Chayka said:

5) Is there somewhere a full list of global variables? Found one here but it doesn't seem to be complete... At least I can't find the one we discussed...

should all be in the docs. http://www.sidefx.com/docs/houdini/ref/expression_cookbook.html
they are referred to as expressions, which makes sense as they are not variables that represent constant values!

• 1

## Create an account

Register a new account