3 Replies Latest reply on Feb 22, 2017 2:17 PM by Deepak Gupta

    Macro to Extract "Cutting Length-outer" (evaluated value) from flat layout of sheet metal parts?

    Richard Abraham

      Hi

       

      I am looking to create a macro that when applied would automatically extract the required dimension (Cutting Length-Outer- example) from a flat layout of a sheet metal part (DXF)

       

      Any help with suggestions would be great!

       

      Thanks

      Richard

        • Re: Macro to Extract "Cutting Length-outer" (evaluated value) from flat layout of sheet metal parts?
          Deepak Gupta

          You can use the bounding box dimensions from the model to get the desired output.

            • Re: Macro to Extract "Cutting Length-outer" (evaluated value) from flat layout of sheet metal parts?
              Richard Abraham

              Thanks for your response Deepak. I already know what the value I am looking for is (From cut list Properties). How can i create a macro that will first convert a part into a flat pattern and then extract the values (for example cut offs) and return the value in a form such as excel or even within solidworks? I have several parts and I dont want to have to open the properties for each one and get them in that way.

               

              Your help is appreciated.

               

              Richard

                • Re: Macro to Extract "Cutting Length-outer" (evaluated value) from flat layout of sheet metal parts?
                  Deepak Gupta

                  Richard, you can link a note in the drawing to the required property.

                   

                   

                   

                   

                  You can also use a macro to export that property value to an excel file. I'll try to write the macro tomorrow as I'm tired and sleepy now (time to get into bed).

                   

                  Well I found one I did few months back for someone. Here are the codes to extract the value. It will print the value in the macro itself.

                   

                  Option Explicit
                      Dim swApp               As SldWorks.SldWorks
                      Dim swModel             As SldWorks.ModelDoc2
                      Dim swFeat              As SldWorks.Feature
                      Dim swCustPropMgr       As SldWorks.CustomPropertyManager
                      Dim strValue            As String
                      Dim strValueOut         As String
                  Sub main()
                      On Error Resume Next
                      
                      Set swApp = Application.SldWorks
                      Set swModel = swApp.ActiveDoc
                      Set swFeat = swModel.FirstFeature
                  
                          Do While Not swFeat Is Nothing
                              If swFeat.GetTypeName() = "CutListFolder" Then
                                  Set swCustPropMgr = swFeat.CustomPropertyManager
                                  swCustPropMgr.Get4 "Cutting Length-Outer", False, strValue, strValueOut 'Change Property Name
                                  Debug.Print strValueOut
                                  Exit Do
                              End If
                          Set swFeat = swFeat.GetNextFeature
                          Loop
                  End Sub