resize a cube through a Vex Function

   Views 725   Replies 6   Subscribers 2
User Avatar
Member
6 posts
Joined: Oct. 2019
Offline
Hello there.
I am really sorry for the ultra noob question:
I have a cube, that I would like to resize with a VEX function


float test = ch("../transform1/sz");

if(ch("../line1/dist") <= 2)
{
    @scale = set(1.0,3.0,4.0); //resize box. not working
    @sizey = 3.0; //size box. not working
    @Cd = set(0,1,0);//debug purpose. if green, code is compiling
    test = 3.0; //going through a transform node doesn.t work either...
}
else
{
    @Cd = set(1,0,0);//red. if red, code updates
}

I don't understand why I cannot resize my cube....
thank you for your help

Attachments:
HoudiniVexResize.png (1.3 MB)

User Avatar
Member
243 posts
Joined: May 2017
Offline
Hi
@scale is a point instance attribute that is usually used in copy to point or dop context. Use matrix transformation when dealing direct with geo (hip example below):

matrix M = ident();
scale(M, chv('t'));
@P *= M;

Image Not Found
Edited by vikus - Feb. 18, 2025 11:48:16

Attachments:
vex_scale.hiplc (108.7 KB)

User Avatar
Member
6 posts
Joined: Oct. 2019
Offline
thank you for your message!
here is what I am trying to achieve ;
I have a box, that I 'copytopoints' on a line
I try to instantiate the box on every point on the line, and the amount of points on line changes depending on its length...

The problem is when I make the length of the line change, in a float way (for example : 1.43), there is either a gab between boxes (if under n.5 float value : 1.3 for example), or an overlapping geometries (if over the n.5 float value : 1.6 for example).
like the picture here :



I thought it would be easier to play with vex, but maybe there is a much easier way to play it around.
what do you reckon?


I did it with VEX
I am not sure it works tho. I will come back to report after my tests

vector toscale = chv('t');
matrix M = ident();
if(ch("../line1/dist/")%1 <0.5)
{
    toscale.x = ch("../line1/dist")+ch("../line1/dist")%1;
    @tx = toscale.x;
    scale(M, toscale);
    @P *= M;
}
else if(ch("../line1/dist/")%1 >0.5)
{
    toscale.x = ch("../line1/dist")-ch("../line1/dist")%1;
    @tx = toscale.x;
    scale(M, toscale);
    @P *= M;
}
Edited by lostshun - Feb. 19, 2025 02:33:26

Attachments:
image1.png (810.3 KB)

User Avatar
Member
243 posts
Joined: May 2017
Offline
You need to compute the ratio between length and (point amount(n) - 1 = (gap amount).

ratio = length / (n - 1). As long as the cube is uniform that should work.

Put some examples. You dont need 'vex', could also use transform sop with expression.

Image Not Found
Edited by vikus - Feb. 19, 2025 02:53:10

Attachments:
vex_scale.hiplc (124.8 KB)

User Avatar
Member
253 posts
Joined: Jan. 2008
Offline
Use the chain SOP with this exact functionality.
User Avatar
Member
6 posts
Joined: Oct. 2019
Offline
vikus
You need to compute the ratio between length and (point amount(n) - 1 = (gap amount).

ratio = length / (n - 1). As long as the cube is uniform that should work.

Put some examples. You dont need 'vex', could also use transform sop with expression.

Image Not Found

oh my god! sweet!
that's the answer you are looking for! thank you so much!
User Avatar
Member
6 posts
Joined: Oct. 2019
Offline
mawi
Use the chain SOP with this exact functionality.

oooooohhhh! it works so easily! and yes, this node is exactly what I was looking for, in such a simple way!!
thank youuuuuuu
  • Quick Links