why doesn't the script see the variable ???
Good afternoon.
I'm trying to create a script that moves objects in a certain direction (X,Y,Z) ....
in the initial position, these objects are located inside another object
_______________________________________________________________________________________
try (DestroyDialog parent_dialog) catch()
rollout parent_dialog "Parent" width:140 height:140
(
local varDir = undefined
local arrayObj =#() -- массив выбранных объектов
checkbox XPOS "X pos."
checkbox YPOS "Y pos."
checkbox ZPOS "Z pos."
button btPrepear "Prepear"
on btPrepear pressed do
(
arrayObj = selection as array
case of
(
(XPOS.checked == true):
(
varDir = "arrayObj[t].pos.x = arrayObj[t].pos.x + 1.0"
)
(YPOS.checked == true):
(
varDir = "arrayObj[t].pos.y = arrayObj[t].pos.y + 1.0"
)
(ZPOS.checked == true):
(
varDir = "arrayObj[t].pos.z = arrayObj[t].pos.z + 1.0"
)
)
for t = 1 to arrayObj.count do
(
while (intersects arrayObj[t] $Box001 == true) do
(
execute varDir
)
)
)
)
createDialog parent_dialog pos:[1580,30] style:#(#style_titlebar, #style_border, #style_sysmenu, #style_minimizebox)
__________________________________________________________________
when I do such conversions without creating a CreateDialog everything is happening normally. But if I use CreateDialog function,an error occurs.
It seems that the script does not see the internal variable.
I attach a scene
Attachment | Size |
---|---|
scene_winrar.rar | 17.43 KB |
Comments
Your arrayObj is local inside the parent_dialog scope, while execute always works in global scope. While you could address it as parent_dialog.arrayObj, you're also using variable t, that's local to the for loop scope. It's better to rethink it and do it without execute altogether:
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
.
you can define offset for all three axis at the same time
offset = [5.0,5.0,5.0] * [ if XPOS.checked then 1 else 0, if YPOS.checked then 1 else 0, if ZPOS.checked then 1 else 0]