PDA

View Full Version : setting the motion of several items at once ?



lasco
10-22-2004, 08:50 AM
Hi,

How do you numerically set a same rotation or position parameter
at once for a group of objects ?
Example : you select at once 40 objects
and set them with a rotation of 20 ?

It seems the spreadsheet manager does not allow to do this :(

faulknermano
10-24-2004, 10:12 AM
this is a generic script that i use as an extra for lw's own numeric function.



@warnings 0
tab;
reqkeyboard: key
{
info(key);
if(key == 49)
{
setvalue(tab,1);
}
if(key == 50)
{
setvalue(tab,2);
}
if(key == 51)
{
setvalue(tab,3);
}


}

generic
{
s = Scene().getSelect();
spos = s[1].getPosition(Scene().currenttime);
srot = s[1].getRotation(Scene().currenttime);
sscl = s[1].getScaling(Scene().currenttime);
cx = integer(recall("cx",0));
cy = integer(recall("cy",0));
cz = integer(recall("cz",0));
ch = integer(recall("ch",0));
cp = integer(recall("cp",0));
cb = integer(recall("cb",0));
csx = integer(recall("csx",0));
csy = integer(recall("csy",0));
csz = integer(recall("csz",0));


tabdef = integer(recall("tabdef",1));
reqbegin("NumericGN");
reqsize(215,150);


// make this work with position rotation and scale at the same time


c1 = ctldistance("",spos.x);
c2 = ctldistance("",spos.y);
c3 = ctldistance("",spos.z);
c4 = ctlcheckbox("X",cx);
c5 = ctlcheckbox("Y",cy);
c6 = ctlcheckbox("Z",cz);

d1 = ctlangle("",srot.x);
d2 = ctlangle("",srot.y);
d3 = ctlangle("",srot.z);
d4 = ctlcheckbox("H",ch);
d5 = ctlcheckbox("P",cp);
d6 = ctlcheckbox("B",cb);

e1 = ctlnumber("",sscl.x);
e2 = ctlnumber("",sscl.y);
e3 = ctlnumber("",sscl.z);
e4 = ctlcheckbox("X",csx);
e5 = ctlcheckbox("Y",csy);
e6 = ctlcheckbox("Z",csz);

tab = ctlchoice("",tabdef,@"Position","Rotation","Scale"@);

ctlposition(tab,5,5);

ctlposition(c1,40,35,150);
ctlposition(c2,40,35+24,150);
ctlposition(c3,40,35+24+24,150);
ctlposition(c4,5,35);
ctlposition(c5,5,35+24);
ctlposition(c6,5,35+24+24);

ctlposition(d1,40,35,150);
ctlposition(d2,40,35+24,150);
ctlposition(d3,40,35+24+24,150);
ctlposition(d4,5,35);
ctlposition(d5,5,35+24);
ctlposition(d6,5,35+24+24);

ctlposition(e1,40,35,150);
ctlposition(e2,40,35+24,150);
ctlposition(e3,40,35+24+24,150);
ctlposition(e4,5,35);
ctlposition(e5,5,35+24);
ctlposition(e6,5,35+24+24);



ctlrefresh(tab,"refresh_tab");
ctlvisible(tab,"tab_pos",c1,c2,c3,c4,c5,c6);
ctlvisible(tab,"tab_rot",d1,d2,d3,d4,d5,d6);
ctlvisible(tab,"tab_scl",e1,e2,e3,e4,e5,e6);

ctlactive(c4,"_active",c1);
ctlactive(c5,"_active",c2);
ctlactive(c6,"_active",c3);

ctlactive(d4,"_active",d1);
ctlactive(d5,"_active",d2);
ctlactive(d6,"_active",d3);

ctlactive(e4,"_active",e1);
ctlactive(e5,"_active",e2);
ctlactive(e6,"_active",e3);


return if(!reqpost());

tabdef = getvalue(tab);
cx = getvalue(c4);
cy = getvalue(c5);
cz = getvalue(c6);

ch = getvalue(d4);
cp = getvalue(d5);
cb = getvalue(d6);

csx = getvalue(e4);
csy = getvalue(e5);
csz = getvalue(e6);

for(i=1;i<=s.size();i++)
{
SelectItem(s[i].id);

if(tabdef == 1)
{
if(cx)
px = getvalue(c1);
else
px = s[i].getPosition(Scene().currenttime).x;

if(cy)
py = getvalue(c2);
else
py = s[i].getPosition(Scene().currenttime).y;

if(cz)
pz = getvalue(c3);
else
pz = s[i].getPosition(Scene().currenttime).z;

Position(px,py,pz);
}
if(tabdef == 2)
{
if(ch)
rh = getvalue(d1);
else
rh = s[i].getRotation(Scene().currenttime).h;

if(cp)
rp = getvalue(d2);
else
rp = s[i].getRotation(Scene().currenttime).p;

if(cb)
rb = getvalue(d3);
else
rb = s[i].getRotation(Scene().currenttime).b;

Rotation(rh,rp,rb);
}

if(tabdef == 3)
{
if(csx)
sx = getvalue(e1);
else
sx = s[i].getScaling(Scene().currenttime).x;

if(csy)
sy = getvalue(e2);
else
sy = s[i].getScaling(Scene().currenttime).y;

if(csz)
sz = getvalue(e3);
else
sz = s[i].getScaling(Scene().currenttime).z;

Scale(sx,sy,sz);
}

}

reqend();

store("cx",cx);
store("cy",cy);
store("cz",cz);

store("ch",ch);
store("cp",cp);
store("cb",cb);

store("csx",csx);
store("csy",csy);
store("csz",csz);

SelectItem(s[s.size()].id);
return if(s.size() <= 1);
for(i=s.size() - 1;i>=1;i--)
AddToSelection(s[i].id);

}
refresh_tab: val
{
store("tabdef",val);
}
tab_pos: val
{
if(val == 1)
return(true);
else
return(false);
}
tab_rot: val
{
if(val == 2)
return(true);
else
return(false);
}
tab_scl: val
{
if(val == 3)
return(true);
else
return(false);
}
_active: val
{
return(val);
}

lasco
10-24-2004, 01:29 PM
Now this works PERFECTLY !
And the option you have to only change one channel
for each parameter is so great !

thank you so much folk, you saved me hours of work !