Write Mesh and Get Object Instance

Using this code to write e mesh object ( really its called many times so maybe the name
is the problem ?)
when I read in Rhino I get a object instance with the mesh inside instead of a mesh object

What to do ?

void DB_RhinoWriter::AddMeshobject(ON_3dPointArray &pArray)
    	  int vertex_count =pArray.Count();
    	  int face_count=vertex_count/3;
    	  if( ! face_count ) return;

    	  ON_Mesh *mesh = new ON_Mesh( face_count, vertex_count, false, false );

    	  for(int i=0;i< vertex_count;i++ )
    		mesh->SetVertex(i,pArray[i] );

    	  int cnt=0;
    	  for(int i=0;i< vertex_count ; i+=3 )
    		  mesh->SetTriangle( cnt , i ,i+1, i+2  );

    	  if ( mesh->IsValid() )
    			  ON_3dmObjectAttributes attributes;
    			  attributes.m_name = "IxMesh";
    			  attributes.m_layer_index = CurrLayer;
    			  bool bResolveIdAndNameConflicts = true;
    			  Model()->AddModelGeometryComponent(mesh, &attributes, bResolveIdAndNameConflicts);

Hi @gerryark,

Nothing in your code snippet stands out as being incorrect. We might need a small sample that we can run here.

Here are two other mesh writing samples if you need some reference.

– Dale