當前位置: 首頁>>代碼示例>>Python>>正文


Python Part.makeCylinder方法代碼示例

本文整理匯總了Python中Part.makeCylinder方法的典型用法代碼示例。如果您正苦於以下問題:Python Part.makeCylinder方法的具體用法?Python Part.makeCylinder怎麽用?Python Part.makeCylinder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Part的用法示例。


在下文中一共展示了Part.makeCylinder方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [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

示例2: vectorz

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def vectorz(l = 10, l_arrow = 4, d = 1, mark = False, show = True):
	"""Draw a vector in the z axis. Parameters:
		 l : Lenght
         l_arrow: arrow length
		 d : vector diameter
	"""

	#-- Correct the length
	if (l < l_arrow):
		l_arrow = l/2

	vectz = Part.makeCylinder(d / 2.0, l - l_arrow)
	base = Part.makeSphere(d / 2.0)
	arrow = Part.makeCone(d/2 + 1, 0.2, l_arrow)
	arrow.Placement.Base.z = l - l_arrow

	#-- Create the union of all the parts
	union = vectz.fuse(base)
	union = union.fuse(arrow)

	#-- Return de vector z
	return union 
開發者ID:Obijuan,項目名稱:videoblog,代碼行數:24,代碼來源:friki.py

示例3: sweep_wire

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def sweep_wire(self, w, solid=False):
        faces = []
        for e in w.Edges:
            faces.append(self.sweep_edge(e,solid))
        shell = Part.Shell(faces)
        shell.sewShape()
        if solid:
            cyl = Part.makeCylinder(self.max_radius*2, self.nb_of_turns*self.lead)
            cyl.Placement = self._placement.multiply(FreeCAD.Placement(FreeCAD.Vector(),FreeCAD.Vector(1,0,0),-90))
            common = cyl.common(shell)
            cut_faces = common.Faces
            new_edges = []
            for e1 in common.Edges:
                found = False
                for e2 in shell.Edges:
                    if nurbs_tools.is_same(e1.Curve, e2.Curve, tol=1e-7, full=False):
                        found = True
                        #print("found similar edges")
                        continue
                if not found:
                    new_edges.append(e1)
            #print(len(Part.sortEdges(new_edges)))
            el1, el2 = Part.sortEdges(new_edges)[0:2]
            f1 = Part.makeFace(Part.Wire(el1),'Part::FaceMakerSimple')
            f2 = Part.makeFace(Part.Wire(el2),'Part::FaceMakerSimple')
            cut_faces.extend([f1,f2])
            try:
                shell = Part.Shell(cut_faces)
                shell.sewShape()
                return Part.Solid(shell)
            except Part.OCCError:
                print("Failed to create solid")
                return Part.Compound(cut_faces)
        return shell 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:36,代碼來源:HelicalSweepFP.py

示例4: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def execute(self, obj):
        o = obj.Source
        base = o.Shape.BoundBox.Center
        dl = o.Shape.BoundBox.DiagonalLength
        cyl = Part.makeCylinder(dl, dl*2, base-obj.Direction*dl, obj.Direction).Face1

        uf,ul,vf,vl=cyl.ParameterRange
        pts = list()
        for i in range(obj.RadialSamples):
            u = uf + (float(i)/(obj.RadialSamples-1))*(ul-uf)
            e = cyl.Surface.uIso(u).toShape()
            #best = 1e50
            #good_pt = None
            d,pt,info = o.Shape.distToShape(e)
            if len(pt) > 1:
                debug("multi pt %s"%str(pt))
                #good_point = pt[0][0]
            for i,inf in enumerate(info):
                if inf[0] in (b"Face","Face"):
                    pts.append(pt[i][0])


        if hasattr(obj,"ExtensionProxy"):
            if obj.Active:
                obj.Shape = obj.ExtensionProxy.approximate(obj, pts)
                return()
        bs = Part.BSplineCurve()
        bs.approximate(pts)
        obj.Shape = bs.toShape() 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:31,代碼來源:Outline_FP.py

示例5: path3d

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def path3d(self):
        cyl = Part.makeCylinder((self.diameter-self.wire_diam)/2., self.length-self.wire_diam, Vector(), Vector(0,0,1)).Face1
        return self.path2d().toShape(cyl.Surface) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:5,代碼來源:comp_spring.py

示例6: linearDeviation

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def linearDeviation(edge, radius=1.0):
    sp = edge.valueAt(edge.FirstParameter)
    ep = edge.valueAt(edge.LastParameter)
    axis = ep-sp
    cyl = Part.makeCylinder(radius,axis.Length,sp,axis)
    d,pts,info = edge.distToShape(cyl.Face1)
    params = list()
    for i in info:
        if i[0] in ("Edge",b"Edge"):
            params.append(i[2])
        elif i[0] in ("Vertex",b"Vertex"):
            params.append(edge.parameterAt(edge.Vertexes[i[1]]))
    return (radius-d), params 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:15,代碼來源:curveOnSurface.py

示例7: makeCylinder

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def makeCylinder(cls, radius, height, pnt=Vector(0, 0, 0), dir=Vector(0, 0, 1), angleDegrees=360):
        """
        makeCylinder(radius,height,[pnt,dir,angle]) --
        Make a cylinder with a given radius and height
        By default pnt=Vector(0,0,0),dir=Vector(0,0,1) and angle=360'
        """
        return Shape.cast(FreeCADPart.makeCylinder(radius, height, pnt.wrapped, dir.wrapped, angleDegrees)) 
開發者ID:jmwright,項目名稱:cadquery-freecad-module,代碼行數:9,代碼來源:shapes.py

示例8: make_dog_bone_on_xz

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def make_dog_bone_on_xz(pos_x, pos_z, width, radius):
    cylinder = Part.makeCylinder(radius, width, FreeCAD.Vector(pos_x, -width/2.0, pos_z), FreeCAD.Vector(0, 1, 0))
    return cylinder 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:5,代碼來源:crosspart.py

示例9: make_dog_bone_on_yz

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def make_dog_bone_on_yz(pos_y, pos_z, length, radius):
    cylinder = Part.makeCylinder(radius, length, FreeCAD.Vector(-length / 2.0, pos_y, pos_z), FreeCAD.Vector(1, 0, 0))
    return cylinder 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:5,代碼來源:crosspart.py

示例10: make_dog_bone_on_xy

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def make_dog_bone_on_xy(pos_x, pos_y, height, radius):
    cylinder = Part.makeCylinder(radius, height, FreeCAD.Vector(pos_x, pos_y, -height / 2.0), FreeCAD.Vector(0, 0, 1))
    return cylinder 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:5,代碼來源:helper.py

示例11: make_dog_bone_on_yz

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def make_dog_bone_on_yz(pos_y, pos_z, height, radius):
    cylinder = Part.makeCylinder(radius, height, FreeCAD.Vector(0, pos_y, pos_z), FreeCAD.Vector(1., 0, 0))
    return cylinder 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:5,代碼來源:helper.py

示例12: screw_way_on_plane

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def screw_way_on_plane(material_plane, screw_nut_spec, pos_y):
    # horizontal hole
    radius = (screw_nut_spec.screw_diameter * 1.2 - material_plane.laser_beam_diameter) / 2.0
    cylinder = Part.makeCylinder(radius, material_plane.thickness, FreeCAD.Vector(0, 0, -material_plane.thickness / 2.))
    cylinder.rotate(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(0, 1, 0), 90)
    cylinder.translate(FreeCAD.Vector(material_plane.thickness / 2.0, pos_y, 0.))
    return cylinder 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:9,代碼來源:join.py

示例13: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeCylinder [as 別名]
def execute(self, fp):
        fp.gear.double_helix = fp.double_helix
        fp.gear.m_n = fp.module.Value
        fp.gear.z = fp.teeth
        fp.gear.undercut = fp.undercut
        fp.gear.shift = fp.shift
        fp.gear.pressure_angle = fp.pressure_angle.Value * np.pi / 180.
        fp.gear.beta = fp.beta.Value * np.pi / 180
        fp.gear.clearance = fp.clearance
        fp.gear.backlash = fp.backlash.Value * \
            (-fp.reversed_backlash + 0.5) * 2.
        fp.gear.head = fp.head
        # checksbackwardcompatibility:
        if "properties_from_tool" in fp.PropertiesList:
            fp.gear.properties_from_tool = fp.properties_from_tool
        fp.gear._update()
        pts = fp.gear.points(num=fp.numpoints)
        rotated_pts = pts
        rot = rotation(-fp.gear.phipart)
        for i in range(fp.gear.z - 1):
            rotated_pts = list(map(rot, rotated_pts))
            pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
            pts += rotated_pts
        pts.append(np.array([pts[-1][-1], pts[0][0]]))
        if not fp.simple:
            wi = []
            for i in pts:
                out = BSplineCurve()
                out.interpolate(list(map(fcvec, i)))
                wi.append(out.toShape())
            wi = Wire(wi)
            if fp.beta.Value == 0:
                sh = Face(wi)
                fp.Shape = sh.extrude(App.Vector(0, 0, fp.height.Value))
            else:
                fp.Shape = helicalextrusion(
                    wi, fp.height.Value, fp.height.Value * np.tan(fp.gear.beta) * 2 / fp.gear.d, fp.double_helix)
        else:
            rw = fp.gear.dw / 2
            fp.Shape = Part.makeCylinder(rw, fp.height.Value)

        # computed properties
        fp.dw = "{}mm".format(fp.gear.dw)
        fp.transverse_pitch = "{}mm".format(fp.gear.pitch) 
開發者ID:looooo,項目名稱:freecad.gears,代碼行數:46,代碼來源:features.py


注:本文中的Part.makeCylinder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。