ScriptSpot

Forum topic · General Scripting

Cannot get the for loop to run only insight of array

By Harvid · 2018-03-10

Description

I'm trying to get a loop to run through the faces I've selected but it runs true all the faces of the model.. what am i doing wrong.


try (closeRolloutFloater MainFloater) catch()

fn Makeplaner ev nodes =
(
for n in nodes where isKindOf (obj = getAnimByHandle n) Editable_Poly do (
if planer ==true then
(
obj.EditablePoly.ConvertSelection #Vertex #Face
Mplaner = obj.GetSelection #Face
For i = 1 to Mplaner.count do
(
obj.EditablePoly.SetSelection #Face #{i}
obj.EditablePoly.makePlanar #Face
)
Mplaner = undefined
Polymodel = undefined
gc light:true
rerun() --call fn rerun
)
)
)
Fn rerun =
(
if planer == true then
(
Polymodel = NodeEventCallback mouseUp:true delay:5000 geometryChanged:Makeplaner

)
)

Rollout Menu01 "PPLANER"
(
checkbutton two "Check" pos:[2,6] width:80 height:20
on two changed state do
(
if state ==true then
(
global planer = true
rerun()
)
else
(
global planer = false
)
)

)
MainFloater = NewRolloutFloater "" 178 55
addRollout Menu01 MainFloater

Comments (1)

Harvid · 2018-03-17

I have pretty much got it to work.
but it only on my desktop computer on my laptop it not running the Fn rerun.. some ideas why ?

fn Makeplaner ev nodes =
(
for n in nodes where isKindOf (obj = getAnimByHandle n) Editable_Poly do (
if planer ==true then
(
obj.EditablePoly.ConvertSelection #Vertex #Face
Mplaner = obj.GetSelection #Face as array
for i in Mplaner do
(
subobjectLevel = 4
$.EditablePoly.SetSelection #Face #{i}
$.EditablePoly.makePlanar #Face

)
subobjectLevel = 1
Polymodel = undefined
gc light:true

)
)
)

Fn rerun =
(
if planer == true then
(
Polymodel = NodeEventCallback mouseUp:true delay:5000 geometryChanged:Makeplaner

)
)