*Lisp to auto increment 1 attribute value in 2 places*

*Lisp to auto increment 1 attribute value in 2 places*

Anonymous
Not applicable
2,495 Views
9 Replies
Message 1 of 10

*Lisp to auto increment 1 attribute value in 2 places*

Anonymous
Not applicable

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 selectionThe 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.

0 Likes
2,496 Views
9 Replies
Replies (9)
Message 2 of 10

pbejse
Mentor
Mentor

@Anonymous wrote:

Hi All,

 

 

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....

.... 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.


The source block "A" and ref block "A1" and "A2" are the same block definition? or a different named block? or you meant block object "A" "A1" and"A2"?

 

The integer value character for increment is the first character after the bracket of the string ? or after every hyphen? That part you need to explain more, i just don't see it right away from the examples string value you posted.

 

Its not a lot to do, you need to be clear about what you're asking.

 

 

 

0 Likes
Message 3 of 10

Anonymous
Not applicable

Thank you for showing interest in this.

 

The source block "A" and ref block "A1" and "A2" are the same block definition? or a different named block? or you meant block object "A" "A1" and"A2"?

 I mean that "A", "A1" and "A2" are separate block objects shown on separate drawings.  Block "A" has a different block name than "A1" and A2".  "A1" and "A2" are typically the same block name and definition because they are representing the same object, shown in two different locations within the drawing set.  However, block "A1" and "A2" maybe have a different block name, like in the example below. 

Example:

"A" Block Name = HPR2_TBL_OUT.dwg 

"A1" Block Name = VPR21_OUT_4DO.dwg

"A2" Block Name = VPR21_OUT_4DO_compact.dwg

 

The integer value character for increment is the first character after the bracket of the string ? or after every hyphen? That part you need to explain more, i just don't see it right away from the examples string value you posted.

I think that incrementing the first character after every hyphen of the string in the bracket would suffice. 

 

In a nutshell, I'd like to be able to type "REFONLY_CHG" into the command line, have a dialog box pop-up that allows me to select a given number of DWG files in a folder, after the selection is confirmed, the routine searches all selected DWGs for this REFONLYLINKGUID attribute, and increments the 1st integer after every hyphen in the value up by 1 character (whether it's a number or a letter). 

0 Likes
Message 4 of 10

pbejse
Mentor
Mentor

@Anonymous wrote:

Thank you for showing interest in this.

 

....I think that incrementing the first character after every hyphen of the string in the bracket would suffice. 


"Are you telling us, up to this point you're not sure what the conditions are?

 


@Anonymous wrote:

... the routine searches all selected DWGs for this REFONLYLINKGUID attribute, and increments the 1st integer after every hyphen in the value up by 1 character (whether it's a number or a letter). 


If possible post  samples of the selected dwgs?  Source and Reference. Also, show what the final result will look after running "REFONLY_CHG"

 

0 Likes
Message 5 of 10

Anonymous
Not applicable

"Are you telling us, up to this point you're not sure what the conditions are?"

 

Not at all.  I'm saying that the condition is to increment the character string in such a way that it maintains its original format, becomes unique, and never increments to match an existing value.  The best solution is to increment all characters (letters and numbers only) inside the brackets.

 

 

"If possible post samples of the selected dwgs?  Source and Reference. Also, show what the final result will look after running "REFONLY_CHG"

 

 Attached are the DWGs you requested. 

0 Likes
Message 6 of 10

Anonymous
Not applicable

The attached Word doc contains screenshots of what I'd like to see in the final result.  In each instance, the value of the attribute tag "REFONLYLINKGUID" is visible.  The "BEFORE" screenshots show the original REFONLYLINKGUID value, the "AFTER" shots show the REFONLYLINKGUID value after running "REFONLY_CHG" (each letter and number incremented up by 1 character).

 

I hope this helps, and again, thank you for your time and attention to my problem.

0 Likes
Message 7 of 10

pbejse
Mentor
Mentor
OK then, I'll see what I can do..

Stay tuned for the next episode....
0 Likes
Message 8 of 10

pbejse
Mentor
Mentor

After selection of files to be processed, Will the program change the "REFONLYLINKGUID" tag value of REF drawings regardless of what the current value is? or it needs to match the current value of the SOURCE block?

 

Is there only 1 of these blocks in every selected drawing? and are they located in Model space?

The source file block is always named "HPR2_TBL_OUT_4DO(P)"?

 

Watch this video 

pending your reply.....

 

 

Screencast will be displayed here after you click Post.

4743194b-8681-4f7d-9923-f05ede329cbd

 

0 Likes
Message 9 of 10

pbejse
Mentor
Mentor

@pbejse wrote:

 

 

 

 


Odd, the screencast video did not come in on my previous post. 

 

Anyhoo, refer to the attached file for the demo video.

 

 

0 Likes
Message 10 of 10

Anonymous
Not applicable

"After selection of files to be processed, Will the program change the "REFONLYLINKGUID" tag value of REF drawings regardless of what the current value is? or it needs to match the current value of the SOURCE block?"

 

Yes, the program will change the REFONLYLINKGUID value regardless of what the current value is, but the program must also change the corresponding Source block to match it. After the change, the REFs new REFONLYLINKGUID value (inside the brackets) must match the Source's value inside the brackets. If the REFs change independent of the Source, and the Source maintains its current value, they will lose their link to the Source.  The practical application of this comes when we copy these Source and REF blocks in a common design.  We want the “old” Source and REF blocks to maintain their link with the “old” REFONLYLINKGUID value, and the “new” Source and REF  blocks to remain linked like they were previously, but with a “new” REFONLYLINKGUID value.  This means that both sets, though copies of one another, are two separate sets of Source and REF blocks. 

 

"Is there only 1 of these blocks in every selected drawing? and are they located in Model space?

 

No, there are many blocks in every selected drawing. What I sent you as an example represents a single row from a single Device Table (that has close to 40 rows), in a drawing that has many unique Device Tables with their own unique REFONLYLINKGUID attributes. Each row drives information to multiple unique  REF symbols throughout the drawings.  Yes, they are all located in Model Space.

 

"The source file block is always named "HPR2_TBL_OUT_4DO(P)"

 

No. The Source blocks have many different block names. All Source block names contain "_TBL_".

 

I liked the interface that I saw in the screencast. One point of feedback I have is the single REFONLYLINKGUID generator. Given the volume of REFONLYLINKGUID attributes that have to be changed, generating a single random value for each would mean running this command over 100 times, possibly closer to 200, on an average project. This was the reason I initially wanted to automatically index the character strings in the beginning. If the character strings for the Source and REF symbols match to begin with, incrementing the REFONLYLINKGUID values by the same number means they will continue to match up after the command changes them. 

 

Please let me know if you need more examples.  If I can help by providing a screencast with a larger sample size to illustrate this.

0 Likes