Skip to content

Create images of different entities/layers #787

Answered by mozman
f0rme asked this question in Q&A
Discussion options

You must be logged in to vote

You have to create layer table entries, to switch layers on and off. Despite the fact that the DXF format does not require a layer table entry to be valid, you should always create layer table entries for all layers you plan to use.

Example shapes.dxf: each shape including the text has a different layer

shapes.zip

The following script...

import ezdxf
from ezdxf.addons.drawing.matplotlib import qsave

doc = ezdxf.readfile("shapes.dxf")
msp = doc.modelspace()

layer_names = ["Shape 1", "Shape 2", "Shape 3"]

for current_layer_name in layer_names:
    for name in layer_names:
        layer = doc.layers.get(name)
        if layer.dxf.name == current_layer_name:
            layer.on()
        e…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@f0rme
Comment options

@mozman
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by f0rme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants