本文整理汇总了Python中Part.makeWireString方法的典型用法代码示例。如果您正苦于以下问题:Python Part.makeWireString方法的具体用法?Python Part.makeWireString怎么用?Python Part.makeWireString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.makeWireString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: text
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeWireString [as 别名]
def text (string, fontFile='/usr/share/fonts/TTF/FreeMono.ttf', height=100, returnWires = False):
"""returns a list of faces corresponding to each character in a string that trace text letters
maybe the default fontdir and font variables have only been tested in Arch Linux"""
wires = Part.makeWireString(string, fontFile, height)
if returnWires:
# flat_wires = []
# for letter in wires:
# for wire in letter:
# flat_wires.append(wire)
flat_wires = [item for sublist in wires for item in sublist]
return flat_wires
else:
faces = []
for letter in wires:
faces.append(Part.Face(letter))
return faces
示例2: execute
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeWireString [as 别名]
def execute(self, obj):
import Part
pl = obj.Placement
if obj.Width.Value and obj.Height.Value:
l2 = obj.Width.Value/2
w2 = obj.Height.Value/2
v1 = Vector(-l2,-w2,0)
v2 = Vector(l2,-w2,0)
v3 = Vector(l2,w2,0)
v4 = Vector(-l2,w2,0)
base = Part.makePolygon([v1,v2,v3,v4,v1])
self.sheetborder = base
wires = []
area = obj.Width.Value * obj.Height.Value
subarea = 0
for v in obj.Group:
if v.isDerivedFrom("Part::Feature"):
wires.extend(v.Shape.Wires)
if Draft.getType(v) == "PanelCut":
if v.Source:
subarea += v.Source.Area.Value
else:
for w in v.Shape.Wires:
if w.isClosed():
f = Part.Face(w)
subarea += f.Area
if wires:
base = Part.Compound([base]+wires)
if obj.FontFile and obj.TagText and obj.TagSize.Value:
chars = []
for char in Part.makeWireString(obj.TagText,obj.FontFile,obj.TagSize.Value,0):
chars.extend(char)
textshape = Part.Compound(chars)
textshape.translate(obj.TagPosition)
textshape.rotate(textshape.BoundBox.Center,Vector(0,0,1),obj.TagRotation.Value)
self.sheettag = textshape
base = Part.Compound([base,textshape])
obj.Shape = base
obj.Placement = pl
obj.FillRatio = int((subarea/area)*100)
示例3: len
# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeWireString [as 别名]
#String = 'AVWAIXA.V' # kerning
String = 'FreeCAD' # ASCII
#FontPath = '/usr/share/fonts/truetype/msttcorefonts/'
#FontName = 'Times_New_Roman_Italic.ttf'
FontPath = '/usr/share/fonts/truetype/msttcorefonts/'
FontName = 'Arial.ttf'
#FontName = 'NOTArial.ttf' # font file not found error
#FontPath = '/usr/share/fonts/truetype/msttcorefonts/'
#FontName = 'ariali.ttf' #symlink to ttf
#FontPath = '/usr/share/fonts/truetype/'
#FontName = 'Peterbuilt.ttf' # overlapping script font
#FontPath = '/usr/share/fonts/truetype/'
#FontName = 'dyspepsia.ttf' # overlapping script font # :)
Height = 2000 # out string height FCunits
Track = 0 # intercharacter spacing
print "testWire.py input String contains ", len(String), " characters."
s = Part.makeWireString(String,FontPath,FontName,Height,Track)
print "returned from makeWireString"
print "testWire.py output contains ", len(s), " WireChars."
for char in s:
for contour in char:
Part.show(contour)
print "testWire ended."