PDA

View Full Version : select two objects



3dWannabe
06-10-2011, 09:35 PM
I'm trying to modify IL_SaveTSeq.ls http://www.interialabs.de/lw/lscript/files/IL_SaveTSeq_101.zip so that it will save several objects at once in the output LWO file.

I figured out how to get it to ask for more than one object, but I'm having trouble selecting more than one object.

myObject.select();
myObject2.select();

doesn't select both, just the last object

myObject.select();
AddToSelection(myObject2.id);

doesn't fail, but I don't think it works either as I only end up with a single object in the output.

In fact, I just tested adding several lines like:

SelectItem("ElmerLowPolyFrom3dCoat:Pupils");
AddToSelection("ElmerLowPolyFrom3dCoat:Eyes");
AddToSelection("ElmerLowPolyFrom3dCoat:Breastplate");

and instead of adding to the selection, only the Breastplate gets selected and output????

1. How can I select two objects at once?

2. preferably, how can I select ALL of the MESH objects in Layout?

Thanks!

nickdigital
06-10-2011, 10:41 PM
Maybe you have to put your selection into an array?

evenflcw
06-11-2011, 08:00 AM
1. SelectItem followed by AddToSelection is the proper way to select items inside Layout. Layout is half-way (or half-heartedly) command-based and will commonly not want complex data types (arrays or object-/agents) as arguments to commands.

Selection might not be the problem, but rather that SaveTransformed command only saves the last or first selected mesh. In which case you should be looping, selecting one mesh at a time and calling the save function at each loop iteration.

2.Get the first mesh from Mesh() function. Then loop through all mesh items using mesh.next() method. In every loop iteration, check for pointcount>0 (or similar) to avoid nulls, and use AddToSelection to add the current mesh to selection. The first mesh you should be selected prior to entering the loop using SelectItem.

3dWannabe
06-11-2011, 09:00 AM
1. SelectItem followed by AddToSelection is the proper way to select items inside Layout. Layout is half-way (or half-heartedly) command-based and will commonly not want complex data types (arrays or object-/agents) as arguments to commands.

Selection might not be the problem, but rather that SaveTransformed command only saves the last or first selected mesh. In which case you should be looping, selecting one mesh at a time and calling the save function at each loop iteration.

2.Get the first mesh from Mesh() function. Then loop through all mesh items using mesh.next() method. In every loop iteration, check for pointcount>0 (or similar) to avoid nulls, and use AddToSelection to add the current mesh to selection. The first mesh you should be selected prior to entering the loop using SelectItem.

Yes, I'd observed that AddToSelection, when used with SaveTransformed seems to only transform the last mesh selected.

Are you saying that SaveTransformed will only allow me to save a file with one mesh, or that I can loop and be able to save all the meshes into one file using SaveTransformed in some fashion?

OR - is there some way to combine (using a script) several LWO's each containing one object? That would work, but I'd be dealing with a sequence of LWOs, so that each frame of LWOs would have to be condensed into one.

My end-result of all of this is to create an FBX file for each frame. As using Autodesk's FBX converter (the 2009 version that works) takes almost a minute per conversion, combining the objects into a single FBX (or finding a way to output them from Lightwave, which would be faster) is very important as I've got a lot of frames.


Maybe you have to put your selection into an array?

I'm not sure AddToSelection is even mentioned in the docs (or maybe it was some other routines I was looking at that weren't mentioned?) so it seems hard to tell. I've seen it used in code snippets in this forum without being used in an array.

But, that's certainly a valid question.

evenflcw
06-11-2011, 09:53 AM
SaveTransformed does not seem to be able to save multilayer objects, so I guess I was saying "save a file with one mesh"!

There is, to my knowledge, no practical way to combine multiple layers/objects into one mesh inside Layout. Only Modeler has "true" layers.

So you've got alot of frames, alot of layers and alot of lwo's?
How experienced are you with lscript in particular and coding in general?

3dWannabe
06-11-2011, 10:50 AM
SaveTransformed does not seem to be able to save multilayer objects, so I guess I was saying "save a file with one mesh"!

There is, to my knowledge, no practical way to combine multiple layers/objects into one mesh inside Layout. Only Modeler has "true" layers.

So you've got alot of frames, alot of layers and alot of lwo's?
How experienced are you with lscript in particular and coding in general?
I write code for a living, using C# and SQL, but started in assembly over 30 years ago, writing the BIOS for a new 6800 computer and debugging with an logic analyzer.

Zero experience with lscript, but I can make sense of it and modify existing code a bit.

I'm working on getting an FBX mesh sequence into Fusion (which doesn't understand bones, so I need just a mesh).

With Cageman's tutorial, and a lot of these scripts, I've gotten it to work, but ... my only problem is that the only version of the FBX Converter from Autodesk that works operates very, very slowly.

So, ideally I'm looking for a way to convert my 'saveTransformed' sequence of objects into a sequence of single FBX files (each containing all the objects).

The FBX files generate by Lightwave work well, but ... Lightwave pops up this dialog and file selector, so it does not seem to be able to be controllable for the automated generation of an FBX sequence.

Thanks!

Blochi
06-21-2011, 10:01 AM
You can try suppressing dialogs with this at the start of your work code:



AutoConfirm(true);



But make sure to set it back to false before the script ends (or is aborted or errors out), because otherwise there will be no more safety popups for that session. Not even the "Are you sure to quit?" and stuff.

Blochi
06-21-2011, 10:07 AM
As to the general method, don't rely on multiselection. Rather do your own loop and perform the savetransformed over and over again.

Here's a script that might help, it's for replacing all selected objects (also a function that natively works only on one object):



//-----------------------------------------
// Batch Replace Object v 2.0
//-----------------------------------------
// 12-24-2004 by Blochi ([email protected])
// 05-31-2007 : update multiselection in LW9.2

@version 2.9
@warnings
@script generic


generic
{
curScene = Scene();
objList = curScene.getSelect(MESH);

if(objList != nil)
{
PathArray = getmultifile("Select replacement object, multiselection will be randomized.",getdir(OBJECTSDIR));
if(PathArray != nil)
{
for(i = 1; i <= size(objList); i++)
{
SelectItem(objList[i].id);
ReplaceWithObject(""+PathArray[random(1,size(PathArray))]);
}
}
}
}

3dWannabe
06-21-2011, 10:27 AM
You can try suppressing dialogs with this at the start of your work code:



AutoConfirm(true);



But make sure to set it back to false before the script ends (or is aborted or errors out), because otherwise there will be no more safety popups for that session. Not even the "Are you sure to quit?" and stuff.

I was having an issue with a massive number of warning dialogs, that that should help. Thanks!!!

Also, thanks for the "objList = curScene.getSelect(MESH);" script.

BTW - I posted a fogBugz about EXPORTFBX not respecting a file name passed to it (like EXPORTOBJ does).

Do you think there's any way to trick Lightwave 9.6 or 10.1 into outputting named FBX files?

3dWannabe
08-11-2011, 12:44 PM
You can try suppressing dialogs with this at the start of your work code:



AutoConfirm(true);



But make sure to set it back to false before the script ends (or is aborted or errors out), because otherwise there will be no more safety popups for that session. Not even the "Are you sure to quit?" and stuff.

Is there a specific place that needs to go?

I get Error: "Unresolved function reference AutoConfirm()?

Thanks!

3dWannabe
08-11-2011, 10:00 PM
ahhh! too late to edit my post!

BTW - I'm trying to use AutoConfirm(1) or AutoConfirm(true) in Modeler with the
IL_BatchEdit2.ls script.

It has a

main {

rather than a

generic {

Is the problem that it doesn't exist in Modeler?

Is there a way to suppress the dialogs in Modeler?

The sad thing is, LW 10.1 doesn't even give the dialogs, BUT ... 10.1 messes with the OBJ format, so that I need to use 9.6 to end up with the 'correct' FBX output I need (where I have to use a 2009 version of AutoDesk's FBX converter as AD broke it so that there are no normal's in any version after 2009 when converting from OBJ to FBX).

Ahhh! Always something!!!

Thanks!!!