Thursday, July 8, 2010

A Macro for Aligning Text, MText and Block Entities Horizontally and Vertically in AutoCAD LT

It has been a long time since I made my last post here. I was seriously thinking of dropping the blogging activities, mainly due to lack of unique ideas. But when I received an email request from a AutoCAD LT user for a macro for aligning objects like Text entities, I couldn't resist trying it out and sharing it with you people. My sincere apologies to all readers for leaving such a long gap. That said, to be honest, I don’t have any idea when I am going to publish my next tip over here.

Back to our post topic. These macros can be used to align entities like Text, Mtext, Blocks and literally any object that comes with an insertion base point, both horizontally and vertically.That means you can use this macro to align a Text entity with an MText or Block Reference. The only limitation you will come across is that you will have to select the entities one by one as opposed to selecting all together in AutoLISP or VBA programs.

You have already seen the power of combining DIESEL with the CAL command (I call it DIECAL for ease of use). Once again, I am going to use the power of DIECAL to accomplish our task. Here goes the first macro, used for aligning entities vertically.


For you to get an idea how it works, please find the image below consisting of different types of entities.


The next picture illustrates what the align vertical macro can do with these entities.


With a small modification in the macro, you can use it to align these entities horizontally as well. Here is the modified macro for horizontal alignment.


And here is the illustration of the macro functionality.

Before running the macro.


After running the macro.


These macros have been tested in AutCAD LT 2011 and works fine over there. I hope it will work with previous versions also, at least in the recent versions of AutoCAD LT. If you come across any problems, please feel free to post it here.

Many thanks to Adam for inspiring me to develop this :-)

1 comment:

Hubert Roguski said...

Thank you very much.