Python Part.makeCone() Examples

The following are 7 code examples of Part.makeCone(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Part , or try the search function .
Example #1
Source File: paramVector.py    From CurvesWB with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 
Example #2
Source File: pipeFeatures.py    From flamingo with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 
Example #3
Source File: friki.py    From videoblog with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #4
Source File: pipeFeatures.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def execute(self, fp):
    if fp.OD>fp.OD2:
      if fp.calcH or fp.Height==0:
        fp.Height=3*(fp.OD-fp.OD2)
      fp.Profile=str(fp.OD)+"x"+str(fp.OD2)
      if fp.conc:
        sol = Part.makeCone(fp.OD/2,fp.OD2/2,fp.Height)
        if fp.thk<fp.OD/2 and fp.thk2<fp.OD2/2:
          fp.Shape=sol.cut(Part.makeCone(fp.OD/2-fp.thk,fp.OD2/2-fp.thk2,fp.Height))
        else:
          fp.Shape=sol
        fp.Ports=[FreeCAD.Vector(),FreeCAD.Vector(0,0,float(fp.Height))]
      else:
        C=Part.makeCircle(fp.OD/2,FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1))
        c=Part.makeCircle(fp.OD2/2,FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1))
        c.translate(FreeCAD.Vector((fp.OD-fp.OD2)/2,0,fp.Height))
        sol=Part.makeLoft([c,C],True)
        if fp.thk<fp.OD/2 and fp.thk2<fp.OD2/2:
          C=Part.makeCircle(fp.OD/2-fp.thk,FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1))
          c=Part.makeCircle(fp.OD2/2-fp.thk2,FreeCAD.Vector(0,0,0),FreeCAD.Vector(0,0,1))
          c.translate(FreeCAD.Vector((fp.OD-fp.OD2)/2,0,fp.Height))
          fp.Shape=sol.cut(Part.makeLoft([c,C],True))
        else:
          fp.Shape=sol
        fp.Ports=[FreeCAD.Vector(),FreeCAD.Vector((fp.OD-fp.OD2)/2,0,float(fp.Height))]
    super(Reduct,self).execute(fp) # perform common operations 
Example #5
Source File: pipeFeatures.py    From flamingo with GNU Lesser General Public License v3.0 5 votes vote down vote up
def execute(self, fp):
    c=Part.makeCone(fp.OD/2,fp.OD/5,fp.Height/2)
    v=c.fuse(c.mirror(FreeCAD.Vector(0,0,fp.Height/2),FreeCAD.Vector(0,0,1)))
    if fp.PRating.find('ball')+1 or fp.PRating.find('globe')+1:
      r=min(fp.Height*0.45,fp.OD/2)
      v=v.fuse(Part.makeSphere(r,FreeCAD.Vector(0,0,fp.Height/2)))
    fp.Shape = v
    fp.Ports=[FreeCAD.Vector(),FreeCAD.Vector(0,0,float(fp.Height))]
    super(Valve,self).execute(fp) # perform common operations 
Example #6
Source File: a2plib.py    From A2plus with GNU Lesser General Public License v2.1 5 votes vote down vote up
def drawVector(fromPoint,toPoint, color):
    if fromPoint == toPoint: return
    doc = FreeCAD.ActiveDocument

    l = Part.LineSegment()
    l.StartPoint = fromPoint
    l.EndPoint = toPoint
    line = doc.addObject("Part::Feature","Line")
    line.Shape = l.toShape()
    line.ViewObject.LineColor = color
    line.ViewObject.LineWidth = 1

    
    c = Part.makeCone(0,1,4)
    cone = doc.addObject("Part::Feature","ArrowHead")
    cone.Shape = c
    cone.ViewObject.ShapeColor = color
    #
    mov = Base.Vector(0,0,0)
    zAxis = Base.Vector(0,0,-1)
    rot = FreeCAD.Rotation(zAxis,toPoint.sub(fromPoint))
    cent = Base.Vector(0,0,0)
    conePlacement = FreeCAD.Placement(mov,rot,cent)
    cone.Placement = conePlacement.multiply(cone.Placement)
    cone.Placement.move(toPoint)
    doc.recompute()
#------------------------------------------------------------------------------ 
Example #7
Source File: shapes.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def makeCone(cls, radius1, radius2, height, pnt=Vector(0, 0, 0), dir=Vector(0, 0, 1), angleDegrees=360):
        """
        Make a cone with given radii and height
        By default pnt=Vector(0,0,0),
        dir=Vector(0,0,1) and angle=360'
        """
        return Shape.cast(FreeCADPart.makeCone(radius1, radius2, height, pnt.wrapped, dir.wrapped, angleDegrees))