在ezdx中,维度是如何工作的

2024-04-28 10:20:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个项目,我需要在一个dxf文件中绘制一些东西。我使用的是dxfwrite,但我需要HATCH函数只能在ezdxf上使用,但我无法想出如何使用ezdxf中的dim函数。有什么想法吗?在

我有定义,但没有明确的例子: https://github.com/mozman/ezdxf/blob/master/ezdxf/modern/dimension.py

已尝试在函数中搜索docstring

import ezdxf

dwg = ezdxf.new('AC1015')  
msp = dwg.modelspace()  
msp.add_aligned_dim?

Tags: 文件项目函数httpsgithubdxf定义绘制
3条回答

我在github上问过类似的问题。这是我得到的答复。在

dxfwrite尺寸可作为附加组件提供ezdxf.addons.dimlines,有关用法,请参见example。在

此加载项没有文档记录。我不想鼓励使用这种伪维度,因为真正的维度支持将出现在ezdxf中。在

那是作者写的。 请参阅对github问题的答复here

ezdxf当前不支持维度。在

在OPs问题中链接到的维度相关代码只是为以后的实现做准备-这(可能)永远不会发生。在

试试这个

import ezdxf
from ezdxf.tools.standards import setup_dimstyle

DIM_TEXT_STYLE = ezdxf.options.default_dimension_text_style

# create a new DXF R2010 drawing, official DXF version name: 'AC1024'
doc = ezdxf.new('R2010',setup=True)  


#create a new dimstyle
setup_dimstyle(doc,
               name='EZDXF1',
               fmt='EZ_MM_0.1_H25_MM',
               blk=ezdxf.ARROWS.closed_filled,
               style=DIM_TEXT_STYLE,
               )

dimstyle = doc.dimstyles.get('EZDXF1')
#keep dim line with text        
dimstyle.dxf.dimtmove=0

msp = doc.modelspace()
points=[(0,0),(20,0),(20,10),(0,10),(0,0)]
#draw rectang
msp.add_lwpolyline(points)
msp.add_aligned_dim(p1=(0, 0), p2=(0, 10),distance=1, dimstyle='EZDXF1')
msp.add_aligned_dim(p1=(0, 10), p2=(20, 10),distance=11, dimstyle='EZDXF1')
msp.add_aligned_dim(p1=(0, 0), p2=(20, 10),distance=1, dimstyle='EZDXF1',text="test")
doc.saveas('dim.dxf')

相关问题 更多 >