solidworks api VBA 用于将模型特征压缩


Dim swApp As Object

Dim swModel As SldWorks.ModelDoc2




Sub main()


Dim sPartName2 As String




Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc


featCount = swModel.GetFeatureCount


sPartName2 = "D:\Solidworks Data\macro\1001\0.stl"
boolstatus = swModel.Extension.SaveAs(sPartName2, 0, 2, Nothing, 0, 0)


For i = featCount To 1 Step -2 '-2把草图空掉
Set theFeature = swModel.FeatureByPositionReverse(featCount - i)
featName = theFeature.Name
Debug.Print "Feature Name: " & featName1 & ".stl";
bRet = theFeature.Select2(False, 0): Debug.Assert bRet
'压缩特征


boolstatus = swModel.EditSuppress2
sPartName2 = "D:\Solidworks Data\macro\1001\" & featCount + 1 - i & ".stl"
boolstatus = swModel.Extension.SaveAs(sPartName2, 0, 2, Nothing, 0, 0)


Next


'boolstatus = Part.Extension.SelectByID2("前视", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
'Part.InsertSketchText 0, 0, 0, "你好!" & Chr(10) & "测试成功!", 0, 0, 0, 100, 100           '插入草图文本
'Part.FeatureManager.FeatureExtrusion2 True, False, False, 0, 0, 0.001, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1, 0, 0, False           '拉伸文本
End Sub

你可能感兴趣的:(备忘)