Problems loading a dwg-file

Hello,

I have problems loading a dwg-file into Rhino. In CAD Software the “object” has only 4 surfaces/rectangles:

If I load this dwg-file in Rhino I see 5 surfaces/rectangles. There is a bottom:

Here is a test file:
test.dwg (25.2 KB)

Any ideas why? Or what can I do to load the dwg file correcly?

Regards
Mathias

Hi Mathias -

I’ve put this on the list for a closer look by the developer
RH-84362 File IO: DWG Reading Issue
Thanks,
-wim

Hi Mathias,

How was this object created? Basically the object is a little wacko, it should have 4 faces total, one for each side. Your object has 10, explode it to see what I mean.

From what I can tell watching it in the debugger is that all of the sides have 2 faces, one pointing inward and one pointing outward. The top (which is invisible in Rhino) is a single face with 2 identical loops, only the trim directions are opposite. That probably confuses Rhino and is why it isn’t rendered. It looks like the loop on the bottom face is meant to be inner, i.e. a hole, but since it’s the only loop and that wouldn’t make sense, at least for Rhino, it probably changes it to an outer loop and that’s why it is actually seen.

I’m not sure that there’s anything in Rhino to fix, at least that I would know how to handle.

Tim

1 Like

Hello, thanks for your answer.

I’m not the creator of the DWG-File and I can’t give You more information. I know the original file is “very” old and I believe it was created with AutoCAD.

I have some more files from the same supplier with similar problems. That is a real problem for us. Because in the reference software (which is not developed by ourself) the files open correctly. And also in the CAD Software of the supplier it looks fine.

In our Software we can’t open DWG directly so we use Rhino to convert them. Which don’t work for some files.
An other problem is the file size. We have some DWG-files that are ~120KB. After saving as OBJ the file size is 16 MB.
We have done some research, too. As CAD Software we use BricsCAD. BricsCAD can open this files without problems. But BricsCAD can’t save OBJ-Files… But if we use the command “3dconvert” which convert solids to regions/meshes and save this as DWG. These DWG-Files can be opened by Rhino and saved with a much small file size (some KB not MB).

I believe it is a problem in rhino or the handling differs from other CAD Software. That doesn’t have to be wrong. But in our case there are different results. And that’s bad…

Regards
Mathias

Hi Mathias,

Sorry if I’m being dense but, why don’t you just model that in Rhino. Make a box the same size and extract the top and bottom surface.

OBJ is likely to be a bigger file regardless of the source because it is a text file and not binary.

Tim

Hello,

That’s not possible. We receive thousands of files from different suppliers that we want to process automatically.

Regards
Mathias

Thats correct. Best example is a sphere which is defined as X, Y, Z and radius. 4 float values in DWG. Saved as OBJ will convert these values to a lot of meshes. But 120 KB → 16 MB is too much. We can also see a lot of rectangles which could be converted to 2 triangles but will produce thousands of triangles.

Here is an exmple. On the left side You can see a lot more triangles and a missing top plate. This OBJ is saved by Rhino from the original DWG File. On the right side the original DWG file is saved with “3dconvert” as a new DWG and these DWG is also saved by Rhino as OBJ. This variant has less triangles.

Regards
Mathias

1 Like

The .obj mesh may depend on your mesh settings and how you export from Rhino.

@Pannier can you send a couple of the files you are trying to import?

@Helvetosaur I use the following lisp-script for conversion:

def GetOBJSettings():
    e_str = "Geometrie=Polygonnetz "
    e_str += "Zeilenumbruch=CRLF "
    e_str += "RhinoObjektnamenExportieren=ObjektnamenNichtExportieren "
    e_str += "RhinoGruppenOderEbenennamenExportieren=GruppennamenNichtExportieren "
    e_str += "MaterialdefinitionenExportieren=Nein " # Default = Ja
    e_str += "LeerzeichenInUnterstricheUmwandeln=Nein "
    e_str += "AnzeigefarbeFürMaterialVerwenden=Ja "
    e_str += "YOben=Ja "
    e_str += "LangeZeilenUmbrechen=Nein "
    e_str += "Schreibpräzision=4 " # Default = 17 ("Anzahl Nachkommastellen")
    e_str += "PolygonnetztexturkoordinatenExportieren=Ja "
    e_str += "PolygonnetzscheitelpunktnormalenExportieren=Ja "
    e_str += "PolygonnetzscheitelpunktfarbenExportieren=Nein "
    e_str += "OffenePolygonnetzeExportieren=Ja "
    e_str += "PolygonnetzeAlsDreieckeExportieren=Nein "
    e_str += "RenderNetzeVerwenden=Nein "
    e_str += "Scheitelpunktverschweißung=Unverändert "
    e_str += "SubDPolygonnetzerzeugung=AusFläche "
    e_str += "SubDNiveau=1 " # Default = 4
    e_str += "NGonModus=Nichts "
    return e_str

def DWGtoOBJ(filename):
    # Open DWG File
    rs.Command("_-Open " + filename + " _Enter", 1)
    
    # Set export options
    options_str = GetOBJSettings()

    # Export "all" to an OBJ-File
    rs.Command('_SelAll')
    rs.Command('-_Export "' + filename.lower().replace('.dwg', '.obj') + '" ' + options_str + ' _Enter _Enter', True)
    
    # close file without saving
    rs.DocumentModified(False)
    rs.Command("_-New _None",False)

@Gijs That is possible. Can I send by “private” mail and not public to all?

yes, you can send to me by pm, or upload the files here

Thank You very much for Your help.
This settings help reducing the file size (triangle count). This is very good. But there are still some graphic parts that are not loaded/exported correctly. See my first test.dwg from my first post.

If you check this box on export (the equivalent was added to dotnet options and scripted) it should remove at least some of the interior vertices on planar “faces” in OBJ export.

OBJ is fine with polygon boundaries of a single face. Rhino does not like that though. So, if you reimport the same obj file into Rhino it may look like single faces, if ngons were created, but under the hood that face will get triangulated. The interior vertices won’t be there anymore though.