python二次开发Solidworks:扫描

在新零件文档中创建一个圆形草图和两条线段草图,并将它们插入到模型中。接着,选中圆形草图作为扫描轮廓,并选中两条线段草图并将它们分组为一个对象。最后,使用特征管理器的InsertProtrusionSwept4方法创建扫描特征。

python 复制代码
import win32com.client as win32
import pythoncom
swApp = win32.Dispatch('sldworks.application')
swApp.Visible = True
Nothing = win32.VARIANT(pythoncom.VT_DISPATCH, None)
swModel = swApp.NewDocument(r"C:\ProgramData\SolidWorks\SOLIDWORKS 2018\templates\gb_part.prtdot", 0, 0, 0)
swModelDocExt = swModel.Extension
swSketchManager = swModel.SketchManager
swFeatureManager = swModel.FeatureManager
#Create sketch of circle for the sweep profile
swSketchSegment = swSketchManager.CreateCircle(0, 0, 0, 0.002394, -0.006333, 0)
swSketchManager.InsertSketch(True)
#Create sketches of lines for the sweep path
status = swModelDocExt.SelectByID2("右视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
swSketchManager.InsertSketch(True)
swSketchSegment = swSketchManager.CreateLine(-0, 0, 0, 0.088481, 0.035691, 0)
swSketchManager.InsertSketch(True)
swModel.ClearSelection2(True)
status = swModelDocExt.SelectByID2("右视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
swSketchManager.InsertSketch(True)
swSketchSegment = swSketchManager.CreateLine(0.088481, 0.035691, 0, 0.079214, 0.076295, 0)
swSketchManager.InsertSketch(True)
swModel.ClearSelection2(True)
#Select the sketch of the circle for the sweep profile
status = swModelDocExt.SelectByID2("草图1", "SKETCH", -5.86834883582351E-03, -3.37646707201764E-03, 0, False, 1, Nothing, 0)
#Select the sketches of the lines for the sweep path and group them as an object
status = swModelDocExt.SelectByID2("直线1@草图2", "EXTSKETCHSEGMENT", 3.79259971310087E-02, 1.52983890733924E-02, 0, True, 4, Nothing, 0)
status = swModelDocExt.SelectByID2("直线1@草图3", "EXTSKETCHSEGMENT", 8.48435978763939E-02, 5.16285284155501E-02, 0, True, 4, Nothing, 0)
status = swModelDocExt.SelectByID2("Unknown", "SELOBJGROUP", 0, 0, 0, True, 4, Nothing, 0)
#Create the sweep feature
swFeature = swFeatureManager.InsertProtrusionSwept4(False, False, 0, False, False, 0, 0, False, 0, 0, 0, 0, True, True, True, 0, True, False, 0, 0)
swModel.ShowNamedView2("*上下二等角轴测", 8)
swModel.SelectionManager.EnableContourSelection = False
swModel.ViewZoomtofit2()
相关推荐
用户277844910499311 小时前
借助DeepSeek智能生成测试用例:从提示词到Excel表格的全流程实践
人工智能·python
JavaEdge在掘金13 小时前
ssl.SSLCertVerificationError报错解决方案
python
我不会编程55514 小时前
Python Cookbook-5.1 对字典排序
开发语言·数据结构·python
老歌老听老掉牙14 小时前
平面旋转与交线投影夹角计算
python·线性代数·平面·sympy
满怀101514 小时前
Python入门(7):模块
python
无名之逆14 小时前
Rust 开发提效神器:lombok-macros 宏库
服务器·开发语言·前端·数据库·后端·python·rust
你觉得20514 小时前
哈尔滨工业大学DeepSeek公开课:探索大模型原理、技术与应用从GPT到DeepSeek|附视频与讲义下载方法
大数据·人工智能·python·gpt·学习·机器学习·aigc
啊喜拔牙15 小时前
1. hadoop 集群的常用命令
java·大数据·开发语言·python·scala
__lost16 小时前
Pysides6 Python3.10 Qt 画一个时钟
python·qt