FreeCAD|读取STEP、创建平面、相交、瓶子

时间:2024-03-04 16:54:16
import FreeCAD as Appimport Part, mathdef makeBottleTut(myWidth = 50.0, myHeight = 70.0, myThickness = 30.0): aPnt1=App.Vector(-myWidth / 2., 0, 0) aPnt2=App.Vector(-myWidth / 2., -myThickness / 4., 0) aPnt3=App.Vector(0, -myThickness / 2., 0) aPnt4=App.Vector(myWidth / 2., -myThickness / 4., 0) aPnt5=App.Vector(myWidth / 2., 0, 0) aArcOfCircle = Part.Arc(aPnt2, aPnt3, aPnt4) aSegment1=Part.LineSegment(aPnt1, aPnt2) aSegment2=Part.LineSegment(aPnt4, aPnt5) aEdge1=aSegment1.toShape() aEdge2=aArcOfCircle.toShape() aEdge3=aSegment2.toShape() aWire=Part.Wire([aEdge1, aEdge2, aEdge3]) aTrsf=App.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=App.Vector(0, 0, myHeight) myBody=myFaceProfile.extrude(aPrismVec) myBody=myBody.makeFillet(myThickness / 12.0, myBody.Edges) neckLocation=App.Vector(0, 0, myHeight) neckNormal=App.Vector(0, 0, 1) myNeckRadius = myThickness / 4. myNeckHeight = myHeight / 10. myNeck = Part.makeCylinder(myNeckRadius, myNeckHeight, neckLocation, neckNormal) myBody = myBody.fuse(myNeck) return myBodyel = makeBottleTut()Part.show(el)