AnsweredAssumed Answered

Export custom properties of selected parts

Question asked by Mark Coville on Oct 25, 2012
Latest reply on Nov 5, 2012 by Mark Coville

Hello All,


I have been trying to create this macro for awhile with no luck. I want to export specific custom properties from all the parts I select in an assembly by click and drag on the screen. The goal eventually would be to export the custom properties "ShippingWeight" & "OperatingWeight" of the 50 or so parts I selected into excel so I can get totals. Here is what I have so far but I am lost. Thanks in advance.


Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim selmgr As SldWorks.SelectionMgr
Dim comp As SldWorks.Component2
Dim cpm As CustomPropertyManager
Dim valOut              As String
Dim resolvedValOut      As String

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set selmgr = swModel.SelectionManager
    For ii = 1 To selmgr.GetSelectedObjectCount
        Dim partinfo As String
        Dim Part As SldWorks.ModelDoc2
        Set comp = selmgr.GetSelectedObject3(ii)
        Set Part = comp.GetModelDoc2
        Set cpm = swModel.Extension.CustomPropertyManager("")
        partinfo = "Name:" + comp.Name + vbNewLine + _
                   "Config:" + comp.ReferencedConfiguration + vbNewLine + _
                    "Size:" + cpm.Get2("Size", valOut, resolvedValOut)
        MsgBox (partinfo)

End Sub