0 Replies Latest reply on May 11, 2018 8:29 AM by stephen.harris@zinwave.com

    Changing PartType problems

    stephen.harris@zinwave.com

      Can anyone help with using VB/Sax to change PartType for parts/components on a schematic?

       

      I have some code that attempts to update the PartType for certain parts on a schematic. I have an Excel spreadsheet that gives the new/updated PartType for particular parts (currently, based on the company part number attribute, but it could just as easily be based on PartType, or on schematic reference).

       

      But, I am seeing some very strange behavious: sometimes, the wrong parts get their PartType changed.

       

      So, for debugging, I modified the code so as to select just one component, and then to change its PartType. Depending on the part selected, this sometimes works. But sometimes changes the PartType for a compelely different (victim) component! However, the correct part is definately being selected. I proved this by adding a debugging attribute, after changing the PartType. And this debug attribute always gets added to the correct part, even when the PartType was changed on the wrong component.

       

      Is changing the PartType of a component allowed? I.E, is part.PartType = "a part" allowable?

       

      Key bits of code:

       

      Set parts = ActiveDocument.Components

       

      For Each part In parts

           ' code to select parts which I want to change

       

           was_name = part.Name

           If was_name = "R1" Then   ' for debugging purposes, only try changing one part. Manually edit this to select different components

                          part.PartType = "10K_0402"   ' the intention is to use a lookup table to define the new PartType depending on the part (or an attribute, e.g. company part number)

                          part.Attributes.Add "Debug", "debug - find me"

            End If

       

      Sometimes, e.g., for R1, this component did have its PartType successfully changed to "10K_0402", and also had the debug attribute added.

       

      But sometimes, e.g. R14, instead of R14 being changed, a seemingly random different component was changed. However, the debug attribute was added to the correct component (R14).

       

      Behaviour seems to be consistent when re-running the same change on the same schematic (I may have seen differences, but when being very careful to re-run under identiacl conditions, I get the same results). A schematic only needs very minor part differences to give different behaviour.

       

      There seems no apparent connection between the selected component and the victim component, nor between their PartTypes.

       

      Running the script a 2nd time, in theory, should have no further effect. But instead, all component that share the updated PartType ('10K_0402' in the above example) get their attributes reset to the default values (in my case, the only attrivute that changes is the "Fitted" atribute, and all parts of the given PartType revert back to being "Y").

       

      (Running PADS VX.2.3, but had te same issues when ruuning PADS VX.1.1. Updating did not fix this issue.)