AnsweredAssumed Answered

Problems using getactiveconfiguration while traversing assemblies

Question asked by Harold Black on Apr 8, 2019
Latest reply on Apr 8, 2019 by Harold Black

I completed my coding project of extracting a weldment cutlist where it collects all the structural members with their lengths whether it's a part file, assembly file, assembly file with sub assemblies and/or parts, or any combination part/assembly components. I've decided that I now want to create a detailed excel table, where there are headings for each component (part) in an assembly and also shows the component title from the custom properties, "Core Frame" for the example table below. I've attached a screenshot example showing what the display for each component should look like.

Weldment Cutlist.png

My code works perfectly except for when I need to extract the custom property "Title" from each part file. I can better describe the issue I'm having if I lay it out below as follows...


If I use

Private Sub TraverseModel(model As Object, nLevel As Integer)

This works only on a part file. If I run my macro on an assembly, I get an error stating "Object doesn't support this property or method" on the line below.

Set swConfig = model.GetActiveConfiguration 'works on parts


The macro will run completely only if I comment out the bit of code that is written to extract the custom property "Title".


Set swConfig = model.GetActiveConfiguration 'works on parts

Set swConfigCustPropMgr = swConfig.CustomPropertyManager

vPropNames = swConfigCustPropMgr.GetNames

swConfigCustPropMgr.GetAll2 vPropNames, vproptypes, vpropval, resolved

For j = 0 To UBound(vPropNames)

If StrComp(vPropNames(j), "Title", vbTextCompare) = 0 Then

comp_name = vpropval(j)

End If

Next j


I've hit a roadblock that I just can't seem to figure out. I'm running SW2019.