- Oh no! An error has occurred!
- You need to be logged in to do that.
- You need to be logged in to do that.
- You need to be logged in to do that.
-
Coinciding with the acquisition of VIA Development, Nate joined Autodesk in March of 2003 after a decade stint as an entrepreneur following a two-decade stint as a controls engineer and software applications developer at Owens-Corning. Nate is now the lead product architect for AutoCAD Electrical. He loves this stuff.
-
Flipping attribute justification on a mass scale - AutoCAD Electrical
June 13, 2007, 12:41 AM Nate HoltThis blog has included a lot of custom applications and utilities over the last year that make use of the AutoCAD Electrical "API". And it's nice when some readers come through with some of their own creations. Here's one from Gerald te Wierik of Aceri Nederland. He has legacy AutoCAD Electrical projects that need to have a certain attribute on a certain block insert flipped from left to right justification. These things can be scattered everywhere in the project drawing set.

Now, he could carefully go through the drawings and locate each instance and make the adjustment. But why spend a lot of time doing this when it's a heck of a lot more fun to create a little utility and do it automatically in a batch mode?
So, here's a sample of the challenge... a group of these arrow symbols need to have the visible attribute flipped to RJT. The block symbol name is HA1S1. Let's do it.
AutoLISP Utility

Here's the little AutoLisp utility that Gerald put together. It makes about three calls into the AutoCAD Electrical API. This is not absolutely necessary but it simplifies development. The rest of the program is straight AutoLISP.
Here's how it works...
1. First part builds a "selection set" of all instances of the target block insert "HA1S1".
2. Next the utility enters a "while" loop and process all instances of the HA1S1 blocks found on the active drawing.
3. A call is made to confirm that the block insert has the target attribute, WIRENO that needs to be flipped to RJT. If the attribute is present then another call is made to return specific information about this attribute. The key piece of information in this returned data list is the entity name of this attribute.
4. Now a call to (c:ace_chgjst...) is made, passing the entity name of the WIRENO attribute (held in "(caddr rtrn)") above. This function flips the attribute to RJT (because the function's last argument is an "R" which flags "RJT").
5. Then the program increments a counter and loops back to process the next one until all are finished.
To run (single drawing)...
1. APPLOAD the above utility (you can download a copy here).
2. For single drawing, type WireNoRight [Enter] at the AutoCAD command prompt.
To run in batch mode...
One way is to use AutoCAD Electrical's "Project-wide Utilities" command. Make sure you save the utility to a folder that is somewhere in the ACAD path. Then enter the following into the edit box as shown below:
(load "WireNoRight.lsp")(c:WireNoRight)
Select OK, select the project drawing to process, and that's it.

Here's an example of the results:

And here's a happy Gerald te Wierik ...!

You must be logged in to post a comment.