Keeping layers during meshing of Rhino objects -> OBJ -> Rhino

 From:  Micha
2720.1 
(I copied Michaels text from the v2 beta release thread to this thread to start an own thread.)

Michael, I tried it, but it dosn't work here.

Rhino layers - Default, Layer 01, Layer 03, Layer 04

OBJ names - Default_3 and three objects joined at layer Default

Attached my Rhino test scene and the convert cmd/js. Do you have an idea?

Thank you very much for all your effort.
Micha



Michael wrote:
>>>>>>>>>>>>>>>
Hi Micha, re: mesh Rhino NURBS and bring back into Rhino with the same layers.

> Maybe an option could be implemented that allow to
> save styles as mesh names (without joining meshes
> with the same name) and at Rhino a script move the
> meshes back to the original layers?

I think it should be possible to handle this part by a script right now in MoI.

For example, if you set up the following script on a keyboard shortcut:

script: /* Set object name as style name + num */ var objs = moi.geometryDatabase.getObjects(); var styles = moi.geometryDatabase.getObjectStyles(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); obj.name = styles.item(obj.styleIndex).name + '_' + i; }

Then when you hit that shortcut key each object will get assigned a name of its associated style name, plus a unique increasing number, like BlueLayer_2, BlueLayer_3, etc...

The number is appended to make the names unique to avoid combination of mesh objects with identical names.

After you have run that script, then when you export to OBJ and read into Rhino, that information of what layer the mesh was originally on will stored in the object name, and some Rhino script code should probably be able to go through the meshes, strip off the ending _xxx which will then give it the layer name to place that object on.

Probably if you can clearly state the problem in the Rhino newsgroup someone will be able to help you with that part. Something like: "I have a bunch of mesh objects with layers stored in their names, like BlueLayer_1, BlueLayer_2, OrangeLayer_5, etc... and I want to edit these objects to place them on the layer that is named in the object name, like assign BlueLayer_1 to the layer named "BlueLayer", etc...


You can incorporate that same MoI script above to be a built in part of your batch conversion script if you want, just after the opening of the model file. Here is more readable version of it for putting in a text file rather than in a single-line keyboard shortcut:

code:
// Set object names to be their Style name + unique number.
var objs = moi.geometryDatabase.getObjects();
var styles = moi.geometryDatabase.getObjectStyles();
for ( var i = 0; i < objs.length; ++i )
{
var obj = objs.item(i);
obj.name = styles.item(obj.styleIndex).name + '_' + i;
}




- Michael
Visualisation for Designer and Architects - www.simulacrum.de