Script to export drawings to dxf - color error (converts black lines to white)

I have written a c# script that exports a bunch of geometries on assigned layers to separate dxf files for fabrication. Key is to have specifi geos on specific layers with assigned colours.

All works fine, but not one layer that is meant to be black. When i open exported dxf files, all black lines are white. Which is weird, because other layers - like yellow or green ones - work fine.

Does anyone knows why is that?

did you search this forum and check for example the export options ?

you should figure out, wether it is an export problem or an import problem.
Did you have any .dxf from the target Application that allows black ?

if you want to make sure you need to look at the generated .dxf ( recommend a simple one, with one single line) - it is a readable text-file

and the specifications can be found online:

-> check if Rhino writes a proper black
-> if yes it is an import problem and you have to see the Target Application ressources.
-> if no it is an export / Rhino-Problem and you can report a bug here.

And to have others to profit from your problem: please post the results here - including the name of your “target-application” … something like "export dxf from Rhino - import in “my target application” …

hope that helps -best -tom

1 Like

Check this setting in your export scheme:

AutoCAD Index Color (ACI) 7 is imported as black when Value (brightness) of the Rhino viewport background color is 128 or greater. Otherwise, it is imported as white.

I think the same thing is true for Export. @KelvinC - can a description of what this setting does be added to the Help?

1 Like

What application do you use to open the dwg file? What if you change the viewport background color in the application to white? Does black stay as black?

I think it is not the same. I did some tests with Rhino only. When Color by AutoCAD index is selected, Rhino exports both white and black as ACI 7 regardless of the viewport background color. @lowell, can you confirm? Thanks.

Try to change black RGB (0, 0, 0) to (0, 0, 1) in Rhino. I guess the target application will not change this color.

This is almost for sure because of the treatment of color 7 in Acad.
I can’t follow this discussion very well so I’ll back up a little.

  • In Acad, Color 7 is displayed as black when the viewport background is light and as white when the background is dark. Rhino has no such feature.

If you write Acad files with the Rhino DWG/DXF writer using color by AcadColorIndex, both black, color RGB(0,0,0) and white, RGB(255,255,255) in Rhino will be written as ACI 7. That will display as either black or white in Acad, depending on your background color.

If you want to export to Acad files and really control the black/white color, you can use RGB color definitions.


That’s what I meant actually… Maybe that note can be added to the Help under DWG/DXF Export Options?

Yes, updated in two places. Thanks.


Hi, Mit
I wonder, in my rhino there are 10 subjects that have been grouped individually.
Is there any script that exports those 10 objects into 10 .dxf files?

Does this script help? (1.3 KB)

OK, have a go with this one… (2.8 KB)

1 Like