Add attributes to selected components or pins sequentially

Version 2

    With addition of Common Properties in DxDesigner 2007, the "attr" command was removed.  The "attr" command was a very powerful way to apply an attribute to the selected objects, including expansion of bus ranges.

     

    One typical use of the "attr" command was to apply connector pin numbers.  To apply pin numbers from 1 to 10, you could select each connector pin symbol, and type "attr #=[1:10]" into the command line toolbar, and the pin numbers were assigned in order.

     

    However, even this powerful command had a drawback, you had to individually select each item in the proper order - selection by dragging the mouse could result in the attribute values being applied unpredictably.

     

    The attached script restores the "attr" command, and enhances the behavior by applying the expanded attribute value in graphical order (top to bottom, then left to right).  In addition, the command can handle properties that have a space in the name, such as "Ref Designator" or "Pin Number".  When adding properties that are defined as a Pin property, the script will automatically select the pins of selected components, and apply the attributes to the pins.  And finally, the command can also map from the "legacy" attribute names to the common property name using the map.cfg file.

     

    To run the script, extract the AttrSequence.vbs file to a directory in your WDIR environment variable.  Load the script on startup in the scripts.ini file:

     

    [viewdraw]

    Script#0=AttrSequence.vbs

     

    If you already have a [viewdraw] section in your scripts.ini, increment the Script# to the next available number with no gaps.

     

    Invoke DxDesigner and open a schematic.  To test the behavior on connector symbols, add a bunch of single pin connector symbols.  Select them using a drag selection, hit the space bar, and enter the command "attr REFDES=J1".  All the selected components will have the Ref Designator property set to the value J1.  Then hit the space bar again, and enter the command "attr #=[1:10]", and the Pin Number property on each pin will have the value from 1 to 10 based on the symbol's graphical position.

     

    The attribute value supports the following expansion:
         {string}n - repeats the string n times
         [start:stop:step] - counts from start to stop in increments of step; step is assumed to be 1 if not specified
         a,b,c - comma separated list of values

     

    The {}, [], and comma values can be given in any combination, they are evaluated in that order. For example,

         {A}3,B[2:6:2],C,D

     

    will expand to

         A, A, A, B2, B4, B6, C, D

     

    Examples:

     

         ' Assign all connector pins to the same physical component:
         attr refdes=J1

     

         ' Assign the connector pins from 31 to 1
         attr #=[31:1]

    Let me know if there are any use cases that have been overlooked.

     

    John

     

    P.S. This has been tested with DxDesigner 2007.3 and 2007.5 on Windows.