python二次开发Solidworks:获取草图中的所有草图段

python二次开发Solidworks:获取草图中的所有草图段_第1张图片

import win32com.client as win32
import pythoncom

swApp = win32.Dispatch('sldworks.application')
swApp.Visible = True
Nothing = win32.VARIANT(pythoncom.VT_DISPATCH, None)
# Part = swApp.OpenDoc6(r"C:\Users\user\Documents\钻头建模\RtoG.SLDPRT", 1, 0, "", 0, 0)
swModel = swApp.ActiveDoc
swSelMgr = swModel.SelectionManager
swSketch = swModel.GetActiveSketch2
print(swModel.GetPathName)
swModel.ClearSelection2(True)
vSketchSeg = swSketch.GetSketchSegments
for i in range(len(vSketchSeg)):
    swSketchSeg = vSketchSeg[i]
    vSketchSegID = swSketchSeg.GetId
    print(vSketchSegID[0],vSketchSegID[1])
    print(swSketchSeg.GetName)
    print(swSketchSeg.GetType)
    print(swSketchSeg.GetLength)

1 1
直线1
0
0.009999999999999995
2 2
直线2
0
0.1
3 3
直线3
0
0.010000000000000009
4 4
直线4
0
0.1
5 5
直线5
0
0.1004987562112089
6 6
直线6
0
0.10049875621120889

你可能感兴趣的:(python,Solidworks)