Example #1
0
def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):
    aPnt1 = Base.Vector(-myWidth / 2., 0, 0)
    aPnt2 = Base.Vector(-myWidth / 2., -myThickness / 4., 0)
    aPnt3 = Base.Vector(0, -myThickness / 2., 0)
    aPnt4 = Base.Vector(myWidth / 2., -myThickness / 4., 0)
    aPnt5 = Base.Vector(myWidth / 2., 0, 0)

    aArcOfCircle = Part.Arc(aPnt2, aPnt3, aPnt4)
    aSegment1 = Part.Line(aPnt1, aPnt2)
    aSegment2 = Part.Line(aPnt4, aPnt5)

    aEdge1 = aSegment1.toShape()
    aEdge2 = aArcOfCircle.toShape()
    aEdge3 = aSegment2.toShape()
    aWire = Part.Wire([aEdge1, aEdge2, aEdge3])

    aTrsf = Base.Matrix()
    aTrsf.rotateZ(math.pi)  # rotate around the z-axis

    aMirroredWire = aWire.copy()
    aMirroredWire.transformShape(aTrsf)
    myWireProfile = Part.Wire([aWire, aMirroredWire])

    myFaceProfile = Part.Face(myWireProfile)
    aPrismVec = Base.Vector(0, 0, myHeight)
    myBody = myFaceProfile.extrude(aPrismVec)

    myBody = myBody.makeFillet(myThickness / 12.0, myBody.Edges)

    neckLocation = Base.Vector(0, 0, myHeight)
    neckNormal = Base.Vector(0, 0, 1)

    myNeckRadius = myThickness / 4.
    myNeckHeight = myHeight / 10
    myNeck = Part.makeCylinder(myNeckRadius, myNeckHeight, neckLocation,
                               neckNormal)
    myBody = myBody.fuse(myNeck)

    faceToRemove = 0
    zMax = -1.0

    for xp in myBody.Faces:
        try:
            surf = xp.Surface
            if type(surf) == Part.Plane:
                z = surf.Position.z
                if z > zMax:
                    zMax = z
                    faceToRemove = xp
        except:
            continue

    # This doesn't work for any reason
    myBody = myBody.makeThickness([faceToRemove], -myThickness / 50, 1.e-3)
    myThreading = Part.makeThread(myNeckHeight / 10, myNeckRadius * 0.06,
                                  myHeight / 10, myNeckRadius * 0.99)
    myThreading.translate(Base.Vector(0, 0, myHeight))
    myCompound = Part.Compound([myBody, myThreading])

    return myCompound
Example #2
0
def makeBottle(myWidth=50.0, myHeight=70.0, myThickness=30.0):
	aPnt1=Base.Vector(-myWidth/2.,0,0)
	aPnt2=Base.Vector(-myWidth/2.,-myThickness/4.,0)
	aPnt3=Base.Vector(0,-myThickness/2.,0)
	aPnt4=Base.Vector(myWidth/2.,-myThickness/4.,0)
	aPnt5=Base.Vector(myWidth/2.,0,0)
	
	aArcOfCircle = Part.Arc(aPnt2,aPnt3,aPnt4)
	aSegment1=Part.Line(aPnt1,aPnt2)
	aSegment2=Part.Line(aPnt4,aPnt5)

	aEdge1=aSegment1.toShape()
	aEdge2=aArcOfCircle.toShape()
	aEdge3=aSegment2.toShape()
	aWire=Part.Wire([aEdge1,aEdge2,aEdge3])
	
	aTrsf=Base.Matrix()
	aTrsf.rotateZ(math.pi) # rotate around the z-axis

	aMirroredWire=aWire.copy()
	aMirroredWire.transformShape(aTrsf)
	myWireProfile=Part.Wire([aWire,aMirroredWire])
	
	myFaceProfile=Part.Face(myWireProfile)
	aPrismVec=Base.Vector(0,0,myHeight)
	myBody=myFaceProfile.extrude(aPrismVec)
	
	myBody=myBody.makeFillet(myThickness/12.0,myBody.Edges)
	
	neckLocation=Base.Vector(0,0,myHeight)
	neckNormal=Base.Vector(0,0,1)
	
	myNeckRadius = myThickness / 4.
	myNeckHeight = myHeight / 10
	myNeck = Part.makeCylinder(myNeckRadius,myNeckHeight,neckLocation,neckNormal)	
	myBody = myBody.fuse(myNeck)

	faceToRemove = 0
	zMax = -1.0

	for xp in myBody.Faces:
		try:
			surf = xp.Surface
			if type(surf) == Part.Plane:
				z = surf.Position.z
				if z > zMax:
					zMax = z
					faceToRemove = xp
		except:
			continue
	
	# This doesn't work for any reason		
	myBody = myBody.makeThickness([faceToRemove],-myThickness/50 , 1.e-3)
	myThreading = Part.makeThread(myNeckHeight/10, myNeckRadius*0.06, myHeight/10, myNeckRadius*0.99)
	myThreading.translate(Base.Vector(0,0,myHeight))
	myCompound = Part.Compound([myBody, myThreading])

	return myCompound
Example #3
0
"""
in pitch_in s n=2 d=0.5
in depth_in s n=2 d=1.0
in height_in s n=2 d=4.0
in radius_in s n=2 d=1.0
out solid_out So
"""

from sverchok.dependencies import FreeCAD

if FreeCAD is None:
    raise Exception("FreeCAD libraries are not available")

from FreeCAD import Base
import Part

solid_out = []
solid = Part.makeThread(pitch_in, depth_in, height_in, radius_in)
solid_out.append(solid)