Results 1 to 5 of 5

Thread: AutoLISP for calculating multiple areas, adding text and creating a table

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2023-02
    Posts
    1
    Login to Give a bone
    0

    Default AutoLISP for calculating multiple areas, adding text and creating a table

    Hello,

    I am looking for a LISP routine that would allow me to select multiple closed polylines, calculate their areas and place the areas (in the form of text) inside of the closed polylines. In addition, I need all of the areas placed into a table with the total of all the areas added up.

    Maybe I am asking for too much. Maybe this is a 2-step process. Any suggestions would help!

    Thank in advance

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: AutoLISP for calculating multiple areas, adding text and creating a table

    Have you searched the forums? Also, the similar threads at the bottom of this page provides links to threads the forum software believes are similar. One in particular is the Quick adding of multiple closed polyline areas
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: AutoLISP for calculating multiple areas, adding text and creating a table

    Like Opie so many examples also at Cadtutor & Forums/Autodesk/lisp

  4. #4
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: AutoLISP for calculating multiple areas, adding text and creating a table

    Lets start with the first part.

    Creating a selection set of closed polylines and getting the areas and totaling them.

    This code returns them as a list.

    P=

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard copyright 2023 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    ;
    ; Abstract: This routine allows the user to select closed polylines and return a list of individual areas
    ; and the total area of the selection set.
    ;___________________________________________________________________________________________________________|
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Comand line function list
    ;___________________________________________________________________________________________________________|
    
    ;* C:PA
    ;* Command Line function to add up areas of selected closed polylines
    
    ;* C:PolylineAreas
    ;* Command Line function to add up areas of selected closed polylines
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General Function Header List
    ;___________________________________________________________________________________________________________|
    
    ;  Function List Argument1 Argument2 Arguement3
    
    ;* (PolylineAreas ssSelections)
    ;* Function to convert a selection set of closed polylines to a list of areas with total area
    
    ;* (SelectionSetToList ssSelections)
    ;* Function to convert a entity based selection set to a list.
    
    ;$ End Header
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Command Line function to add up areas of selected closed polylines
    ;___________________________________________________________________________________________________________
    
    (defun C:PA ()(C:PolylineAreas))
    
    (defun C:PolylineAreas (/ ssSelections)
     (if (and (princ "\nSelect Closed Polylines: ")
              (setq ssSelections (ssget (list (cons 0 "polyline")(cons 66 1))))
         )
      (PolylineAreas ssSelections)
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Function to convert a selection set of closed polylines to a list of areas with total area
    ;___________________________________________________________________________________________________________
    
    (defun PolylineAreas (ssSelections / lstAreas lstObjects sngArea )
     (if (and (setq lstObjects   (SelectionSetToList ssSelections))
              (setq lstAreas     (mapcar 'vla-get-area lstObjects))
              (setq sngArea      (apply '+ lstAreas))
         )
      (reverse (cons sngArea (reverse lstAreas)))
     )
    )
    
    ;___________________________________________________________________________________________________________ 
    ;
    ; Function to convert a entity based selection set to a list.
    ;___________________________________________________________________________________________________________
    
    (defun SelectionSetToList (ssSelections / entSelection intCount lstObjects objSelection )
     (repeat (setq intCount (sslength ssSelections))
      (and (setq intCount (1- intCount))
           (setq entSelection (ssname ssSelections intCount))
           (setq objSelection (vlax-ename->vla-object entSelection))
           (setq lstObjects   (cons objSelection lstObjects))
      )
     )
     lstObjects
    )
    
    (princ "!")
    (vl-load-com)
    Attached Files Attached Files
    AutomateCAD

  5. #5
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    0

    Default Re: AutoLISP for calculating multiple areas, adding text and creating a table

    This was kinda fun to a ran with it.

    Here is the first routine modified to put area text into the polylines.

    It also groups them.

    You cannot copy the groups.

    You can rerun the program selecting polylines again.

    You can also add the layer you want the "AREA Polylines" To be on.

    P=

    You will have to look at the attachment. The code is too long for 10000 characters
    Attached Files Attached Files
    AutomateCAD

Similar Threads

  1. calculating polygons areas using autocad field
    By franciscorefosco in forum AutoCAD Customization
    Replies: 14
    Last Post: 2017-03-26, 04:57 AM
  2. RAC 2009 - Best Practices for calculating surface areas, etc.
    By designviz in forum Revit Architecture - General
    Replies: 2
    Last Post: 2009-08-07, 01:56 PM
  3. Quick adding of multiple closed polyline areas
    By CBLENDERMANN in forum AutoLISP
    Replies: 6
    Last Post: 2008-05-29, 04:21 PM
  4. Areas - Removing Columns from Floor Areas
    By ddavison.33993 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2006-02-18, 02:39 PM
  5. Calculating Areas
    By johnsonr in forum CAD Management - General
    Replies: 2
    Last Post: 2004-09-10, 04:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •