Lisp to obtain Attribute value to Rotate Block

Lisp to obtain Attribute value to Rotate Block

Anonymous
Not applicable
3,905 Views
23 Replies
Message 1 of 24

Lisp to obtain Attribute value to Rotate Block

Anonymous
Not applicable

I have used many Lisp programs over the years, but have done very little programming. I am trying to find or create a Lisp program which will automatically rotate a block to the angle specified in an attribute contained in the block. In other words - if I change the attribute angle to 53 degrees, I want the block to rotate around its insertion point to an angle of 53 degrees. Eventually, I would like the program to work in 2 ways:  1.) By changing the attribute as I described, or 2.) By specifying the angle when inserting the block (which will place the block at the appropriate angle and change the att txt to the angle spec'd on insertion.  Any help with this would be GREATLY appreciated.

 

Dustin

0 Likes
3,906 Views
23 Replies
Replies (23)
Message 21 of 24

dlanorh
Advisor
Advisor

Attached is updated lisp file. The check for the new blocks wasn't working properly and causing an error instead of exiting gracefully.

I am not one of the robots you're looking for

0 Likes
Message 22 of 24

dlanorh
Advisor
Advisor

Disregard the above. There was a spelling mistake in a variable name. Attached is update lisp.

I am not one of the robots you're looking for

0 Likes
Message 23 of 24

Anonymous
Not applicable

Thank you vetry much....I wanted to point out before that you could feel free to make the "host block" for the antennas however you wanted - with the text justified to center (as it should have been in the first place) ......as long as the block is on layer "0" and color/linetype is bylayer - it would be fine. As far as the block pointing straight East with a "0" Azimuth - that of course is incorrect...."0" Azimuth is pointing North - or at 90deg.....which I am sure you understand. Anyway, I am sorry - I have been swamped and have not had a chance to try out the LISP, but I promise I will asap - and let you know how it works. I really appreciate all your help. Thank you.

0 Likes
Message 24 of 24

dlanorh
Advisor
Advisor

@Anonymous wrote:

Thank you vetry much....I wanted to point out before that you could feel free to make the "host block" for the antennas however you wanted - with the text justified to center (as it should have been in the first place) ......as long as the block is on layer "0" and color/linetype is bylayer - it would be fine. As far as the block pointing straight East with a "0" Azimuth - that of course is incorrect...."0" Azimuth is pointing North - or at 90deg.....which I am sure you understand. Anyway, I am sorry - I have been swamped and have not had a chance to try out the LISP, but I promise I will asap - and let you know how it works. I really appreciate all your help. Thank you.


I haven't changed anything in the blocks, they are all on layer "0" and bylayer apart from some bolt entities in a sub block of the 5G block which were red and I left them like that.

 

The blocks are orientated East as this is the "0" Autocad default. When the blocks are inserted this will be the default, however one of the lisps included in the file above (c:r2az) allows you to select multiple blocks and rotate them to the desired azimuth entered by the user. The lisp accounts for the difference between AutoCAD (0 = East CounterClockwise) and Azimuth (0 = North Clockwise) when setting the required rotation. This has been implimented in this fashion because the "rotation" property of blocks is always AutoCAD standard.

I am not one of the robots you're looking for

0 Likes