PDA

View Full Version : LS Commander (Basic Q)


devin
03-16-2003, 01:23 AM
Hi,

I've been given a scene file with hundreds of objects (mainly clones) that have been haphazardly placed in the Y within Layout. I've already modded the model files but now have to fix the scene. I'm trying to get them to all rest on the ground now at "0".

I thought I'd give LS Commander a try to speed things up but here's the prob.

I just want to move objects in the Y and not influence X and Z but I have no clue how to do that. I'm a programming flunky for sure.

Here's what I get...

generic
{
Position("<X>","<0>","<Z>");
}

Is there anything that I can place for X and Z to tell it to ignore moving these channels.

Maybe there is something easier to truly batch these items. I'd appreciate any info. I've already searched flay.

/devin

Mike RB
03-16-2003, 04:02 AM
This is actuauly good, as lscript is somthing that is powerful yet underused. I'm just looking into lscript now as I've been doing a lot of scripting work on the game I'm working on.

I don't know the functions we need but this is probably how the logic should work:

//////////////////////////////////////////////////////
variable1 = objects current x pos;
variable2 = objects current z pos;

Position ( variable1, 0, variable2);

Select next object;
//////////////////////////////////////////////////////
Unless there is a SetPositionY function....

The way to do this without lscript would be to just select them all, open the grpah editor, hit shift-g to get all the curves, select only the y curves, select all the keyframes and type in 0 in the value field.

But i'd love CIM or CMAN or someone to chime in here on how one would do this script as I'd love to learn more myself.

Mike

Shade01
03-16-2003, 04:16 AM
Isn't this something you could do in the spreadsheet editor? Just do a batch selection, select motion options and key in a value only on the y axis for all objects?

Mike RB
03-16-2003, 04:18 AM
There are probably a lot of ways to do this, geditor, spreadsheet...... but I'm actually intersted in getting a discussion going on lscript....

CIM
03-16-2003, 04:34 AM
Basically, something like this would be decent:

generic
{
// Get selected
sel = Scene().getSelect() || error("Select Something!");
// Get currenttime
curTime = Scene().currenttime;

// Loop through selected
// Get position
// Select and set position
for(i = 1; i <= sel.size(); i++)
{
pos[i] = sel[i].getPosition(curTime);

SelectItem(sel[i].id);
Position(pos[i].x, 0, pos[i].z);
}
}

Mike RB
03-16-2003, 04:47 AM
pos[i] has all the position numbers contained it in right? And you extract the one you want by adding a .x .y or .z at the end of it?

Cool.

for(i = 1; i <= sel.size(); i++)
{
}

this section runs whats in the squggle brackets once after running the top part each time... Which defines i, sets the for loop to stop once i is equal to the number of selected items, and then increments it once per loop... right?

Mike

mohh
03-16-2003, 04:50 AM
Works like a charm, thanks CIM!:thumbsup:

devin
03-16-2003, 05:41 AM
This is off from the LScript discussion but Shade01 mentions batching the Y value in the spreadsheet. Am I missing something? I don't see any options for affecting the individual move/rot/scale channels.

I've been sucked into general new media work for awhile now and have been away from LW's newer tools but I do consult the manual and search a bit before posting. Plz excuse my loss at some of the new goodz!

/devin

PS - Thx for the help everyone.

devin
03-16-2003, 06:02 AM
I tried running the script provided by CIM btw and get an 'Unknown command "}" error every time.

Darn.

Triple G
03-16-2003, 07:05 AM
Very cool, CIM. :thumbsup: LScript is still a huge mystery to me...maybe one of these days I'll really sit down and try to wrap my head around it. :shrug:

@Devin: I ran it, and it works fine for me with 7.5. Are you running 7.5b by any chance? (I actually didn't use LS commander....I copy/pasted what CIM wrote into a plain text file, and saved it with a .ls extension. Then I just ran it by going to LScript->LScript Tools->LScript. Worked like a charm.)

SplineGod
03-16-2003, 07:40 AM
Originally posted by devin
This is off from the LScript discussion but Shade01 mentions batching the Y value in the spreadsheet. Am I missing something? I don't see any options for affecting the individual move/rot/scale channels.

I've been sucked into general new media work for awhile now and have been away from LW's newer tools but I do consult the manual and search a bit before posting. Plz excuse my loss at some of the new goodz!

/devin

PS - Thx for the help everyone.
Select all your objects in the scene editor.
Open the graph editor and hit shift g to throw every channel of every object into the channel bin. Use the filter function to filter out everything except the Y channels. Select all the Y channels and set them to zero.

Mike RB
03-16-2003, 06:03 PM
Faulknermano posted this as a responce in the newtek board:

@warnings
generic
{
s = Scene().getSelect();
for(i=1;i<=s.size();i++)
{
pos = s[i].getPosition(Scene().currenttime);
SelectItem(s[i].id);
Rotation(s[i].x,0.0,s[i].z);
}
}


I'm trying to see the differences between that and yours CIM:

generic
{
sel = Scene().getSelect() || error("Select Something!");
curTime = Scene().currenttime;

for(i = 1; i <= sel.size(); i++)
{
pos[i] = sel[i].getPosition(curTime);

SelectItem(sel[i].id);
Position(pos[i].x, 0, pos[i].z);
}
}


The on ly thing i can see is that you put current time into a variable, Faulknermano didnt. Cool.

CIM
03-16-2003, 08:38 PM
He's setting the Y rotation to 0.

Mike RB
03-16-2003, 09:02 PM
Interesting. But other than that they are very similar

devin
03-16-2003, 11:25 PM
Got it now. Thx a mill for all your help everyone. Life is much easier with these boards and the good ppl on them.

mohh
03-17-2003, 03:19 AM
Hey Mike,

If you look closely, it seems as if Faulknermano's is zeroing out a rotation value (pitch?), while CIM's zero's out the Y position.

Mike RB
03-17-2003, 03:26 AM
I see that. So what exactly does putting a .z at the end mean, does it just pull out the one channel?

What else can you put after wards to get returned...

Mike

Mike RB
03-17-2003, 04:18 AM
Is there an online resource that has all the lscript commands in it?

Mike.

mohh
03-17-2003, 04:21 AM
The script didn't work. I had to make some modifications and now it does. If you run it, it will zero out the (P) pitch of the objects selected.

So what exactly does putting a .z at the end mean, does it just pull out the one channel?

The .z simply gets the current z position of the object. If I were to have left it as it was with the .z value in there, then the bank would have been changed to try and match the value of the z axis. Since one value is a coordinate and the other a degree, the results are not desireable.

Modified script:

@warnings
generic
{
s = Scene().getSelect();
for(i=1;i<=s.size();i++)
{
pos[i] = s[i].getPosition(Scene().currenttime);
SelectItem(s[i].id);
Rotation(pos[i].h,0.0,pos[i].b);
}
}

CIM
03-17-2003, 04:23 AM
Download the LScript manuals from Newtek:

http://www.newtek.com/products/lightwave/downloads/index.html

Mike RB
03-17-2003, 04:33 AM
Thanks cim, found them just after posting that.

Mike

CGTalk Moderation
01-14-2006, 03:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.