setdetailattribute min

   2814   9   1
User Avatar
Member
4189 posts
Joined: June 2012
Offline
Hi! Just wondering if the minimum function of setdetailattrib is dead


f@dog = {11, 30, 5};

setdetailattrib(0, 'max', @dog, "max");
setdetailattrib(0, 'min', @dog, "min");

returns

max 11.0
min 0.0

H17.5.260, linux
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
It works…just depends on how you are using it.

For starters..your trying to assign 3 values to a single attribute - f@dog.

So it only takes the first value of 11. That's why you get a max of 11 instead of 30.

Since there is no min value…it defaults to 0.

Create a polygon sphere and in a wrangle set to run over points put the following and you will see the function does work:

setdetailattrib(0, 'max', @P.y, "max");
setdetailattrib(0, 'min', @P.y, "min");
User Avatar
Member
4189 posts
Joined: June 2012
Offline
thanks - that works but then why doesn't it for for the @speed attribute of the attached. The Max works but not the min.

Attachments:
speed.hipnc (309.5 KB)

User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Yeah, that's strange…I think it is a bug.

I mean it works with @v.

But if before the wrangle with setdetail, I add a wrangle and doing something like this for normals:

@N = set(rand(@ptnum) + 1, rand(@ptnum+2) + 1, rand(@ptnum+3) + 1);

Setdetail still returns 0 for all components.( at ‘best’ min should be no less than 1 )

But if I use a sop to set normals, setdetail works fine.
Edited by BabaJ - June 1, 2019 21:50:53
User Avatar
Member
7810 posts
Joined: Sept. 2011
Offline
I think you are misunderstanding what min and max mean in this context. The token at the end of setattib() functions determines how the value is recorded.

the normal way, ‘set’, replaces the existing value with the new one.
'multiply', ‘min’, ‘max’, ‘add’, etc perform that operation to combine the existing value with the new one.

For example, if you set the values of ‘P’, to {1.0,1.0,1.0} with a min operation, all the points left of 1.0, below 1.0 and behind 1.0 units from the origin will be unchanged, the rest will be set to 1.0.

In your examples, I presume the attribute named ‘min’ and ‘max’ do not yet exist. When performing a ‘min’ or ‘max’ operation, the existing values are assumed to be 0, and the operation uses 0 as the first operand and your new value as the second.

There are other functions called min() and max() that work on vectors or arrays to return the highest value or lowest value contained therein.
Edited by jsmack - June 1, 2019 22:09:43

Attachments:
setpointattrib_ex.hip (124.3 KB)

User Avatar
Member
4189 posts
Joined: June 2012
Offline
okay, does that mean to normalise the min, max values of the @speed attribute, in the example, then I need to use an attribute promote Sop? Would prefer a vex solution if possible.
User Avatar
Member
8597 posts
Joined: July 2007
Offline
goat
okay, does that mean to normalise the min, max values of the @speed attribute, in the example, then I need to use an attribute promote Sop? Would prefer a vex solution if possible.

just make sure your speed_min default is a big number
you can either initialize it before
or if you need in the same wrangle you can use adddetailattrib()
adddetailattrib(0, 'speed_min', 1e10);
setdetailattrib(0, 'speed_min', @speed, "min");
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
4189 posts
Joined: June 2012
Offline
thanks @tamte - that works beautifully.
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
So..it's sort of a ‘bug’.

If there is no attribute to begin with and it's assuming a value of 0.0,

Then the first ‘set’ operation is creating the attribute.

No reason why that initial creation could not branch an operation to use the current value as the starting point.

I'm guessing there is a bit of legacy coding going on here.

Like wasn't there at one point in time something like not being able to set a non-existent attribute. But now we can?
User Avatar
Member
64 posts
Joined: July 2005
Offline
tamte
adddetailattrib(0, 'speed_min', 1e10);
Thank you!!! I had this set in an upstream wrangle but still had rounding, putting it in same wrangle fixed. thanks
  • Quick Links