PDA

View Full Version : Objects 2 Match another Objects Positions



Roadwarrior
02-18-2009, 04:54 AM
Want to use the original correct positioned 4Tyres
(B) , and assign the 4Tyres at 0.0.0 (A)
to match the same positions inside Layout

All the time keeping the 4 Tyres (A)
modeled at the 0.0.0 as these will rotate later on.

I have a mass of them to do so is there an Lscript
to do this snapping type procedure.

faulknermano
02-18-2009, 11:45 PM
Are the B Tyres placed in Layout, or were they positioned in Modeler?

Roadwarrior
02-18-2009, 11:46 PM
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

Roadwarrior
02-18-2009, 11:52 PM
Sorry faulknermano fell asleep on the job:D
Are the placed in Layout, or were they positioned in Modeler
The B Tyres were positioned in Modeler to align with the car body, i notice you had a snap to Lscript on the Ol Spread, :)

i tried them and it didn't seem to work on this type of setup.

faulknermano
02-19-2009, 12:02 AM
not sure if there can be a better method than what you're trying to do. firstly, if you positioned your tires already in Modeler, did you consider moving the pivot point in Modeler? I use this script to quickly find the average of select points / polys and move the pivot point there:



@warnings
main
{
selmode(USER);
pc = editbegin() || error("Select one point.");

vec = pointinfo(points[1]);

vec = <0,0,0>;
for(i=1;i<=pc;i++)
vec = vec + pointinfo(points[i]);
vec = vec / pc;

editend();
setpivot(vec);
}



so what happens is that I select the rim / model, then the script will take the average and place the pivot point there. This is assuming that each tyre is in separate layers. When loaded into Layout it should be in the proper position with the correct pivot point.

Roadwarrior
02-19-2009, 12:21 AM
i didn't consider the pivot point but now you mentioned it
this may solve part of the problem.:foreheads
Can Lscript command record object positions?

faulknermano
02-19-2009, 01:51 AM
there's a method of saving positions. for example, in Layout:



// code below saves selected item transformations (pos,rot,scl) in a text file
generic
{
fout = File("C:\\LW_XForm_Clipboard.txt","w");
if(!fout)
error("Unable to open file for writing");
s = Scene().getSelect();
if(!s)
error("Select an item");
curtime = Scene().currenttime;
for(i=1;i<=s.size();i++)
{
pos = s[i].getPosition(curtime);
rot = s[i].getRotation(curtime);
scl = s[i].getScaling(curtime);

fout.writeln(pos);
fout.writeln(rot);
fout.writeln(scl);
}

}




// code below applies transforms (pos, rot, scl)to selected items
generic
{
f = File("C:\\LW_XForm_Clipboard.txt","r");
if(!f)
error("Unable to open file for writing");
s = Scene().getSelect();
if(!s)
error("Select an item");
curtime = Scene().currenttime;
for(i=1;i<=s.size();i++)
{
rpos = f.read();
rrot = f.read();
rscl = f.read();
pos = vector(rpos);
rot = vector(rrot);
scl = vector(rscl);
SelectItem(s[i].id);
Position(pos);
Rotation(rot);
Scale(scl);

}
}

Roadwarrior
02-19-2009, 04:43 AM
thanks a bunch for the helps Faulknermano ! :)
look forward to speeding things up a bit with em!

Work, Lscripts, Faulknermano = no more suffering! :dance: :boogiedow