本文整理匯總了Python中Part.makeCircle方法的典型用法代碼示例。如果您正苦於以下問題:Python Part.makeCircle方法的具體用法?Python Part.makeCircle怎麽用?Python Part.makeCircle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Part
的用法示例。
在下文中一共展示了Part.makeCircle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: execute
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def execute(self, obj):
debug("\n* paramVector : execute *\n")
if not hasattr(obj,"Origin"):
v0 = FreeCAD.Vector(0,0,0)
else:
v0 = obj.Origin
if not hasattr(obj,"Direction"):
v1 = FreeCAD.Vector(0,0,-10)
else:
v1 = obj.Direction.normalize().multiply(10)
v2 = v0.add(v1)
line = Part.Edge(Part.LineSegment(v0,v2))
cone = Part.makeCone(1,0,3,v2,v1,360)
circle = Part.makeCircle(10,v0,v1.negative())
face = Part.makeFace(circle,"Part::FaceMakerSimple")
comp = Part.Compound([line,cone,face])
obj.Shape = comp
obj.ViewObject.Transparency = 50
示例2: execute
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [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
示例3: makeSquareTool
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def makeSquareTool(s, m):
# makes a cylinder with an inner square hole, used as cutting tool
# create square face
msq = Base.Matrix()
msq.rotateZ(math.radians(90.0))
polygon = []
vsq = Base.Vector(s / 2.0, s / 2.0, -m * 0.1)
for i in range(4):
polygon.append(vsq)
vsq = msq.multiply(vsq)
polygon.append(vsq)
square = Part.makePolygon(polygon)
square = Part.Face(square)
# create circle face
circ = Part.makeCircle(s * 3.0, Base.Vector(0.0, 0.0, -m * 0.1))
circ = Part.Face(Part.Wire(circ))
# Create the face with the circle as outline and the square as hole
face=circ.cut(square)
# Extrude in z to create the final cutting tool
exSquare = face.extrude(Base.Vector(0.0, 0.0, m * 1.2))
# Part.show(exHex)
return exSquare
示例4: make_oval
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [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])])
示例5: testFuse
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [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)
示例6: testIntersect
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [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)
示例7: execute
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def execute(self, fp):
inner_diameter = fp.module.Value * fp.teeth
outer_diameter = inner_diameter + fp.height.Value * 2
inner_circle = Part.Wire(Part.makeCircle(inner_diameter / 2.))
outer_circle = Part.Wire(Part.makeCircle(outer_diameter / 2.))
inner_circle.reverse()
face = Part.Face([outer_circle, inner_circle])
solid = face.extrude(App.Vector([0., 0., -fp.thickness.Value]))
# cutting obj
alpha_w = np.deg2rad(fp.pressure_angle.Value)
m = fp.module.Value
t = fp.teeth
t_c = t
t_i = fp.other_teeth
rm = inner_diameter / 2
y0 = m * 0.5
y1 = m + y0
y2 = m
r0 = inner_diameter / 2 - fp.height.Value * 0.1
r1 = outer_diameter / 2 + fp.height.Value * 0.3
polies = []
for r_i in np.linspace(r0, r1, fp.num_profiles):
pts = self.profile(m, r_i, rm, t_c, t_i, alpha_w, y0, y1, y2)
poly = Wire(makePolygon(list(map(fcvec, pts))))
polies.append(poly)
loft = makeLoft(polies, True)
rot = App.Matrix()
rot.rotateZ(2 * np.pi / t)
if fp.construct:
cut_shapes = [solid]
for _ in range(t):
loft = loft.transformGeometry(rot)
cut_shapes.append(loft)
fp.Shape = Part.Compound(cut_shapes)
else:
for i in range(t):
loft = loft.transformGeometry(rot)
solid = solid.cut(loft)
fp.Shape = solid
示例8: make_circle
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def make_circle(size,params=None):
_ = params
return Part.Wire(Part.makeCircle(size.x*0.5))
示例9: make_gr_circle
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def make_gr_circle(params, width=0):
center = makeVect(params.center)
end = makeVect(params.end)
r = center.distanceToPoint(end)
if not width or r <= width*0.5:
return Part.makeCircle(r+width*0.5, center)
return Part.makeCompound([Part.Wire(Part.makeCircle(r+width*0.5,center)),
Part.Wire(Part.makeCircle(r-width*0.5,center,Vector(0,0,-1)))])
示例10: makeArc
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def makeArc(center,start,angle):
p = start.sub(center)
r = p.Length
a = -degrees(DraftVecUtils.angle(p))
# NOTE: KiCAD pcb geometry runs in clockwise, while FreeCAD is CCW. So the
# resulting arc below is the reverse of what's specified in kicad_pcb
if angle>0:
arc = Part.makeCircle(r,center,Vector(0,0,1),a-angle,a)
arc.reverse();
else:
arc = Part.makeCircle(r,center,Vector(0,0,1),a,a-angle)
return arc
示例11: drawCircle
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def drawCircle( self, radius, center, axis ):
global taskUI
cc = Part.makeCircle( radius, center, axis )
circle = App.ActiveDocument.addObject('Part::FeaturePython', 'aCircle')
#circle.ViewObject.Proxy = setCustomIcon(circle,'Draft_Circle.svg')
circle.ViewObject.Proxy = setCustomIcon( circle, taskUI.circleIcon )
circle.Shape = Part.Wire( cc )
circle.ViewObject.LineWidth = 5
circle.ViewObject.LineColor = ( 1.0, 1.0, 1.0 )
circle.ViewObject.PointSize = 10
circle.ViewObject.PointColor= ( 0.0, 0.0, 1.0 )
self.addToDims(circle)
示例12: testShapeProps
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def testShapeProps(self):
"""
Tests miscellaneous properties of the shape object
"""
e = Shape(Part.makeCircle(2.0, FreeCAD.Base.Vector(1, 2, 3)))
# Geometry type
self.assertEqual(e.geomType(), 'Edge')
# Dynamic type checking
self.assertTrue(e.isType(e, 'Edge'))
self.assertFalse(e.isType(None, 'Edge'))
# Checking null objects
self.assertFalse(e.isNull())
# Checking for sameness
self.assertTrue(e.isSame(e))
# Checking for equality
self.assertTrue(e.isEqual(e))
# Checking for shape validity
self.assertTrue(e.isValid())
# Testing whether shape is closed
self.assertTrue(e.Closed())
# Trying to get the area of the circular edge
with self.assertRaises(ValueError):
e.Area()
# Getting the area of the square face
mplane = Face.makePlane(10.0, 10.0)
self.assertAlmostEqual(100.0, mplane.Area(), 3)
# Getting the center of a solid
s = Solid.makeCylinder(10.0, 10.0)
self.assertTupleAlmostEquals((0.0, 0.0, 5.0), s.Center().toTuple(), 3)
示例13: testEdgeWrapperCenter
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def testEdgeWrapperCenter(self):
e = Edge(Part.makeCircle(2.0, FreeCAD.Base.Vector(1, 2, 3)))
self.assertTupleAlmostEquals((1.0, 2.0, 3.0), e.Center().toTuple(), 3)
示例14: testEdgeWrapperMakeCircle
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def testEdgeWrapperMakeCircle(self):
halfCircleEdge = Edge.makeCircle(radius=10, pnt=(0, 0, 0), dir=(0, 0, 1), angle1=0, angle2=180)
self.assertTupleAlmostEquals((0.0, 5.0, 0.0), halfCircleEdge.CenterOfBoundBox(0.0001).toTuple(),3)
self.assertTupleAlmostEquals((10.0, 0.0, 0.0), halfCircleEdge.startPoint().toTuple(), 3)
self.assertTupleAlmostEquals((-10.0, 0.0, 0.0), halfCircleEdge.endPoint().toTuple(), 3)
示例15: testShapeInit
# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCircle [as 別名]
def testShapeInit(self):
"""
Tests whether a Shape object can be instantiated without
throwing an error.
"""
e = Shape(Part.makeCircle(2.0, FreeCAD.Base.Vector(1, 2, 3)))