AnsweredAssumed Answered

Electrical Routing API

Question asked by Rick Hombsch on Dec 23, 2015
Latest reply on Dec 28, 2015 by Mike Spens

I am trying to write a macro that runs through all components in an assembly and pulls out some information from all electrical routes. The info I am trying to pull is then given name of the route as well as the length of the route.


I have not found any info on accessing this information from a macro so any information would be helpful.





Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc


ConfigNames = Part.GetConfigurationNames

'Determine How Many Configurations Part Has

LastConfig = UBound(ConfigNames)


For k = 0 To LastConfig

    'Set Config to ith Configuration

    Config = ConfigNames(k)

    Part.ShowConfiguration2 (Config)


    Name = Part.GetTitle


    'If assembly

    If InStr(1, Name, "SLDPRT", 1) = 0 Then

        Component = Part.GetComponents(False)

        NumberOfComponents = UBound(Component)

        'For all components in assembly

        For i = 0 To NumberOfComponents


            ComponentName = Component(i).GetSelectByIDString

            Suppression = Component(i).GetSuppression()



            If Not Suppression = 0 Then

                Dim SubComponent As SldWorks.ModelDoc2

                Set SubComponent = Component(i).GetModelDoc2()

                ComponentType = SubComponent.GetType

                CompConfig = Component(i).ReferencedConfiguration

                PreferedPart = SubComponent.CustomInfo2(CompConfig, "PreferedPart")


                ComponentType = 2

            End If




            Name = Replace(Name, ".sldasm", "", 1)

            ComponentName = Replace(ComponentName, "@" & Name, "", 1)

            'Insert Code Route ID Code Here

        Next i

    End If

Next k