FreeCAD: Reading STEP, Creating Planes, Intersecting, and Modeling Bottles

Click the above “Mechanical and Electronic Engineering Technology” to follow us
FreeCAD is an open-source CAD/CAE tool based on OpenCASCADE. OpenCASCADE is an open-source CAD/CAM/CAE geometric modeling kernel, developed by Matra Datavision in France, and is the development platform for the well-known CAD software EUCLID. FreeCAD can run on both Windows and Linux systems, and is a general-purpose 3D CAD modeling tool with completely open-source development (following the LGPL license of GPL).
The direct application target of FreeCAD is mechanical engineering and product design, but its uses are extensive, also suitable for architecture and other engineering disciplines, engineering drawing, and more. FreeCAD has tools similar to CATIA, SolidWorks, or Solid Edge, and thus will also provide CAX (CAD, CAM, CAE), PLM, and other functionalities. It is based on a parametric modeling feature and a modular software architecture, making it easy to provide additional functionalities without modifying the core system.
Using Python scripts in FreeCAD can greatly extend its functionality, allowing users to automate design processes, create custom tools and macros, and perform advanced parametric design. Below are some examples of Python scripting in FreeCAD:

Import STEP

import Parts = Part.Shape()s.read(u"d:/Documents/drill.step")Part.show(s)

Create Plane

plan1=Part.makePlane(2,2,App.Vector(-1,-1,0.8),App.Vector(0,0,1))Part.show(plan1)

Boolean Intersection

k=s.common(plan1)Part.show(k1)

Bottle Modeling

import FreeCAD as Appimport Part, math
def 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 myBody
el = makeBottleTut()Part.show(el)
FreeCAD: Reading STEP, Creating Planes, Intersecting, and Modeling Bottles

Want to know more

Quickly scan the code to follow

Leave a Comment