Display full version of the post: display of areas combined with calculation

nickoh
13.04.2013, 23:32
hi.maybe somebody nows a way to save me some days of very dumb work...i have many areas / closed polylines on different layers in autocad 2013.what i do now is click on each polyline to get the area from the properies display. then i multiplicate it with a certain number (which is different on most layers but stays the same within one layer). then i write the result in a multileader (the multileader also contains an abbrevation wich is also different on the different layers but stays the same within one layer) for each area / polyline and put it to the right position (so it wont block any other information on the plan). i have to do all this for a big amount of areas / polylines on several layers.is there a possibility to automate this at least a bit? maybe with some kind of attribute or text field???in other words:i have a planting plan. each layer is one plant-species. each species has several areas where it should be put.one m² of plant A is 3 pieces, one m² of plant B is 5 pieces, one m² of plant C is 10 pieces and so on.i need to display the plant name and the number of plants for each area.does anybody have an idea??thanks a lotcheersnickoh

Kent Cooper
15.04.2013, 15:58
I would go about it like this:
Make some lists, one with Layer names, one with abbreviations for the plant names, one with the multipliers [quantity of plants per square meter]:
 
(setq
  layers '("LayerA" "LayerB" "LayerC")
  abbs '("AXZ" "BTW" "CPM"); abbreviations for plant names
  mults '(3 5 10); multipliers for plant quantity per sq meter
); setq
 
Select your Polylines, or have the routine select all Polylines.  Step through the selection, and for each, make the Polyline a VLA object, stored in a variable [here, plobj].  Then do something like this:
 
(setq
  pos (vl-position (vla-get-Layer plobj) layers); its Layer's position in the list
  qua (* (fix (vla-get-Area plobj)) (nth pos mults)); the quantity of plants for that area
  str (strcat (itoa qua) " " (nth pos abbrevs)); the text string [rearrange/add to the pieces as desired]
); setq
 
Depending on your Units settings, you may need to convert the Area property to square meters with a calculation.
 
You can use the bounding box to find the middle of the extents of the Polyline's area, if that's a good basis for positioning Text or a Leader start point or something.  Or you can leave that to the User to pick.  You can have different Layers for the notation with another list, or use the Polyline's Layer; in either case, you would set that Layer current for the Text/Leader/whatever.
 
Consider also testing whether each Polyline is closed, or is on one of the appropriate Layers, etc., before applying the process to it.  [A Layer check would be essential if you're having the routine select all Polylines.]
Your use of the word multileader makes me wonder whether you are using one designation of quantity for more than one Polyline area.  That would make it more complicated, and would, I assume, require User selection of which Polylines to tag collectively.  If you are doing it for each Polyline individually, I would think an ordinary Leader, or even just a piece of Text, would do.  If it's just Text, you could have it middle-justified at the midpoint of the bounding box automatically, and look around afterwards for any that need to be repositioned, or you could leave it to the User for each one to designate a location.  That would actually be easier to accomplish than a Leader- or Multileader approach, unless you're willing to require all Leaders/Multileaders to be drawn with the same number of defining points.

nickoh
18.04.2013, 09:17
thanks.sounds complicated :-)i already expected the solution to be some kind of lisp.unfortunately i dont know anything about lisps yet. but i think i have to get into it anyway :-)its not multileaders but only one leader for each polyline.next time i have to do this i will learn how to do it instead of spending two days clicking :-)thanks!

heinsite
18.04.2013, 14:02
I'm just shooting from the hip here, but I'm thinking that using multileaders w/ fields representing the area of the closed (that part is important) polylines gets you individual area totals.  And for quantity by type totals I'd play with data extraction into tables on the plan itself... or to a spreadsheet.Dave.

nickoh
19.04.2013, 08:22
hi.multileaders with fields is what i used in the end.it was even possible to multiplicate it by 3 or any number.unfortunately there were several klicks involved for every leader, because i had to redo the settings for every field :-(i use dataextraction a lot, but in this case (i needed the area, etc displayed IN or at least next to each polyline) it did not help, or at least i did not find a way to make it help.of course the polylines were all closed.anyway i found that for some of them the area was not displayed in the preferences (that was how i got the area when i started) but this is a different topic.thanks again!cheersnico

heinsite
19.04.2013, 09:12
I just did this all rather quickly using multi-leaders.  Somehow you do have to collect information on each of many different areas, so if you don't come up with a method where data extraction works maybe the following will.Using a closed polyline I selected multi-leader, clicked on the polyline to set the arrowhead, then drag it out for the landing location and click again.  In the context sensitive menu select Field > Object > Object type (select the polyline) > Area (for the property).  From here you can configure the precision, etc.Once you do this the first time all the rest will be fairly easy, and some of the settings will "default' so you don't have to go thru the whole thing every time.  You can also use multiple fields in any leader text definition, and this may also give you ideas.Good luck!Dave.