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

AttachmentSize
scene_winrar.rar17.43 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Swordslayer's picture

 

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:

try destroyDialog parent_dialog catch()
rollout parent_dialog "Parent" width:140 height:140
(
    local cullObj = $Box001
 
    checkBox XPOS "X pos."
    checkBox YPOS "Y pos."
    checkBox ZPOS "Z pos."
    button btPrepear "Prepear"
 
    on btPrepear pressed do with undo "Move Objects" on
        for obj in selection do if intersects obj $Box001 do move obj \
            [if XPOS.checked then amax 0 (ceil (cullObj.max.x - obj.min.x)) else 0,
             if YPOS.checked then amax 0 (ceil (cullObj.max.y - obj.min.y)) else 0,
             if ZPOS.checked then amax 0 (ceil (cullObj.max.z - obj.min.z)) else 0]
)
createDialog parent_dialog pos:[1580,30] style:#(#style_titlebar, #style_border, #style_sysmenu, #style_minimizebox)
jahman's picture

.

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]

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.