本文整理汇总了Python中Part.Wire方法的典型用法代码示例。如果您正苦于以下问题:Python Part.Wire方法的具体用法?Python Part.Wire怎么用?Python Part.Wire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.Wire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shape
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def shape(self):
proj1 = self.shape1.toNurbs().extrude(self.dir1)
proj2 = self.shape2.toNurbs().extrude(self.dir2)
curves = list()
for f1 in proj1.Faces:
for f2 in proj2.Faces:
curves += f1.Surface.intersectSS(f2.Surface)
intersect = [c.toShape() for c in curves]
edges = []
for sh in intersect:
if isinstance(sh, Part.Edge) and sh.Length > 1e-7:
edges.append(sh)
se = Part.sortEdges(edges)
wires = []
for el in se:
wires.append(Part.Wire(el))
return Part.Compound(wires)
示例2: execute
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def execute(self, obj):
#curvesWB = FreeCADGui.activeWorkbench()
proptype = obj.getTypeIdOfProperty("Profile")
if proptype == 'App::PropertyLink':
sh = obj.Profile.Shape.copy()
mat = obj.Profile.Shape.Placement.toMatrix()
obj.Shape = sh.transformGeometry(mat)
elif proptype == 'App::PropertyLinkSubList':
edges = self.getEdgeList( obj, "Profile")
#vert = self.getVertex( obj, "Location")
if edges:
w = Part.Wire(Part.__sortEdges__(edges))
if w:
obj.Shape = w
else:
FreeCAD.Console.PrintError("\nFailed to build wire\n")
else:
FreeCAD.Console.PrintError("\nFailed to extract edges\n")
示例3: ancestors
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def ancestors(shape, sub):
'''list_of_shapes = ancestors(shape, sub)
Returns the closest ancestors of "sub" in "shape"'''
def cleanup(shape):
s = str(shape)
ss = s.split()[0]
return ss.split('<')[1]
shd = (Part.Vertex,
Part.Edge,
Part.Wire,
Part.Face,
Part.Shell,
Part.Solid,
Part.CompSolid,
Part.Compound)
for i in range(len(shd)-1):
if isinstance(sub, shd[i]):
for j in range(i+1,len(shd)):
manc = shape.ancestorsOfType(sub, shd[j])
if manc:
print("{} belongs to {} {}.".format(cleanup(sub), len(manc), cleanup(manc[0])))
return manc
示例4: execute
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def execute(self, fp):
base=Part.Face(Part.Wire(Part.makeCircle(fp.D/2)))
if fp.d>0:
base=base.cut(Part.Face(Part.Wire(Part.makeCircle(fp.d/2))))
if fp.n>0:
hole=Part.Face(Part.Wire(Part.makeCircle(fp.f/2,FreeCAD.Vector(fp.df/2,0,0),FreeCAD.Vector(0,0,1))))
hole.rotate(FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1),360.0/fp.n/2)
for i in list(range(fp.n)):
base=base.cut(hole)
hole.rotate(FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1),360.0/fp.n)
flange = base.extrude(FreeCAD.Vector(0,0,fp.t))
try: # Flange2: raised-face and welding-neck
if fp.trf>0 and fp.drf>0:
rf=Part.makeCylinder(fp.drf/2,fp.trf,vO,vZ*-1).cut(Part.makeCylinder(fp.d/2,fp.trf,vO,vZ*-1))
flange=flange.fuse(rf)
if fp.dwn>0 and fp.twn>0 and fp.ODp>0:
wn=Part.makeCone(fp.dwn/2,fp.ODp/2,fp.twn,vZ*float(fp.t)).cut(Part.makeCylinder(fp.d/2,fp.twn,vZ*float(fp.t)))
flange=flange.fuse(wn)
except:
pass
fp.Shape = flange
fp.Ports=[FreeCAD.Vector(),FreeCAD.Vector(0,0,float(fp.t))]
super(Flange,self).execute(fp) # perform common operations
示例5: getBase
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def getBase(self):
if self.combo.currentText()!="<new>":
pl=FreeCAD.ActiveDocument.getObjectsByLabel(self.combo.currentText())[0]
sel=FreeCADGui.Selection.getSelection()
if sel:
base=sel[0]
isWire=hasattr(base,'Shape') and base.Shape.Edges #type(base.Shape)==Part.Wire
isSketch=hasattr(base,'TypeId') and base.TypeId=='Sketcher::SketchObject'
if isWire or isSketch:
FreeCAD.activeDocument().openTransaction('Assign Base')
pl.Base=base
if isWire:
pipeCmd.drawAsCenterLine(pl.Base)
pipeCmd.moveToPyLi(pl.Base,self.combo.currentText())
FreeCAD.activeDocument().commitTransaction()
else:
FreeCAD.Console.PrintError('Not valid Base: select a Wire or a Sketch.\n')
else:
pl.Base=None
FreeCAD.Console.PrintWarning(pl.Label+'-> deleted Base\n')
else:
FreeCAD.Console.PrintError('Please choose or create a PypeLine first\n')
示例6: make_oval
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def make_oval(size,params=None):
_ = params
if size.x == size.y:
return make_circle(size)
if size.x < size.y:
r = size.x*0.5
size.y -= size.x
s = ((0,0.5),(-0.5,0.5),(-0.5,-0.5),(0,-0.5),(0.5,-0.5),(0.5,0.5))
a = (0,180,180,360)
else:
r = size.y*0.5
size.x -= size.y
s = ((-0.5,0),(-0.5,-0.5),(0.5,-0.5),(0.5,0),(0.5,0.5),(-0.5,0.5))
a = (90,270,-90,-270)
pts = [product(size,Vector(*v)) for v in s]
return Part.Wire([
Part.makeCircle(r,pts[0],Vector(0,0,1),a[0],a[1]),
Part.makeLine(pts[1],pts[2]),
Part.makeCircle(r,pts[3],Vector(0,0,1),a[2],a[3]),
Part.makeLine(pts[4],pts[5])])
示例7: _makeCustomPad
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def _makeCustomPad(self, params):
wires = []
for key in params.primitives:
wire,width = makePrimitve(key, getattr(params.primitives, key))
if not width:
if isinstance(wire, Part.Edge):
wire = Part.Wire(wire)
wires.append(wire)
else:
wire = Path.Area(Accuracy=self.arc_fit_accuracy,Thicken=wire.isClosed(),
Offset=width*0.5).add(wire).getShape()
wires += wire.Wires
if not wires:
return
if len(wires) == 1:
return wires[0]
return Part.makeCompound(wires)
示例8: drawLine
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def drawLine( self, pt1, pt2, name='aLine', width=3 ):
global taskUI
if pt1!=pt2:
line = Part.makeLine( pt1, pt2 )
wire = App.ActiveDocument.addObject('Part::FeaturePython', name)
wire.ViewObject.Proxy = setCustomIcon(wire, taskUI.lineIcon )
wire.Shape = Part.Wire(line)
wire.ViewObject.LineWidth = width
wire.ViewObject.LineColor = ( 1.0, 1.0, 1.0 )
wire.ViewObject.PointSize = 10
wire.ViewObject.PointColor= ( 0.0, 0.0, 1.0 )
self.addToDims(wire)
else:
point = App.ActiveDocument.addObject('Part::FeaturePython', 'aPoint')
point.ViewObject.Proxy = setCustomIcon(point, taskUI.pointIcon )
point.Shape = Part.Vertex(Part.Point( pt1 ))
point.ViewObject.PointSize = 10
point.ViewObject.PointColor= ( 0.0, 0.0, 1.0 )
self.addToDims(point)
示例9: testFuse
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def testFuse(self):
"""
Tests fusing one face to another.
"""
# Face 1
edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
wire1 = Part.Wire([edge1,edge2,edge3,edge4])
face1 = Part.Face(wire1)
cqFace1 = Face(face1)
# Face 2 (face to cut out of face 1)
edge1 = Part.makeCircle(4.0)
wire1 = Part.Wire([edge1])
face2 = Part.Face(wire1)
cqFace2 = Face(face2)
# Face resulting from fuse
cqFace3 = cqFace1.fuse(cqFace2)
self.assertEquals(len(cqFace3.Faces()), 3)
self.assertEquals(len(cqFace3.Edges()), 8)
示例10: testIntersect
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def testIntersect(self):
"""
Tests finding the intersection of two faces.
"""
# Face 1
edge1 = Part.makeLine((0, 0, 0), (0, 10, 0))
edge2 = Part.makeLine((0, 10, 0), (10, 10, 0))
edge3 = Part.makeLine((10, 10, 0), (10, 0, 0))
edge4 = Part.makeLine((10, 0, 0), (0, 0, 0))
wire1 = Part.Wire([edge1,edge2,edge3,edge4])
face1 = Part.Face(wire1)
cqFace1 = Face(face1)
# Face 2 (face to cut out of face 1)
edge1 = Part.makeCircle(4.0)
wire1 = Part.Wire([edge1])
face2 = Part.Face(wire1)
cqFace2 = Face(face2)
# Face resulting from the intersection
cqFace3 = cqFace1.intersect(cqFace2)
self.assertEquals(len(cqFace3.Faces()), 1)
self.assertEquals(len(cqFace3.Edges()), 3)
示例11: testWireMakeHelixDefault
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def testWireMakeHelixDefault(self):
(pitch, height, radius) = (1., 5., 2.)
wire = Wire.makeHelix(pitch=pitch, height=height, radius=radius)
edge = wire.Edges()[0]
# Assert: helix length is correct
# expectation, default is a cylindrical helix
helix_horiz = (((2 * pi) * radius) * (height / pitch))
helix_vert = height
self.assertAlmostEqual(edge.Length(), sqrt(helix_horiz**2 + helix_vert**2), 4)
# Assert: bounding box is accurate
# mainly checking that helix is in the positive Z direction.
# not happy with the accuracy of BoundingBox (see places=2 below), but that's out of cadquery's scope
bb = edge.BoundingBox()
self.assertTupleAlmostEquals((bb.xmin, bb.xmax), (-radius, radius), 2)
self.assertTupleAlmostEquals((bb.ymin, bb.ymax), (-radius, radius), 2)
self.assertTupleAlmostEquals((bb.zmin, bb.zmax), (0, height), 3)
示例12: geomType
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def geomType(self):
"""
Gets the underlying geometry type
:return: a string according to the geometry type.
Implementations can return any values desired, but the
values the user uses in type filters should correspond to these.
As an example, if a user does::
CQ(object).faces("%mytype")
The expectation is that the geomType attribute will return 'mytype'
The return values depend on the type of the shape:
Vertex: always 'Vertex'
Edge: LINE, ARC, CIRCLE, SPLINE
Face: PLANE, SPHERE, CONE
Solid: 'Solid'
Shell: 'Shell'
Compound: 'Compound'
Wire: 'Wire'
"""
return self.wrapped.ShapeType
示例13: smMakeReliefFace
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def smMakeReliefFace(edge, dir, gap, reliefW, reliefD, reliefType, op=''):
p1 = edge.valueAt(edge.FirstParameter + gap)
p2 = edge.valueAt(edge.FirstParameter + gap + reliefW )
if reliefType == "Round" and reliefD > reliefW :
p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * (reliefD-reliefW/2)
p34 = edge.valueAt(edge.FirstParameter + gap + reliefW/2) + dir.normalize() * reliefD
p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * (reliefD-reliefW/2)
e1 = Part.makeLine(p1, p2)
e2 = Part.makeLine(p2, p3)
e3 = Part.Arc(p3, p34, p4).toShape()
e4 = Part.makeLine(p4, p1)
else :
p3 = edge.valueAt(edge.FirstParameter + gap + reliefW) + dir.normalize() * reliefD
p4 = edge.valueAt(edge.FirstParameter + gap) + dir.normalize() * reliefD
e1 = Part.makeLine(p1, p2)
e2 = Part.makeLine(p2, p3)
e3 = Part.makeLine(p3, p4)
e4 = Part.makeLine(p4, p1)
w = Part.Wire([e1,e2,e3,e4])
face = Part.Face(w)
if hasattr(face, 'mapShapes'):
face.mapShapes([(edge,face)],[],op)
return face
示例14: make_cross_box
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def make_cross_box(length, width, height, node_type, node_thickness):
half_length = length / 2.0
p1 = FreeCAD.Vector(half_length, 0, 0)
p2 = FreeCAD.Vector(-half_length, 0, 0)
p3 = FreeCAD.Vector(-half_length, 0, -height)
p4 = FreeCAD.Vector(half_length, 0, -height)
l1 = Part.makeLine(p1, p2)
l2 = Part.makeLine(p2, p3)
l3 = Part.makeLine(p3, p4)
l4 = Part.makeLine(p4, p1)
wire = Part.Wire([l1,l2,l3,l4])
face = Part.Face(wire)
face.translate(FreeCAD.Vector(0, -width / 2.0, 0))
part = face.extrude(FreeCAD.Vector(0, width, 0))
return part
示例15: make_node_xz
# 需要导入模块: import Part [as 别名]
# 或者: from Part import Wire [as 别名]
def make_node_xz(width, height, thickness, x_positive = True):
p1 = FreeCAD.Vector(0., -thickness/2.0, height / 2.0)
p2 = FreeCAD.Vector(0., -thickness/2.0, -height / 2.0)
if x_positive is True:
pa = FreeCAD.Vector(width, -thickness/2.0, 0.)
else:
pa = FreeCAD.Vector(-width, -thickness/2.0, 0.)
l1 = Part.makeLine(p1, p2)
a2 = Part.Arc(p2, pa, p1).toShape()
wire = Part.Wire([l1, a2])
face = Part.Face(wire)
node = face.extrude(FreeCAD.Vector(0, thickness, 0))
return node