*Lisp to auto increment 1 attribute value in 2 places*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I work with AutoCAD Electrical (2018). I've looked around the forums for a lisp that will allow me to increment a single attribute value in 2 different places, either automatically after being copied, or with a command. I have found some that are almost there, but nothing that really fits right. I'm hoping that I can get help here.
In the example below, I want to increment the value inside the brackets by some number (1 character), and increment the value outside the bracket by some number (1 character), using one command, making only one selection. The character string format of the attribute value is crucial and should remain {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}M_XXXXX. The "M_" should never change. My thinking is that the characters in the string increment up by 1 (in the case of a "9" it would role over and start at "1" again) so that the auto-incrementing will always cause previously like values to remain like values after the incrementing. In this example, the Source block gets its own unique handle, located outside the bracket, so AcadE knows which block is the primary. The "Ref Blocks" are linked to the "Source Block" because they share the same unique text string located inside the brackets.
Source Block "A" REFONLYLINKGUID value - {4DFDE12A-48E6-48F2-A7A7-A914EF917F37}M_41975
Ref Block "A1" REFONLYLINKGUID value - {4DFDE12A-48E6-48F2-A7A7-A914EF917F37}
Ref Block "A2" REFONLYLINKGUID value - {4DFDE12A-48E6-48F2-A7A7-A914EF917F37}
The reason I want a lisp is, we use design templates (AcadE .wdp files) and frequently duplicate these templates multiple times within a main project (.wdp) file. Changing some equipment data prior to adding the new drawings to the main project file ensures all common designs have unique equipment IDs (i.e. no duplication). The problem is that these "Source" and "Reference" relationships within the REFONLYLINKGUID attribute are preset inside of the design templates, so they are already related when we go into design. In any given drawing there could be scores of these unique REFONLYLINKGUID relationships set-up between various blocks; in an entire project file, there could be hundreds. The only way we can make them unique values, at this point, is to manually change every REFONLYLINKGUID attribute value in the new design so that it matches and links together, but doesn't match and link back to the previous design it was copied from. If it works the way I envision it, the result of running this "REFONLY_CHG" command will produce the following result, based on what you saw in the previous example:
Source Block "B" REFONLYLINKGUID value - {5EGEF21B-59F7-59F3-B8B8-B125FG128G48}M_52186
Ref Block "B1" REFONLYLINKGUID value - {5EGEF21B-59F7-59F3-B8B8-B125FG128G48}
Ref Block "B2" REFONLYLINKGUID value - {5EGEF21B-59F7-59F3-B8B8-B125FG128G48}
I know it's a lot to ask, but if you feel you can help, I think something like this would benefit others as well.