本文整理汇总了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
示例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
示例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
示例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()
示例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)
示例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
示例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))
示例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
示例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
示例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
示例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
示例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
示例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)