AnsweredAssumed Answered

Macro to Rename Imported Parts

Question asked by Daniel Smith on Dec 3, 2015
Latest reply on Dec 3, 2015 by Daniel Smith

I have an issue with imported step files from Altium causing conflicts when they are put into a single assembly due to name conflicts between auto generated Imported body names, which are highlighted in the attached image. I have a macro right now that can transverse through the assembly and rename the lowest level part files with the following logic (all credit to Deepak Gupta):

 

swApp.SetUserPreferenceToggle swExtRefUpdateCompNames, False

   For i = 0 To nLevel - 1

        sPadStr = sPadStr + "  "

    Next i

    vChildComp = swComp.GetChildren

    For i = 0 To UBound(vChildComp)

        Set swChildComp = vChildComp(i)

        Set swChildModel = swChildComp.GetModelDoc

        If swChildModel.GetType = swDocPART Then

        swChildComp.Select2 False, 0

        'Get configuration name

        swCompConfig = swChildComp.ReferencedConfiguration

        'Get Configuration Properties Values

        NewName = "testname"

        swChildComp.Name2 = NewName

        Debug.Print swChildComp.Name2

         End If

        TraverseComponent swChildComp, nLevel + 1

    Next i

    swApp.SetUserPreferenceToggle swExtRefUpdateCompNames, bOldSetting

 

I think it is the highlighted If statement that selects the sldprt files and then goes on to rename them. I can't figure out how to modify the script so it can instead stop traversing at the part and then rename (or more preferably add a suffix to the existing name) the imported parts highlighted in the attached image? If I could figure that out it would stop my ID collision issue. And unfortunately Pack-and-Go doesn't work for me because it does not actually rename everything down the hierarchy, causing the collisions to still take place.

 

reanmeimportedparts.JPG

Outcomes