[Closed] transform script and local modifier problem
Hi all,
I have a problem, perhaps somebody could take a look at the code below.
Below is a small test program to slice a box with 2 slices depending on how the planes are standing. This works good if i take out the * (getModContextTM ‘” + b b.modifiers[mod_pos] + “’), but when i take it in, i just gives an error.
segment = box pos:[0,0,0]
vlak1 = Plane pos:[0,20,5] width:40 length:40
vlak2 = Plane pos:[0,20,15] width:40 length:40
slice_mod = slicemodifier()
slice_mod1 = slicemodifier()
addmodifier segment slice_mod
addmodifier segment slice_mod1
script_Controller "test" segment vlak1 1
script_Controller "test2" segment vlak2 2
fn script_Controller script_naam segment vlak mod_seg =
(
script = script_naam
p = vlak
b = segment
script = transform_script()
b.modifiers[mod_seg].slice_plane.controller = script
theCtrl1 = p.transform.controller
script.addtarget p.name theCtrl1
format "testtttttt %
" (getModContextTM b b.modifiers[mod_seg])
txt = "$'" + p.name + "'.transform * (getModContextTM '" + b b.modifiers[mod_seg] + "') * (inverse $'" + b.name + "'.transform)
"
script.setexpression txt
)
Hi,
I cleaned up the script and changed the pivot of the box (from maxscript help :-)) to the code example. Hopyfully it gives a better demonstration of what is going wrong.
I would like to align the slices on the box to the planes, and i think i should use (getModContextTM b b.modifiers[1]) for this, but when i place this in the TXT script, like this it doenst want to work anymore.
TXT= "$'" + p.name + "'.transform * (getModContextTM '" + b b.modifiers[1] "') * (inverse $'" + b.name + "'.transform)
"
below without getModContextTM
clearlistener()
global segment = box pos:[0,0,0]
RotatePivotOnly segment (EulerAngles 50 50 35)
vlak_array = #(vlak1 = Plane pos:[0,20,5] width:40 length:40, vlak2 = Plane pos:[0,20,15] width:40 length:40)
for x = 1 to 2 do
(
addmodifier segment (slicemodifier())
script_Controller segment vlak_array[x]
)
fn script_Controller segment vlak =
(
p = vlak
b = segment
script = transform_script()
b.modifiers[1].slice_plane.controller = script
theCtrl1 = p.transform.controller
script.addtarget p.name theCtrl1
--format "testtttttt %
" (getModContextTM b b.modifiers[1])
TXT= "$'" + p.name + "'.transform * (inverse $'" + b.name + "'.transform)
"
script.setexpression TXT
)
fn RotatePivotOnly obj rotation=
(
local rotValInv=inverse (rotation as quat)
animate off in coordsys local obj.rotation*=RotValInv
obj.objectoffsetrot*=RotValInv
obj.objectoffsetpos*=RotValInv
)
And i have one more question, i would also like to keep the slice modifiers in the same pos/rot of the planes when i move the box. should i write a new transform script for this or can this be placed in the same one i already have.