-
New people want to ask, how to export dxf corresponding coordinate range into a picture according to a coordinate range, the following is my example code, always export the entire dxf file into a picture import ezdxf 定义坐标范围x_min, y_min = 789970.2299576874, 12005.03740519899 读取 DXF 文件doc = ezdxf.readfile('X-E6-incision-test.DXF') print('读取完毕!') 创建 matplotlib 图形fig, ax = plt.subplots(figsize=(200, 200)) # 设置图形大小以控制像素 print('创建 matplotlib 图形') 设置坐标范围ax.set_xlim(x_min, x_max) print('设置坐标范围') 设置渲染上下文和后端ctx = RenderContext(doc) print('设置渲染上下文和后端') 使用 Frontend 将模型空间渲染到 matplotlib 图形frontend = Frontend(ctx, out, config) print('使用 Frontend 将模型空间渲染到 matplotlib 图形') 保存为图片fig.savefig('output.png', dpi=1000, bbox_inches='tight') # 调整 dpi 和 bbox_inches print("图片保存成功!") |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
see FAQ: #550
|
Beta Was this translation helpful? Give feedback.
see FAQ: #550