PDA

View Full Version : Array-loop problem


Rivendale
09-28-2004, 01:05 AM
Hey, I'm making some tools for selecting things in polyobjects. I have a problem with a tool like below. It adds every other polygon to the selection(or every nth in final) based on the facenumber.

The problem I have is that the index gets out of range if it tries to select polygons after the last facenumber. What can I do to prevent it from getting out of range?

(
rollout mainroll "Select polygons"
(
group "Selection"
(
button Nthsel "Nth Sel"
)
on Nthsel pressed do undo on
(
FaceSel = polyop.getfaceselection $.baseobject
Facearr = polyop.getfaceselection $.baseobject
for i in FaceSel do
append Facearr (i+2)
setfaceselection $ Facearr
redrawviews()
)
)
main = newrolloutfloater "Nth Select" 130 120
addrollout mainroll main
)

Help?

CML

Rivendale
09-28-2004, 04:21 AM
Woohoo I solved it, I'm soo proud:)
Did it like so:
FaceSel = polyop.getfaceselection $.baseobject
Facearr = polyop.getfaceselection $.baseobject
for i in FaceSel do
if i < ($.faces.count-1) then
append Facearr (i+2)
setfaceselection $ Facearr
redrawviews()

(Remember I'm newb so this is a big triumph for me:) )

CML

CGTalk Moderation
01-19-2006, 10:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.