SOLIDWORKS 專門論壇 SolidWorks forum

 找回密碼
 註冊
查看: 14356|回復: 3
收起左側

鈑金展開巨集編輯問題

[複製鏈接]
發表於 2016/5/22 14:08:06 | 顯示全部樓層 |閱讀模式
求助下列代碼求各位大神可以幫我改成.執行巨集 板金件->工程圖平板顯示->存到桌面為dwg或dxf嗎

目前只做到工程圖平板.可以改成自動存檔為dwg或dxf嗎  謝謝幫忙

  1. ' ******************************************************************************
  2. ' C:\Documents and Settings\Administrator\Local Settings\Temp\swx3104\Macro1.swb - macro recorded on 05/22/16 by Administrator
  3. ' ******************************************************************************
  4. Option Explicit

  5. Dim swApp As SldWorks.SldWorks
  6. Dim swModel As SldWorks.ModelDoc2
  7. Dim swPart As SldWorks.PartDoc
  8. Dim swModelDocExt As SldWorks.ModelDocExtension
  9. Dim swSelMgr As SldWorks.SelectionMgr
  10. Dim swDrawing As SldWorks.DrawingDoc
  11. Dim swView As SldWorks.View
  12. Dim retval As String
  13. Dim boolstatus As Boolean
  14. Sub main()
  15. Set swApp = Application.SldWorks
  16. Set swModel = swApp.ActiveDoc
  17. Set swPart = swModel
  18. Set swModelDocExt = swModel.Extension
  19. Set swSelMgr = swModel.SelectionManager
  20. retval = swApp.GetUserPreferenceStringValue(swDefaultTemplateDrawing)

  21. Set swModel = swApp.NewDocument(retval, 0, 0, 0)
  22. Set swDrawing = swModel

  23. Set swView = swDrawing.CreateDrawViewFromModelView3(swPart.GetPathName, "平板型式", 0.1, 0.14, 0)

  24. boolstatus = swModelDocExt.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)

  25. boolstatus = swDrawing.ActivateView("Drawing View1")
  26. swModel.ClearSelection2 True

  27. End Sub
複製代碼
發表於 2016/7/14 17:08:37 | 顯示全部樓層
  1. 'Enables a sheet metal part to be saved to disk in its flattened state to a DXF/DWG file.
  2. '钣金零件以平板型式存为DXF/DWG文件-----PYCZT
  3. Dim swApp As Object
  4. Dim swModel As Object
  5. Dim swModelName As String
  6. Dim FilePath As String
  7. Dim value As Boolean
  8. Sub main()
  9. Set swApp = Application.SldWorks
  10. Set swModel = swApp.ActiveDoc
  11. swModelName = swModel.GetPathName      '读取当前SW模型文档名(含路径)
  12. FilePath = Left(swModelName, Len(swModelName) - 7) + "平板图.dwg" '定义工程图名
  13. 'value = swModel.ExportFlatPatternView(FilePath, swExportFlatPatternOption_None)  保留折弯线
  14. value = swModel.ExportFlatPatternView(FilePath, swExportFlatPatternOption_RemoveBends)     '无折弯线
  15. End Sub
複製代碼

點評

大哥,您這個程式真的很好用,我用了許久,但最近換了公司發現有一些美中不足的,想請問您, 針對保留折線的部份,我們工件正常會有正折,反折,能否將折線區分出來呢,例如顏色or 線型不同等等的呢。 請指教  詳情 回復 發表於 2019/6/11 21:40
誠摰歡迎前輩加入幾何~  詳情 回復 發表於 2016/7/14 23:09
發表於 2016/7/14 23:09:33 | 顯示全部樓層

誠摰歡迎前輩加入幾何~
發表於 2019/6/11 21:40:55 來自手機 | 顯示全部樓層
pyczt 發表於 2016/7/14 17:08

大哥,您這個程式真的很好用,我用了許久,但最近換了公司發現有一些美中不足的,想請問您,
針對保留折線的部份,我們工件正常會有正折,反折,能否將折線區分出來呢,例如顏色or 線型不同等等的呢。
請指教
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版上論壇|論壇來自幾何科技

GMT+8, 2019/8/25 13:40 , Processed in 0.081559 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表