0 Replies Latest reply on Nov 15, 2013 8:22 AM by Jiten Dutia

    flat pattern to dwg with custom properties

    Jiten Dutia

      Hello Guys,

      I would like to get some assistance in getting my macro programmed. I have the following macro to create flatpattern view of a sheetmetal part and export it to a dwg without any bend lines. I wanted to add few custom properties (ex. sheetmetal part has a property called Quantity, thickness etc.) to this dwg? is it possible, if so how? Any help would be greatly appriciated.

       

      Also i have the following code working as a pdm task. I would like to include these custom properties option into this task as well to make it automated.

      Thanks

       

      Option Explicit

       

      Dim swApp As SldWorks.SldWorks

       

      Sub main()

        

          Dim swModel                 As SldWorks.ModelDoc2

          Dim vConfNameArr            As Variant

          Dim vConfName               As Variant

          Dim bShowConfig             As Boolean

          Dim bRebuild                As Boolean

          Dim bRet                    As Boolean

          Dim swDocSpecification      As SldWorks.DocumentSpecification

       

          Set swApp = CreateObject("SldWorks.Application")

          Set swDocSpecification = swApp.GetOpenDocSpec("<Filepath>")

          Set swModel = swApp.OpenDoc7(swDocSpecification)

          Set swModel = swApp.ActiveDoc

       

      'Is it a part document?

      Dim modelType As Long

       

      modelType = swModel.GetType

       

      If modelType <> SwConst.swDocPART Then

          'swApp.SendMsgToUser2 "A sheet metal part must be open.", swMbWarning, swMbOk

          Exit Sub

      End If

       

      vConfNameArr = swModel.GetConfigurationNames

       

      For Each vConfName In vConfNameArr

          If (Strings.Right(vConfName, 7)) = "PATTERN" Then

          bShowConfig = swModel.ShowConfiguration2(vConfName)

          bRebuild = swModel.ForceRebuild3(False)

       

          Dim FilePath As String

          Dim PathSize As Long

          Dim PathNoExtension As String

          Dim NewFilePath As String

         

          FilePath = swModel.GetPathName

          PathSize = Strings.Len(FilePath)

          PathNoExtension = Strings.Left("<Filepath>", PathSize - 6)

       

          NewFilePath = PathNoExtension & "DWG"

         

          'Export Flat Pattern

          bRet = swModel.ExportFlatPatternView(NewFilePath, swExportFlatPatternOption_RemoveBends)

          End If

      Next vConfName

       

      'Close the document

      swApp.CloseDoc (swModel.GetTitle)

       

      End Sub