AnsweredAssumed Answered

Export all opened sheetmetal parts to DWG and add DWG Textbox

Question asked by Damir Galic on Jun 29, 2018
Latest reply on Jul 2, 2018 by X. Men

Hi,

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swPart As SldWorks.PartDoc

Dim boolstatus As Long

Dim errors As Long

 

Sub main()

    Set swApp = Application.SldWorks

    Dim FileSavedCount As Long

    Dim FailedToSaveCount As Long

    Set swModel = swApp.GetFirstDocument

  

    While Not swModel Is Nothing

        If swModel.GetType = swDocPART Then

            If Not swModel.GetBendState = 0 Then 'if part is sheet metal

 

                Set swPart = swApp.ActivateDoc2(swModel.GetTitle, True, errors)

               

                Dim targetFilePath As String

                Dim modelPath As String

                modelPath = swModel.GetPathName

                targetFilePath = Left(modelPath, InStr(modelPath, ".") - 1) & ".DWG"

          

                boolstatus = swPart.ExportToDWG2(targetFilePath, modelPath, swExportToDWG_ExportSheetMetal, True, 0, False, False, 2053, Null)

               

                If boolstatus Then

                    FileSavedCount = FileSavedCount + 1

                Else

                    FailedToSaveCount = FailedToSaveCount + 1

                End If

            Else

                MsgBox (swModel.GetTitle & "Part is not sheet metal")

            End If

        Else

            MsgBox (swModel.GetTitle & "Document is not a Part.")

        End If

 

        Set swModel = swModel.GetNext

    Wend

    MsgBox (FileSavedCount & " dwg file(s) exported, " & FailedToSaveCount & " file(s) failed")

End Sub

How do i add to above program that would also hide hidden lines, bend lines, bounding-box, all text and add a text block above drawing with this definition:

Name: "some property in configuration"

Thickness: thickness

Material: "some property name in configuration"

 

Would like to see where to change option for bounding box to display, in case the part is not fully flattened.

Outcomes