Notifications
Clear all

[Closed] GetFaceSelection convertion to interger, how?

I use the polyop.getFaceSelection $ to get a face.

I get a <face list> as an answer say #(10). problem is how on earth do I convert this into an integer?

I need to calculate the area of the face using polyop.getFaceArea $ INTEGER_VALUE
problem is I have to enter an integer value here, it won’t accept the face list, and I can’t convert the vert list into an integer.
Also the length of the face list is 595 (as many as there are faces), if the length was only 1 i could just get the first element.

A very strange problem
/Andreas

5 Replies

You dont get #() (array), you get #{} (bitArray)
May be you can do some better things with bitwise operators.
see maxscript ref for more about bitarrays and bit.
a = polyop.getFaceSelection $
b = a as array

polyop.getFaceArea $ b[i] –i can be any int number and b[i] is int
this works?
see my thread about biped and ctrls any idea?

3 Replies
(@f97ao)
Joined: 11 months ago

Posts: 0

Hi there, thanks for the answer, I managed to solve it after quite some while, I did it almost exactly like you said. I wrote

a=polyop.getFaceSelection $
b=a as array
sel=b[1]
and since the selection in this case always was only one size, then it was always at the first number.

/Andreas

(@bobo)
Joined: 11 months ago

Posts: 0

Just a quick note that since MAXScript is expression based, you can do shortcuts like

sel = ((polyop.getFaceSelection $) as array)[1]

(@f97ao)
Joined: 11 months ago

Posts: 0

Yea, thanks Bobo, I know about this one, but ARG!, readability.
/((Andreas as array)[1] as lotsofwork)==true

man if I were you I would write this way:

fn getFaceSelectionArea =

(

local totalAr = 0

for i in (polyOp.getFaceSelection selection[1]) do

(

local faceArea = polyOp.getFaceArea selection[1] i

totalAr += faceArea

)

return totalAr

)

see ya