Set the layer color as the print color. Exporting to .dwg

I usually export my drawings to .dwg and find annoying the fact that i can’t reprint them with the same printing colors, as they aren’t transmitted during the export. A quick workaround would consist in changing the layer colors to those set as printing colors. I’m sure thats something that it can be easily achieved in python, but I can’t figure it out, as I’m a begginer in the subject. The code structure would be something like this:

  def ColorLayerAsPrint ():

          myLayers=rs.LayerNames()
          myPrintColors= rs.LayerPrintColor()

    for obj in myLayers:
    
         rs.LayerColor (myLayers, (myPrintColors))

  ColorLayerAsPrint ()

It doesn’t work so far. What is wrong in the code? Is there an easier approach which doesn’t involve changing the layer colors? Any help provided will be useful. Thank you in advance

Hi @allucanteat,

Can you run Rhino’s SystemInfo command and post the results?

Do you have a .3dm file that exhibits the above behavior when saved to .dwg?

What version of AutoCAD DWG are you saving to? What Export Scheme are you using?

Try this:

import rhinoscriptsyntax as rs
    
def ColorLayerAsPrint():
    layers = rs.LayerNames()
    for layer in layers:
        print_color = rs.LayerPrintColor(layer)
        rs.LayerColor(layer, print_color)

if __name__ == "__main__":
    ColorLayerAsPrint()

Thanks,

– Dale

1 Like

System Info:

Rhino 6 SR35 2021-8-10 (Rhino 6, 6.35.21222.17001, Git hash:master @ 073ac7b225c67348731c6597127b9410126c3139)
License type: Educacional, build 2021-08-10
License details: Cloud Zoo. In use by: José Manuel Parrilla López-Brea ()

Windows 7 SP1 (Physical RAM: 16Gb)
Machine name: USUARIO-PC

Computer platform: DESKTOP

Standard graphics configuration.
Primary display: NVIDIA GeForce GTX 960 (NVidia) Memory: 2GB, Driver date: 9-13-2021 (M-D-Y).
> External USB display device with 4 adapter port(s)
- Windows Main Display attached to adapter port #0
Primary OpenGL: NVIDIA GeForce GTX 960/PCIe/SSE2: NVIDIA Corporation. OpenGL Ver: 4.6.0 NVIDIA 472.12
> No graphics device is being used for OpenGL

Secondary graphics devices.
Intel(R) HD Graphics 4600 (Intel) Memory: 2GB, Driver date: 3-30-2014 (M-D-Y).
> External USB display device with 3 adapter port(s)
- Secondary monitor attached to adapter port #0

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On

Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 9-13-2021
Driver Version: 30.0.14.7212
Maximum Texture size: 16384 x 16384
Z-Buffer depth: 24 bits
Maximum Viewport size: 16384 x 16384
Total Video Memory: 2 GB

Rhino plugins
C:\Program Files\Rhino 6\Plug-ins\Commands.rhp “Commands” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\WebBrowser.rhp “WebBrowser”
C:\Program Files\Rhino 6\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 6\Plug-ins\RPC.rhp “RPC”
C:\Program Files\Rhino 6\Plug-ins\RhinoBonusTools.rhp “Rhino Bonus Tools”
C:\Program Files\Rhino 6\Plug-ins\export_ACAD.rhp “AutoCAD file export : export_ACAD”
C:\Program Files\Rhino 6\Plug-ins\AnimationTools.rhp “AnimationTools”
C:\Program Files\Rhino 6\Plug-ins\RhinoRender.rhp “Rhino Render”
C:\Program Files\Rhino 6\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 6\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 6\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\RhinoCycles.rhp “RhinoCycles” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Chaos Group\V-Ray\V-Ray for Rhinoceros\V6\VRayForRhino.rhp “V-Ray for Rhino”
C:\Program Files\Rhino 6\Plug-ins\Displacement.rhp “Displacement”
C:\Program Files\Rhino 6\Plug-ins\Calc.rhp “Calc”
C:\Program Files\Rhino 6\Plug-ins\NamedPositions.rhp “Named Position”
C:\Users\Usuario\AppData\Roaming\McNeel\Rhinoceros\packages\6.0\PanelingTools\2018.12.17+906\PanelingTools.rhp “PanelingTools”

Rhino screenshot 1:

Autocad screenshot 2:


*Version: 2018. Color 12 is red

Export Scheme


*It doesn’t make a difference if ‘Color by Autocad Index’ is marked

Results
The script works perfect! Thank you! Perhaps this problem was corrected in later versions. I should update

Seems to work in Rhino 8. You might consider download an evaluation version and testing.

– Dale

1 Like