@P.y -= number (vex)didn't work

   1976   3   1
User Avatar
Member
5 posts
Joined: 2月 2022
Offline
I wanted all points of my objects minus min height of the point of the object, so it can move to the grid. but apparently, it didn't work.

fist point wrangle
vector p = point(0, "P", 0);
float minHeight = p.y;
int numberOfPoint = npoints(0);
for(int i = 0; i < numberOfPoint; i++) {
    p = point(0, "P", i);
    if(minHeight > p.y) {
        minHeight = p.y;
    }
}

f@minHeight = minHeight;

second point wrangle

float minHeight = detail(0, "minHeight");

@P.y -= minHeight;
Edited by zhutianci123456 - 2022年10月15日 09:04:52

Attachments:
微信截图_20221015210207.png (22.9 KB)
untitled.hipnc (100.5 KB)

User Avatar
Member
2129 posts
Joined: 9月 2015
Offline
In your second point wrangle node you're attempting to use a detail attribute named 'minHeight' which doesn't exist as a detail.

So with no actual detail attribute it reads back 0. So subtracting 0 doesn't change anything.

The previous point wrangle node you have it set to run over points so the attribute 'minHeight' gets created as a point attribute, not a detail attribute.

So you'll want to change the nodes run over parameter to detail in order that in the next wrangle node you have that detail attribute available.
User Avatar
Member
5 posts
Joined: 2月 2022
Offline
BabaJ
In your second point wrangle node you're attempting to use a detail attribute named 'minHeight' which doesn't exist as a detail.

So with no actual detail attribute it reads back 0. So subtracting 0 doesn't change anything.

The previous point wrangle node you have it set to run over points so the attribute 'minHeight' gets created as a point attribute, not a detail attribute.

So you'll want to change the nodes run over parameter to detail in order that in the next wrangle node you have that detail attribute available.

thanks, after i change to
setdetailattrib(0, "minHeight", minHeight, "set");
, it works.
User Avatar
Member
8833 posts
Joined: 7月 2007
Offline
you can also just change your first wrangle to Detail wrangle
however there is no need to compute this yourself, especially in a loop


you can have a single point wrangle:
@P.y -= getbbox_min(0).y;

OR

Match Size SOP
Justify X, Z : None
Justify Y: Min
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links