Export option for OBJ names needed - object names lost

Next
 From:  Micha
3396.1 
Hello,

my client gave me a Rhino file with many objects at layers and object names with the material name. After meshing per MoI I lost all object names, but got the layer names as object name. This could be usefull, if there would be a script for converting names to layers. For now I lost the original object names and layers I havn't too. It could be nice, if the OBJ object naming could get an option (at the export option page), so that the user could choose between layer names or original object names.

Regards,
Micha

Visualisation for Designer and Architects | http://www.simulacrum.de
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Micha
3396.2 In reply to 3396.1 
... there is also a information channel unused - the object colors of the Rhino materials are reset to gray. Could be good, if this colors could be keeped too.


Stop - I have seen now, obj material color it's the layer color. OK, could be nice, if this behavoir could be set to material color stay material color too. At the moment. The layer information is saved in two "positions" - obj name and obj color. But I have objects with different materials at different layers.

EDITED: 19 Mar 2010 by MICHA

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3396.3 In reply to 3396.1 
Hi Micha, I'm sorry it's not entirely clear what you are asking about.

MoI does not store layer names as the object name in an OBJ export - layers are called "Styles" in MoI, and Styles become a materials list and material assignments in the OBJ file.

Object names are totally separate from Style names - an "object name" is a label assigned to an object that is separate from its style/layer assignment.

Object names are also written to an OBJ file, they are written into the OBJ file as an "o" directive which is intended to label the name for an object in the file.


> After meshing per MoI I lost all object names, but got the layer
> names as object name.

That should not happen - object names should be preserved, and there is nothing in MoI that tries to copy the style name to be the object name.

If you are seeing this, can you please send me a small sample 3DM file that I can use to reproduce the behavior?

But I think that you may have gotten confused between some of these various names...


> It could be nice, if the OBJ object naming could get an option
> (at the export option page), so that the user could choose
> between layer names or original object names.

You want an option to write the object name as something totally different than the actual object name? That seems like it would be pretty weird.

Since there is an "object name" in MoI and there is something for the "object name" in the OBJ file, it is most natural that these should match.

I could create a script for you that would do something like set objects to have the same object name as their assigned style, if that would be any help.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3396.4 In reply to 3396.2 
Hi Micha,

> ... there is also a information channel unused - the
> object colors of the Rhino materials are reset to gray.
> Could be good, if this colors could be keeped too.

MoI does not support this kind of separate individual object color that would override the layer color.

That can tend to be confusing in many ways, and also does not map very well to the way that most mesh file formats are structured.

In an OBJ file for instance, there is no mechanism in place to have a color directly assigned to an object itself, the only way things are colored is by assigning a material.

So having things assigned color by their assignment to a material list is what MoI is focused on using.


> Stop - I have seen now, obj material color it's the layer color.

Yes, in MoI it is the Style color that will become the material color in the exported file - the Styles list in MoI becomes the Materials list in the OBJ file.


> OK, could be nice, if this behavoir could be set to material color
> stay material color too.

In MoI the Style/Layer list is the same thing as the materials list, they are not separate lists.


> OK, could be nice, if this behavoir could be set to material color
> stay material color too.

This is already happening - the Style colors and style names will become material colors and material names in the OBJ file.


> The layer information is saved in two "positions" - obj name
> and obj color.

No, this is not correct - in MoI there is no individual "object color" available at all, there are only colors assigned by style (or by layer as Rhino calls it), and the style name and the object name are separate things, it is not the same name written twice to the OBJ file like you seem to be thinking here.


> But I have objects with different materials at different layers.

Not in MoI you don't - in MoI layers and materials are the same thing.

MoI's system is not as convoluted as Rhino's system so there are some kinds of complex setups that you can do in Rhino (like having things not colored "by layer" and instead colored by individual object settings and stuff like that), which will not map to MoI's system.

It sounds like you've run into some stuff like that.

The nice thing about MoI's system is that it is set up to be more exactly compatible with how materials and names work in mesh files, like as I mentioned previously in an OBJ file there is not anything available in the OBJ structure to have color by other than material, and there is not anything in OBJ files that would allow for setting a "layer assignment" as something different from a "material assignment".

It helps to make for a clean mapping from MoI to OBJ by having things colored in MoI only by their Style assignment and not with all kinds of various other lists and special override properties.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Micha
3396.5 In reply to 3396.4 
Hello Michael,

ok, the material color can't be used, but here a screenshot that show my problem - at Rhino the object has a name and a layer and opened at MoI it lost the object name. Could be nice if a name exist, that the name can be keeped.



Visualisation for Designer and Architects | http://www.simulacrum.de
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
3396.6 In reply to 3396.5 
Hi Micha,

> at Rhino the object has a name and a layer and opened at
> MoI it lost the object name. Could be nice if a name exist,
> that the name can be keeped.

That is supposed to work, and does work in Rhino v3, for example here is a box I created in Rhino v3 and assigned a name:



Then when opening up the file in MoI, that name is assigned like you want:




If you are seeing different results, can you please post a sample 3DM file that does not work?

- Michael

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Micha
3396.7 In reply to 3396.6 
I found the reason for the confusion - it's the script for open rhino documents for meshing. I found the function AssignObjectNamesFromStyles();, set it as comment and it works now. Since I found no rhino script for layer keeping I can keep my object names.

Thanks,
Micha



----------
function AssignObjectNamesFromStyles()
{
// 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);
var name = styles.item(obj.styleIndex).name + '§' + i;

// Replace all spaces with underscore characters, since spaces don't work as
// object names in OBJ files.
obj.name = name.replace( /\s/g, '§' );
}
}

function Convert(FileName)
{
var gd = moi.geometryDatabase;

// Open the file, set 2nd param to true to suppress any save changes prompt.
gd.open( FileName, true );

AssignObjectNamesFromStyles();

moi.view.resetAll();

// Create the output file name by breaking off the file extension and adding 'obj'.

OBJFileName = FileName.substr( 0, FileName.lastIndexOf('.') + 1 ) + 'obj';

// Save out to the output file, passing the option to suppress the UI. You
// add other options separated by semi-colons with no spaces. These
// options are available for controlling the meshing:
// NoUI=true
// Angle=6.0
// Output=ngons | quads | triangles
// MaxLength=
// MaxLengthApplyTo=curved | planes | all
// MinLength=4
// AspectRatio=0.0
// Weld=true
// Display=shadedwithedges | shadednoedges | wireframe
// ExpandedDialog=false

gd.saveAs( OBJFileName, 'Angle=;MinLength=;MaxLength=;AspectRatio=;Weld=true;Output=quads');

// Let's clear out and suppress any save changes prompt again.
gd.fileNew( true );
}

Convert('d:\\Temp\\#moi.3dm');

moi.exit( true ); // Pass true to suppress save changes prompt.

Visualisation for Designer and Architects | http://www.simulacrum.de
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All