使用dxfwrite或ezdxf在z方向创建dxf文本

时间:2017-02-18 10:40:35

标签: dxf

我想使用dxfwriteezdxf沿(WCS)y方向创建文本,并在(WCS)z方向创建高度。< / p>

使用autocad,我通过设置UCS并输入文本来完成此操作。

如何在dxfwrite或ezdxf(或任何其他python友好库)中进行操作?

dxf.ucs('textucs',xaxis=(0.,1.,0),yaxis=(0.,0.,1.))
lab = dxf.mtext('hello',np.array([0.,0.,.5]),layer='mylay',height=0.3)

不起作用,大概是因为我只创建了UCS,而我没有使用它。

1 个答案:

答案 0 :(得分:1)

定义UCS什么都不做,dxfwrite / ezdxf不是CAD应用程序。

此示例使用ezdxf在YZ平面中写入文本:

import ezdxf

dwg = ezdxf.new('ac1015')
modelspace = dwg.modelspace()
modelspace.add_mtext("This is a text in the YZ-plane",
                     dxfattribs={
                         'width': 12,  # reference rectangle width
                         'text_direction': (0, 1, 0),  # write in y direction
                         'extrusion': (1, 0, 0)  # normal vector of the text plane
                     })

dwg.saveas('mtext_in_yz_plane.dxf')

dxfwrite中的mtext只是一堆TEXT实体,因为MTEXT实体需要DXF13或更高版本。