Simplified geometries in OBJ exported files

Hi All,

in a rhino script, I do batch export of objects into obj files.

Some geometries are over simplified.
Left shows object in Rhino, Right is exported OBJ file :

I saw that there are several export options (detailed and advanced) for OBJ format.
Should I change some of them to get same geometries in exported files ?

Best regards,
Frédéric.

@Frederic_Trastour,

try to increase the value for Significant Digits to 16 doing a manual *.obj export. If this fixes it, change it in your batch export script.

c.

Thanks Clement,

I already use :
sOpt = sOpt & " _YUp=_No "
sOpt = sOpt & " _WritePrecision=17 "

Coordinates look like :
v 736651.04299999995 7025062.5640000002 82.507999999999996

My objects are in meters; I suppose precision is suffisant :slightly_smiling:

Note that I get same uggly geometries with all formats.
I’m wondering if the problem related to the output format…

Any other idea ?

Regards,
Frédéric.

Can you post parts of your mesh ? If it is not a mesh but a nurbs object, please show the mesh settings you use.

If your object is in meters, seeing the coordinate it seems either very large or very far from the origin. What happens if you move it closer to the orgin and then export ?

btw. 15 seems to be the maximum digits i can export.

c.

Clement,

Can you post parts of your mesh ?

Yes I’ll post the mesh ASAP.

If it is not a mesh but a nurbs object, please show the mesh settings you use.

Where are these setting ? I quite new to Rhino and objects are generated by the RhinoCity plugin.

If your object is in meters, seeing the coordinate it seems either very large or very far from the origin.

Object is in meters but in cartographic coordinates (EPSG 2154)- they tend to be effectively very large in X&Y.

What happens if you move it closer to the orgin and then export ?

I’ll try that

Regards,
Fred.

Hi Fred,

the obj export settings usually pop up if you export manually. In case of a nurbs object, there are options to define the mesh density settings. If you export your obj geometry via a batch export script, you might control them from there as well. Lets first check the data itself.

c.

Clement,

you were right : It seems that the problem is related my coordinates ranges. If I move the model to 0,0 in X,Y, it works fine.

In a post processing chain, this is what I do ( I recenter each output model, creating a 3D GIS point file allowing to place model in the final 3D scene).

Now, I have to figure out how to - in the script - recenter each model before saving - and writing out a text file (for example) allowing to place them afterward.

Fred.

Hi Fred, ok. I guess you can just select the objects, find their boundingbox and use the bottom center of that box as first point. Then use rs.MoveObjects to move them to the World origin. below is an example script.

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
    
def MoveToOrigin():
    # select surfaces, polysurfaces and meshes
    obj_ids = rs.ObjectsByType(8+16+32, True, 1)
    if not obj_ids: return
    
    # get their bounding box
    bb = rs.BoundingBox(obj_ids, None, True)
    
    # get boundingbox center at bottom face
    center = Rhino.Geometry.Point3d.Unset
    center.Interpolate(bb[0], bb[2], 0.5)
    
    # move from center to origin
    translation = Rhino.Geometry.Plane.WorldXY.Origin - center
    rs.MoveObjects(obj_ids, translation)
    
    # do the export
    
if __name__=="__main__":
    MoveToOrigin()

you can try this by pasting in the python script editor. (_EditPythonScript)

c.

Clement,

thanks for your support.

I modified my script this morning to do something similar (create a moved copy, export, delete copy).

I join the script which may be useful for other people.

Kr,
Fred.

ExportOBJ.rvb (6.2 KB)