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

FreeCAD是一个基于OpenCASCADE的开源CAD/CAE工具。OpenCASCADE是一套开源的CAD/CAM/CAE几何模型核心,来自法国Matra Datavision公司,是著名的CAD软件EUCLID的开发平台。FreeCAD可运行于Windows以及Linux系统环境下,是一种通用的3D CAD建模工具,其发展是完全开源的(遵循GPL的LGPL许可证)。

FreeCAD的直接应用目标是机械工程和产品设计,但其用途十分广泛,也适用于建筑或其他工程专业,工程制图等领域。FreeCAD具有类似CATIA,SolidWorks或Solid Edge的工具,因此也将提供CAX(CAD,CAM,CAE),PLM等功能。这是一个基于参数化建模功能与模块化的软件架构,使得它易于无需修改核心系统即可提供额外的功能。

在FreeCAD中使用Python脚本编写可以极大地扩展其功能,并允许用户自动化设计流程、创建自定义工具和宏,以及进行高级的参数化设计。以下是一些FreeCAD中Python脚本编写的示例:

导入STEP

复制代码
import Parts = Part.Shape()s.read(u"d:/Documents/drill.step")Part.show(s)​

创建平面

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

布尔相交

复制代码
k=s.common(plan1)Part.show(k1)

瓶子建模

复制代码
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)​
相关推荐
一个天蝎座 白勺 程序猿1 小时前
Python爬虫(47)Python异步爬虫与K8S弹性伸缩:构建百万级并发数据采集引擎
爬虫·python·kubernetes
XiaoMu_0012 小时前
基于Django+Vue3+YOLO的智能气象检测系统
python·yolo·django
honder试试3 小时前
焊接自动化测试平台图像处理分析-模型训练推理
开发语言·python
心本无晴.3 小时前
Python进程,线程
python·进程
java1234_小锋6 小时前
Scikit-learn Python机器学习 - 特征降维 压缩数据 - 特征提取 - 主成分分析 (PCA)
python·机器学习·scikit-learn
java1234_小锋6 小时前
Scikit-learn Python机器学习 - 特征降维 压缩数据 - 特征提取 - 线性判别分析 (LDA)
python·机器学习·scikit-learn
思辨共悟7 小时前
Python的价值:突出在数据分析与挖掘
python·数据分析
计算机毕业设计木哥7 小时前
计算机毕设选题:基于Python+Django的B站数据分析系统的设计与实现【源码+文档+调试】
java·开发语言·后端·python·spark·django·课程设计
中等生8 小时前
Pandas 与 NumPy:数据分析中的黄金搭档
后端·python
用户8356290780518 小时前
Python查找替换PDF文字:告别手动,拥抱自动化
后端·python