当前位置: 首页>>代码示例>>Python>>正文


Python Part.makeCircle方法代码示例

本文整理汇总了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 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:20,代码来源:paramVector.py

示例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 
开发者ID:oddtopus,项目名称:flamingo,代码行数:25,代码来源:pipeFeatures.py

示例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 
开发者ID:shaise,项目名称:FreeCAD_FastenersWB,代码行数:27,代码来源:FSNuts.py

示例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])]) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:22,代码来源:kicad.py

示例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) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:26,代码来源:TestCadObjects.py

示例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) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:26,代码来源:TestCadObjects.py

示例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 
开发者ID:looooo,项目名称:freecad.gears,代码行数:42,代码来源:features.py

示例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)) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:5,代码来源:kicad.py

示例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)))]) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:10,代码来源:kicad.py

示例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 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:14,代码来源:kicad.py

示例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) 
开发者ID:Zolko-123,项目名称:FreeCAD_Assembly4,代码行数:14,代码来源:Asm4_Measure.py

示例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) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:41,代码来源:TestCadObjects.py

示例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) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:6,代码来源:TestCadObjects.py

示例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) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:8,代码来源:TestCadObjects.py

示例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))) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:8,代码来源:TestCadObjects.py


注:本文中的Part.makeCircle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。