我需要写DXF绘图镜像文本。我使用python和ezdxf模块。根据文件有一些标志要设置,但我总是得到DXFAttributeError。你知道吗
我尝试使用'text\u generation\u flags':2和'text\u direction':(-1,0,0)
这是我的代码(在没有镜像attempst的情况下运行良好)
def publish_face_no_bolts(poly, label, filename):
t = poly.get_default_transformation()
trans_poly = poly.transform(t)
# trans_poly = trans_poly.make_coordinates_positive()
points = transformation.points_3d_to_2d(trans_poly.poly_points)
points.append(points[0]) # must close polygon
drawing = ezdxf.new(dxfversion='AC1024') # or use the AutoCAD release name ezdxf.new(dxfversion='R2010')
modelspace = drawing.modelspace()
modelspace.add_lwpolyline(points, dxfattribs={'color': 7})
drawing.layers.new('TEXTLAYER', dxfattribs={'color': 1})
# use set_pos() for proper TEXT alignment - the relations between halign, valign, insert and align_point are tricky.
# drawing.styles.new('mirrored', dxfattribs={'text_generation_flags': 2})
# 'text_direction': (0, 1, 0), # write in y direction
drawing.styles.new('mirrored', dxfattribs={ 'text_direction': (-1, 0, 0)})
err, cx, cy = polygon.centroid2d(points)
modelspace.add_text(label, dxfattribs={'layer': 'TEXTLAYER', 'text_direction': (-1, 0, 0), 'height': 4}).set_pos((cx, cy), align='CENTER')
drawing.saveas(filename)
使用哪种旗子以及如何正确设置旗子?你知道吗
我没有使用ezdxf,但是
text_direction
是MTEXT
实体(DXF组11)的一个属性,是有效控制多行文字旋转的另一种方法。你知道吗要镜像一个单行
TEXT
实体,您需要将dxfgroup71设置为2,在简要查看了ezdxf的代码之后,它看起来被实现为text_generation_flag
参数。你知道吗因此,我建议:
相关问题 更多 >
编程相关推荐