AutoCAD Lisp to Automatically fill in already created Attributed Block

AutoCAD Lisp to Automatically fill in already created Attributed Block

Anonymous
Not applicable
1,736 Views
8 Replies
Message 1 of 9

AutoCAD Lisp to Automatically fill in already created Attributed Block

Anonymous
Not applicable

Hi,

I've already created and Attributed block with a Room Name, Room Use, Area and Perimeter part but was wondering if there is a way via Lsp to Auto populate the Area and Perimeter by picking a polyline and then the block. Currently I have to manually fill these fields in which on large drawings is a chore.

Any help is appreciated.

cheers

0 Likes
Accepted solutions (3)
1,737 Views
8 Replies
Replies (8)
Message 2 of 9

David_W_Koch
Mentor
Mentor
Accepted solution

Welcome to the community!

 

Are you using AutoCAD Architecture (the subject software of this forum)?  If so, Spaces and Space Schedule Tags could take care of all of that, without the need to do anything other than place the Space and tag it.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

Message 3 of 9

Anonymous
Not applicable

Hi David,

Thanks for the reply. I am using AutoCAD Architecture but I have to export the drawing into a facilities management system which can only accept attributed blocks and I also have to save it back as ACAD2010.

0 Likes
Message 4 of 9

pendean
Community Legend
Community Legend
Accepted solution
Instead of "saving bacck" you should be "exporting to autocad" and the program will then explode all AEC content to stock AutoCAD entities. That way you can use the tools you have at hand for the task.

Try it, its worth testing.

0 Likes
Message 5 of 9

Anonymous
Not applicable

thanks to everyone for the replies.

Will plod on me thinks. 🙂 🙂

0 Likes
Message 6 of 9

David_W_Koch
Mentor
Mentor

If that is your workflow, it would be possible to write an AutoLISP routine to do what you ask.  I do not have one, but it is possible.  Care to post a sample drawing that has your attributed block in it (the AutoLISP code will need to know the attribute definition tag names)?  I may not be able to get to this in a timely manner, but I should be able to put something together, eventually.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

0 Likes
Message 7 of 9

Anonymous
Not applicable

Hi David,

They way I have to do my drawing is governed by the software I have to import it into so that's why I have to use the attributed block route. Any help would be much appreciated. If you could sort something out then that would be brilliant. Whenever you can fit it in is totally fine.

0 Likes
Message 8 of 9

David_W_Koch
Mentor
Mentor
Accepted solution

The attached AutoLISP file should do what you want (with some tweaking, perhaps).  It defines a command called AP2TAG, which prompts the user to select a Polyline, and then a Room Tag Block.  If the user fails to select the desired object, a second chance is offered (or the user can quit).

 

The user is notified if the block reference selected has no Attributes.  If it has Attributes, they are examined one by one, and if the Attribute Tag is "AREA", then the Area value from the Polyline is pushed to that Attribute as its new value; if the Attribute Tag is "PER", then the Perimeter (Length) value is pushed to that Attribute as its new value.  There are command line prompts noting that the Area or Perimeter have been updated.  If Attributes with those Tags are not found, the program ends without any notice to the user.

 

Your drawing length units are millimeters with two-decimal-place precision, and your Area unit is set to square meters with two-decimal-place precision.  The value entered into the tags for "H" (which I assume is height) appear to be in meters.  I assumed that you would want the values in square meters (Area) or meters (Perimeter), so I divided the Area by 1000000 mm2/m2 and the Perimeter by 1000 mm/m, and then formatted the strings to be pushed to the attributes to have two-decimal places.  All of that can be adjusted, if you prefer.


David Koch
AutoCAD Architecture and Revit User
Blog | LinkedIn
EESignature

0 Likes
Message 9 of 9

Anonymous
Not applicable

Hi David, Thanks for your help with this. That is perfect. It works like a dream. I can't thank you enough.

The height field you mention is more indicative and is rarely changed to be fair. 

cheers

Phil  👍

0 Likes