-
Hello there! I'm new to ezdxf and I'm not sure that I understand all concepts from documentation correctly, So I have several questions:
import sys
import matplotlib.pyplot as plt
from ezdxf import recover
from ezdxf.addons.drawing import RenderContext, Frontend
from ezdxf.addons.drawing.matplotlib import MatplotlibBackend
# Safe loading procedure (requires ezdxf v0.14):
try:
doc, auditor = recover.readfile('mod_draw.dxf')
except IOError:
print(f'Not a DXF file or a generic I/O error.')
sys.exit(1)
except ezdxf.DXFStructureError:
print(f'Invalid or corrupted DXF file.')
sys.exit(2)
# The auditor.errors attribute stores severe errors,
# which may raise exceptions when rendering.
if not auditor.has_errors:
fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
ctx = RenderContext(doc)
out = MatplotlibBackend(ax)
modelspace1 = doc.modelspace()
Frontend(ctx, out).draw_layout(modelspace1, finalize=True) But I want to plot only purple lines that belong to "purple_layer" layer. So I decide to change the plotting line from this
to this
But I get an error. Can you please tell me what I'm doing wrong?
how to get a new modelspace with half view of the original dxf, given that the x-axis runs in the middle? Maybe there is some simple way to do this with ezdxf
how can I access and change the coordinates of specific lines? For example, I want to move the top of the purple triangle 20 mm to the left. To do this, I need to refer to the x-coordinate of two specific lines (assuming that half of the view is shown) and change its value. How do I do this? How do I know that I am changing the coordinate of the line I want? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Beta Was this translation helpful? Give feedback.
RenderContext.set_layers_state(layers, state)
. Here 'state' means 'visible'1a. you can use
Frontend.draw_entities
if you want to draw a collection of entities such as the result of a query. Look at the source code fordraw_layout
to see what other things you might want to set if you usedraw_entities