Closed dmh126 closed 3 years ago
The true color value is a bit coded integer, use ... , 'true_color': ezdxf.rgb2int((r, g, b))
to calculate this integer value from a (r, g, b)
tuple or use the common graphic entity property rgb
to set the true color value: mesh.rgb = (r, g, b)
. For green (3) the true color value would be (0, 255, 0)
.
But the visual representation also depends on some other parameters which are not well documented in the DXF reference (Visualstyle, Materials) and on the capabilities of the viewer application. It is difficult to create a particular look, especially if you are not an AutoCAD expert and I am not one. I see the DXF file format as data exchange format and nothing else, there exist better documented file formats to represent entire scenes including materials.
I tried to set:
mesh.rgb = (0,255,0)
but still got the same result. Even 2d view has no color if I don't set dxfattribs.
I create dxf files from scratch by creating blocks and adding Mesh objects to blocks. I tried to set color to layer and to mesh directly. I use Forge BIM360 viewer to visualize them, but it displays correct colors only in 2D view. Here are some screenshots:
I'm not really sure if this is related to Forge or there is a different approach to set colors using ezdxf. My code sample:
I also tried with layers but got the same effect:
doc.layers.new(name='green', dxfattribs={'color': 3, 'true_color': 3})
Is there any better method to do that?