Rhino8 Export Dwg

I have found an issue where even if I set the DWG file to be exported as a solid, when I select the Rhino Space solid, the exported object is still a line segment. However, when I set it as a mesh, everything is normal; I’m not sure if this is a new bug, can you help me check my Python code? May I have overlooked something?

import Rhino
import scriptcontext as sc

import os


temp_doc = Rhino.RhinoDoc.CreateHeadless(None)
wait_export_file = Rhino.FileIO.File3dm.Read(Import_File)

for obj in wait_export_file.Objects:
    temp_doc.Objects.Add(obj.Geometry)


file_name, file_extension = os.path.splitext(Import_File)
output_filepath = file_name + '.dwg'



options = Rhino.FileIO.FileDwgWriteOptions()

options.Version = Rhino.FileIO.FileDwgWriteOptions.AutocadVersion.Acad2007
options.Flatten = 0

options.ExportSurfacesAs = Rhino.FileIO.FileDwgWriteOptions.ExportSurfaceMode.Solids
options.ExportMeshesAs = Rhino.FileIO.FileDwgWriteOptions.ExportMeshMode.Meshes



Rhino.FileIO.FileDwg.Write(output_filepath, temp_doc, options)


Hi Niko,

I think there is a bug. I’m looking into it now.

Tim

A fix is in the works. See https://mcneel.myjetbrains.com/youtrack/issue/RH-84634 to track progress.

Hi Tim! I’m thrilled to be part of the code repair process and to see the progress being made. Could you let me know approximately when we can expect the latest Rhino 8 version for our follow-up code testing?

Hi Niko -

RH-84634 is currently “Needs Testing” with a fix in 8.14. Rhino 8.13 should become the stable Service Release next week, at which point a first release candidate of 8.14 will also become publicly available.
-wim

Hi Niko & Wim,

Because the change was trivial, and I was very confident in it, I actually merged it into 8.13. I plan on testing it today. So, unless there are issues (seriously doubt there will be), it should be in the build released this coming Tuesday, November 12, 2024.

Tim

RH-84634 is fixed in Rhino 8 Service Release 13

hi @tim. I tried the same code that @Niko posted above but in my case the imported .3dm file has text on it. The resulting exported .dwg has errors and does not contain the text. Is that a bug, or am I missing something?

Attached the test.3dm
test.3dm (35.8 KB)

Hi David,

It’s definitely not related to the bug that was fixed here.

I tried opening your model and adding a cylinder. Then I ran the test command TestExportWithOptions (you have to cut and paste or type it out completely, it will not autocomplete). That command is currently set up to test this solid bug. When I open your file in acad I see both the cylinder and the text. So, I guess I need more details if I’m going to have a chance at repeating this.

Tim

Hi @tim.

It does work with the command, it also works if I manuall export/import, but not programatically.

Can you try replicating this error by running the code?

import Rhino
import scriptcontext as sc

import os

Import_File =  r"C:\test.3dm"

temp_doc = Rhino.RhinoDoc.CreateHeadless(None)
wait_export_file = Rhino.FileIO.File3dm.Read(Import_File)

for obj in wait_export_file.Objects:
    temp_doc.Objects.Add(obj.Geometry)


file_name, file_extension = os.path.splitext(Import_File)
output_filepath = file_name + '.dwg'

options = Rhino.FileIO.FileDwgWriteOptions()

options.Version = Rhino.FileIO.FileDwgWriteOptions.AutocadVersion.Acad2007
options.Flatten = 0

options.ExportSurfacesAs = Rhino.FileIO.FileDwgWriteOptions.ExportSurfaceMode.Solids
options.ExportMeshesAs = Rhino.FileIO.FileDwgWriteOptions.ExportMeshMode.Meshes

Rhino.FileIO.FileDwg.Write(output_filepath, temp_doc, options)

you would need to put the test file that I sent in C: and run that code in the Python editor. The resulting test.dwg file that I get is corrupted and empty. Not sure if it’s that’s a bug or I’m something is missing on my end to make the text export work.

David -

I was able to recreate this and a couple YT items fell out of it. We will take a closer look.

1 Like

Thanks @scottd looking forward to hearing back from you

@scottd any updates on this one?

Hey David,
Happy new year; hope things are well.

The text is failing to be added because there is no dimension style in the new document that matches what the annotation is using.

Instead of reading into a File3dm and transferring to a headless doc I would recommend just reading directly into the headless doc

temp_doc = Rhino.RhinoDoc.OpenHeadless(Import_File)

1 Like

RH-85272 is fixed in Rhino 8 Service Release 16 Release Candidate

1 Like

Many thanks for the tip @stevebaer! (late) happy new year to you too, and to all the mcneel team. Hope to see you guys soon.

1 Like