LS Commander (Basic Q)


#1

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


#2

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


#3

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?


#4

There are probably a lot of ways to do this, geditor, spreadsheet… but I’m actually intersted in getting a discussion going on lscript…


#5

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);

}
}


#6

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


#7

Works like a charm, thanks CIM!:thumbsup:


#8

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.


#9

I tried running the script provided by CIM btw and get an 'Unknown command “}” error every time.

Darn.


#10

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.)


#11

Originally posted by devin
[B]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. [/B]

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.


#12

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 &lt;= 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.


#13

He’s setting the Y rotation to 0.


#14

Interesting. But other than that they are very similar


#15

Got it now. Thx a mill for all your help everyone. Life is much easier with these boards and the good ppl on them.


#16

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.


#17

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


#18

Is there an online resource that has all the lscript commands in it?

Mike.


#19

The script didn’t work. I had to make some modifications and now it does. If you run it, it will zero out the § 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);
    }
}

#20

Download the LScript manuals from Newtek:

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