Notifications
Clear all

[Closed] loop through selection of elements/faces

Hi!
I’m trying to loop through a selection of elements like

 for i in selection do

does it with an selection of objects.
I selected some elements of my mesh inside a editable poly and now I would like to edit them via script. But I can’t find a way to loop through the elements. Is there something similar?

3 Replies

Hi,

You can seperate the elements using polyOp.getElementsUsingFace fn and then loop through them.

Light

Thanks for that fast answer, I’ll give it a try!

Hi McM,

how did you go? This function will return an array of arrays holding the faces of an objects elements.


fn getelements obj=
(
try
(
f=obj.numfaces
eles=#()
done=#()
for i=1 to f do
(
if (finditem done i)==0 then
(
case (classof obj) of
(
editable_mesh:(faces=(meshop.getElementsUsingFace obj #(i)) as array)
editable_poly:(faces=(polyop.getElementsUsingFace obj #(i)) as array)
)
append eles faces
join done faces
)
)
)
catch(eles="non poly or mesh object!")
return eles
)
 
getelements selection[1]

Hope it’s useful!

J.