本帖最后由 gt.adan 于 2014-9-23 15:10 编辑
【練習】用悶大的代碼加入鈑金的展開及抑制,達成「批量重整」模型- Dim swApp As Object
- Dim Part As Object
- Dim boolstatus As Boolean
- Dim longstatus As Long, longwarnings As Long
- Sub Test()
- Set swApp = Application.SldWorks
- PartPath = "C:\資料夾路徑" '設定目錄
- PartFileName = Dir(PartPath & "*.sldprt") '搜尋首個零件檔案名稱
- Do Until PartFileName = "" '直至搜尋到空值
- Set Part = swApp.OpenDoc(PartPath & PartFileName, 1) '開啟零件
- boolstatus = Part.Extension.SelectByID2("Flat-Pattern1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
- Part.ClearSelection2 True
- longstatus = Part.SetBendState(2)
- boolstatus = Part.EditRebuild3()
- boolstatus = Part.Extension.SelectByID2("Flat-Pattern1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
- Part.ClearSelection2 True
- longstatus = Part.SetBendState(3)
- boolstatus = Part.EditRebuild3()
- Part.Save '保存
- swApp.CloseDoc (PartFileName) '關閉零件
- PartFileName = Dir '搜尋下一個零件檔案名稱
- Loop '循環搜尋
- End Sub
复制代码 |