python - 如何在ezdxf中获取块的大小和位置?
问题描述
我想在现有的 dxf 文件上找到一个块(代表一扇门)并用一条直线替换它(即关上门)。
我的想法是找到插入块的点,然后从该点沿块的较大尺寸画一条线。
为此,我需要找到块的总宽度和高度。我曾尝试使用explode 和virtual_entities 来尝试分析组成块的各个线和多段线,但我最终得到的点甚至与dxf 文件中显示的点都不接近。
我还需要它在 dxf 文件上的确切位置。当我使用 dxf.insert 时,我得到的点与图层上的实际插入点坐标不同。
我正在使用 matplotlib 在绘图上显示实体,这是我尝试过的代码示例:
for insert in msp.query('INSERT'):
insertion_point = insert.dxf.insert
for e in insert.virtual_entities():
if e.dxftype == 'LINE':
a = e.dxf.start
b = e.dxf.end
x = [a[0], b[0]]
y = [a[1], b[1]]
plt.plot(x, y, 'b')
elif e.dxftype == 'LWPOLYLINE':
poly = np.array(list(e.vertices()))
plt.plot(poly[:,0],poly[:,1],'b')
解决方案
推荐阅读
- cleverhans - Cleverhans 加载预训练模型
- pandas - 展平和重命名多索引聚合列
- shell - 当 shell 命令不返回任何内容时,Makefile 失败
- c - 如何使用 tcp/ip 向客户端发送二维数组;我的代码什么也没打印
- fluid - AnyLogic Fluid 动态分配储罐(可视化表示)
- r - 字符向量是由什么组成的?
- javascript - Node.JS/Fetch:请求的资源上不存在“Access-Control-Allow-Origin”标头
- java - FileNotFoundException:对于部署在 Tomcat 中的 Spring Boot 应用程序中的属性文件
- javascript - javascript正则表达式匹配以特定单词结尾的字符串
- django - 如何使 div 大小相同