PDA

View Full Version : Making many objects into one object


polarbear53
05-11-2005, 08:15 PM
I have a scene with many objects that i would like to put together into one object, how do I do this?

faulknermano
05-12-2005, 02:04 AM
there was this plugin at flay.com called load objects from scene.. but i'm not a hundred percent on the name. some people, however, were having problems with it regarding crashes.

anyway, i'd give you solution right here and now:


first, save out all the transformed objects in the scene using this generic lscript. first select all the objects and then run the script. you will be prompted for an output directory. use a new directory to output the meshes to.


@warnings
active_useDir: val { return(val); }

generic // save all transformed
{
s = Scene().getSelect();

if(s[1].genus != MESH)
error("Select mesh type only.");

reqbegin("Batch Save Transformed");

objDir = string(getdir(OBJECTSDIR),"\\[DIRECTORY]");

defDir = recall("THEDIR",objDir);

c1 = ctlcheckbox("Use different directory?",0);
c2 = ctlfilename("New Directory",defDir,100,0);

ctlactive(c1,"active_useDir",c2);

return if(!reqpost());

useDir = getvalue(c1);
theDir = getvalue(c2);
store("THEDIR",theDir);
(f1,f2,f3,f4) = split(theDir);


AutoConfirm(true);
for(i=1;i<=s.size();i++)
{
if(s[i].null)
continue;
SelectItem(s[i].id);
if(useDir)
{
(g1,g2,g3,g4) = split(s[i].filename);
str = string(f1,f2,g3,g4);
SaveTransformed(str);
}
else
SaveTransformed(s[i].filename);
}
AutoConfirm(false);
}



then go to modeler and use this script to load that new directory. the script below will load all the objects in one directory in one layer.


// this version of NewTek's loadObjN2Lyr script revised by Lernie Ang
//loadObjN2Lyr.ls
@warnings 0
@version 2.3
@script modeler
@name Load Objects Into Layer...
c1; c2;
contentDir;
objList;

c_active: val
{
return(false);
}
c_refresh: val
{
objDirOld = getvalue(c1);
objDirNew = checkBackSlash(objDirOld);
if(objDirOld != objDirNew)
setvalue(c1,objDirNew);

objDir = objDirNew;
if(objDir == nil)
findObjects(contentDir);
else
findObjects(contentDir + objDir);

requpdate();
}
findObjects: dir
{
objList = nil;
LWOs = matchfiles(dir,"*.lwo");
OBJs = matchfiles(dir,"*.obj");
DXFs = matchfiles(dir,"*.dxf");

o = 0;

for(i=1;i<=LWOs.size();i++)
objList[++o] = LWOs[i];

for(i=1;i<=OBJs.size();i++)
objList[++o] = OBJs[i];

for(i=1;i<=DXFs.size();i++)
objList[++o] = DXFs[i];

}
list_count
{
if(objList[1] == nil)
return(0);
return(objList.size());
}

list_names: ndx
{
if(objList[1] == nil)
return(nil);
return(objList[ndx]);
}
checkBackSlash: str
{
if(strleft(str,1) != "\\")
str = "\\" + str;

return(str);


}
main
{
objList[1] = nil;
contentDir = getdir("Content");
objDir = recall("objDir","\\Objects");
objDir = checkBackSlash(objDir);
if(objDir == nil)
findObjects(contentDir);
else
findObjects(contentDir + objDir);


/*
if((getObjFile = getfile("Load Object Into Layer...","*.lwo",objDir,true)) == nil)
return;

if((objFile = File(getObjFile,"r")) == nil)
{
error("Unable to open object file.");
return;
}
*/

reqbegin("Load Objects Into Layer");

c0 = ctlstring("Content Directory",contentDir);
c1 = ctlstring("Object Subdir",objDir);
c2 = ctllistbox("Files",500,500,"list_count","list_names");


ctlactive(c2,"c_active",c0);
ctlrefresh(c1,"c_refresh");

ctlposition(c0,5,5,500);
ctlposition(c1,5,30,500);
ctlposition(c2,5,54);

return if(!reqpost());

objDir = getvalue(c1);
store("objDir",objDir);
objNdx = getvalue(c2);

reqend();

if(objNdx.size() == 0)
return;


for(i=1;i<=objNdx.size();i++)
{
n = objNdx[i];
if(objDir == nil)
importList[i] = contentDir + "\\" + objList[n];
else
importList[i] = contentDir + objDir + "\\" + objList[n];

}

for(i=1;i<=importList.size();i++)
{
curObj = Mesh(0);

curName = curObj.name;

current = lyrfg();

load(importList[i]);

copy();

close();

setobject(curName);

lyrsetfg(current);

paste();

}
}

polarbear53
05-12-2005, 09:16 AM
I was trying that code buy it gave me an error and i only had 10 minutes to mess with it, but now i found http://www.interialabs.de/lw/lscript/index.html (One Click Scene to Object (GN, MD))on flay. Thanks for the help.