See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: I need the area of a polyline in sq. ft, not sq. in.

  1. #1
    Member jtaylor.82814's Avatar
    Join Date
    2005-02
    Location
    Houston, TX
    Posts
    2
    Login to Give a bone
    0

    Question I need the area of a polyline in sq. ft as text, not sq. in.

    I tried the lisp by Luis Esquivel posted by Miff on September 9th, 2004 but when I use it, it puts my area in sqare inches with a tag of square feet. I thought if I changed my units it might work, but it didn't. I dont think it matters any but I run on ACAD 2002. If any one has a better script or any suggestions it would be greatly appreciated.

    THX
    Last edited by jtaylor.82814; 2005-02-24 at 10:32 PM. Reason: Clearification

  2. #2
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    1

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    Find the line :
    (strcat (add-comma (rtos (vla-get-area vla_obj ) 2 0 ) ) " S.F." )
    and convert Your unit like
    (strcat (add-comma (rtos (/ (vla-get-area vla_obj ) 1000000 ) 2 0 ) ) " m2." )
    that convert an area 1000mm x 1000mm in to m2

    : ) Happy Computing !

    kennet

  3. #3
    Active Member
    Join Date
    2003-11
    Location
    YUL
    Posts
    75
    Login to Give a bone
    0

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    Well, it would be a good idea to post the code here, if you want someone to help you.

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    Well paulmcz
    lisp by Luis Esquivel posted by Miff on September 9th, 2004
    : ) Happy Computing !

    kennet

  5. #5
    Active Member
    Join Date
    2003-11
    Location
    YUL
    Posts
    75
    Login to Give a bone
    0

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    Sorry, I didn't know that he posted it right here.

  6. #6
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    1

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    Here's a modified version that checks the Lunits sysvar and reacts accordingly. Not intended for use in metric drawings at this time.
    Code:
    ;; =================================================
    ;; 2002 By Luis Esquivel
    ;; put the area in sq-ft of selected closed areas...
    ;; modified 11/22/03 by Jeff Mishler to allow use within
    ;; PS Viewport and to accept a Polyline that was created
    ;; by selecting the startpoint as the endpoint, technically
    ;; it is closed but the closed property isn't set.
    ;;
    ;; Command: PUTAREA
    
    ;;;(addtext <string> <point> <real>)
    (defun addtext (textstring insertionpoint height / aa)
      (vl-load-com)
      (setq aa (vla-get-activedocument (vlax-get-acad-object)))
      (vla-addtext
    	      (if (= 1 (vla-get-activespace aa))
    		(vla-get-modelspace aa)
    		(if (= (vla-get-mspace aa) :vlax-true)
    		  (vla-get-modelspace aa)
    		  (vla-get-paperspace aa)
    		  )
    		)
    	      textstring
    	      (vlax-3d-point insertionpoint)
    	      height)
      )
    
    (defun add-comma  (txt / strl cont1 lth cont txt1)
      (setq strl  (strlen txt)
     cont1 1
     txt1  "")
      (while (and (/= (substr txt cont1 1) ".") (<= cont1 strl))
        (setq cont1 (1+ cont1)))
      (setq lth   (1- cont1)
     cont1 1
     cont  (1- lth))
      (if (> lth 3)
        (progn
          (while (< cont1 lth)
     (setq let  (substr txt cont1 1)
           txt1 (strcat txt1 let))
     (if (and (zerop (rem cont 3)) (eq (type (read let)) 'INT))
       (setq txt1 (strcat txt1 ",")))
     (setq cont  (1- cont)
           cont1 (1+ cont1)))
          (while (<= cont1 strl)
     (setq txt1  (strcat txt1 (substr txt cont1 1))
           cont1 (1+ cont1)))
          txt1)
        txt))
    
    (defun get-last-coord (obj / COORDS LAST_COORD)
      (setq coords (vla-get-coordinates obj)
    	coords (vlax-safearray->list (vlax-variant-value coords))
    	coords (reverse coords)
    	last_coord (list (cadr coords)(car coords)
    			 )
    	)
      last_coord
      )
    
    (defun C:PUTAREA  (/ ent vla_obj pt objname vla_text aa lunit)
      (while (setq ent (entsel "\nSelect closed object: "))
        (setq vla_obj (vlax-ename->vla-object (car ent))
       objname (vla-get-objectname vla_obj))
        (if
          (vlax-property-available-p vla_obj 'area)
           (progn
      (if
        (or
          (= "AcDbCircle" objname)
          (and (wcmatch (vla-get-objectname vla_obj) "*Polyline")
    	   (or  (= :vlax-true (vla-get-closed vla_obj))
    		(equal (vlax-safearray->list
    		     (vlax-variant-value
    		       (vla-get-coordinate vla_obj '0)))
    		   (get-last-coord vla_obj)
    		   0.001)
    		)
    	   )
          )
         (progn
           (if (setq pt (getpoint "\nPick text placement: "))
      (progn
        (setq lunit (getvar "lunits"))
        (setq vla_text
        (addtext
          (strcat
            (add-comma
              (rtos
    	    (if (or (= lunit 3)
    		    (= lunit 4)
    		    )
    	      (/ (vla-get-area vla_obj) 144)
    	      (vla-get-area vla_obj)
    	      )
         2
         0))
            " S.F.")
          pt
          (getvar "textsize")))
    
        ;; alignment to left
        (vla-put-alignment vla_text acAlignmentCenter)
    
        (vla-put-textalignmentpoint
          vla_text
          (vlax-3d-point pt))
    
        ;; use current textstyle
        (vla-put-stylename
          vla_text
          (vla-get-name
            (vla-get-activetextstyle
       (setq aa (vla-get-activedocument
           (vlax-get-acad-object)))))))))
         (prompt "\nNot a closed object. ")
        ))))
      (princ))
    (princ)

  7. #7
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    ...mmm, and here is a way to do it in metric mm2
    Code:
    (defun c:InsertArea ( / Ent Ent Area Pkt )
      (if (setq Ent (entsel "\nCommand: Select a closed LWpolyline or a region : " ) )
        (progn
          (vl-load-com)
          (setq Obj (vlax-ename->vla-Object (car Ent )) ) ;; Only closed LWPolyline or regions are allowed
          (if (or (and (= (vlax-get  Obj "ObjectName" ) "AcDbPolyline" ) (= (vlax-get  Obj "Closed" ) -1 ) ) (= (vlax-get  Obj "ObjectName" ) "AcDbRegion" ) )
            (progn
              (setq Area (vlax-get  Obj "Area" ) )
              (vlax-release-Object Obj )
              (initget 7 )
              (setq Pkt (getpoint "and place the Area Text : " ) )
              (command "._text" "J" "MC" Pkt "" "" (strcat (rtos Area 2 0  ) " mm2" ) )
            )
            (princ "That object was not allowed."  )
          )
        )
        (princ "Miss, aim better !" )
      )
      (princ)
    )
    : ) Happy Computing !

    kennet

  8. #8
    Member jtaylor.82814's Avatar
    Join Date
    2005-02
    Location
    Houston, TX
    Posts
    2
    Login to Give a bone
    0

    Thumbs up Re: I need the area of a polyline in sq. ft, not sq. in.

    Quote Originally Posted by miff
    Here's a modified version that checks the Lunits sysvar and reacts accordingly. Not intended for use in metric drawings at this time.
    Code:
    ;; =================================================
    ;; 2002 By Luis Esquivel
    ;; put the area in sq-ft of selected closed areas...
    ;; modified 11/22/03 by Jeff Mishler to allow use within
    ;; PS Viewport and to accept a Polyline that was created
    ;; by selecting the startpoint as the endpoint, technically
    ;; it is closed but the closed property isn't set.
    ;;
    ;; Command: PUTAREA
    
    ;;;(addtext <string> <point> <real>)
    (defun addtext (textstring insertionpoint height / aa)
      (vl-load-com)
      (setq aa (vla-get-activedocument (vlax-get-acad-object)))
      (vla-addtext
    	      (if (= 1 (vla-get-activespace aa))
    		(vla-get-modelspace aa)
    		(if (= (vla-get-mspace aa) :vlax-true)
    		  (vla-get-modelspace aa)
    		  (vla-get-paperspace aa)
    		  )
    		)
    	      textstring
    	      (vlax-3d-point insertionpoint)
    	      height)
      )
    
    (defun add-comma  (txt / strl cont1 lth cont txt1)
      (setq strl  (strlen txt)
     cont1 1
     txt1  "")
      (while (and (/= (substr txt cont1 1) ".") (<= cont1 strl))
        (setq cont1 (1+ cont1)))
      (setq lth   (1- cont1)
     cont1 1
     cont  (1- lth))
      (if (> lth 3)
        (progn
          (while (< cont1 lth)
     (setq let  (substr txt cont1 1)
           txt1 (strcat txt1 let))
     (if (and (zerop (rem cont 3)) (eq (type (read let)) 'INT))
       (setq txt1 (strcat txt1 ",")))
     (setq cont  (1- cont)
           cont1 (1+ cont1)))
          (while (<= cont1 strl)
     (setq txt1  (strcat txt1 (substr txt cont1 1))
           cont1 (1+ cont1)))
          txt1)
        txt))
    
    (defun get-last-coord (obj / COORDS LAST_COORD)
      (setq coords (vla-get-coordinates obj)
    	coords (vlax-safearray->list (vlax-variant-value coords))
    	coords (reverse coords)
    	last_coord (list (cadr coords)(car coords)
    			 )
    	)
      last_coord
      )
    
    (defun C:PUTAREA  (/ ent vla_obj pt objname vla_text aa lunit)
      (while (setq ent (entsel "\nSelect closed object: "))
        (setq vla_obj (vlax-ename->vla-object (car ent))
       objname (vla-get-objectname vla_obj))
        (if
          (vlax-property-available-p vla_obj 'area)
           (progn
      (if
        (or
          (= "AcDbCircle" objname)
          (and (wcmatch (vla-get-objectname vla_obj) "*Polyline")
    	   (or  (= :vlax-true (vla-get-closed vla_obj))
    		(equal (vlax-safearray->list
    		     (vlax-variant-value
    		       (vla-get-coordinate vla_obj '0)))
    		   (get-last-coord vla_obj)
    		   0.001)
    		)
    	   )
          )
         (progn
           (if (setq pt (getpoint "\nPick text placement: "))
      (progn
        (setq lunit (getvar "lunits"))
        (setq vla_text
        (addtext
          (strcat
            (add-comma
              (rtos
    	    (if (or (= lunit 3)
    		    (= lunit 4)
    		    )
    	      (/ (vla-get-area vla_obj) 144)
    	      (vla-get-area vla_obj)
    	      )
         2
         0))
            " S.F.")
          pt
          (getvar "textsize")))
    
        ;; alignment to left
        (vla-put-alignment vla_text acAlignmentCenter)
    
        (vla-put-textalignmentpoint
          vla_text
          (vlax-3d-point pt))
    
        ;; use current textstyle
        (vla-put-stylename
          vla_text
          (vla-get-name
            (vla-get-activetextstyle
       (setq aa (vla-get-activedocument
           (vlax-get-acad-object)))))))))
         (prompt "\nNot a closed object. ")
        ))))
      (princ))
    (princ)
    That works like a dream have absolutely no complaints. Would it be possible for it not to round to the nearest sq. ft.? If not it's no big deal but sometimes it's important to at least have it round to the nearest tenth's place.

  9. #9
    100 Club lance.81922's Avatar
    Join Date
    2005-01
    Location
    Santa Fe, NM
    Posts
    176
    Login to Give a bone
    0

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    It's easy to make the program print the area with tenths of a square foot. At line 108, the part that says:
    (rtos
    (if (or (= lunit 3)
    (= lunit 4)
    )
    (/ (vla-get-area vla_obj) 144)
    (vla-get-area vla_obj)
    )
    2
    0
    )
    The "0" is the precision setting for RTOS. Change it to "1" for one decimal place.

  10. #10
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: I need the area of a polyline in sq. ft, not sq. in.

    Quote Originally Posted by lance.81922
    It's easy to make the program print the area with tenths of a square foot. At line 108, the part that says:
    (rtos
    (if (or (= lunit 3)
    (= lunit 4)
    )
    (/ (vla-get-area vla_obj) 144)
    (vla-get-area vla_obj)
    )
    2
    0
    )
    The "0" is the precision setting for RTOS. Change it to "1" for one decimal place.
    Or you could just remove both the 2 and 0, then the (rtos) will use your current unit and precision settings. I hard-coded it since I use this strictly for labelling lot areas on Tentative maps.

Page 1 of 3 123 LastLast

Similar Threads

  1. Area without a closed polyline
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2014-02-11, 03:07 PM
  2. 2010: why does polyline have area?
    By mcdonough.80122419 in forum AutoCAD General
    Replies: 2
    Last Post: 2013-02-21, 09:51 PM
  3. 3d polyline area
    By pennygreg in forum AutoLISP
    Replies: 9
    Last Post: 2009-01-18, 10:36 PM
  4. Polyline Area
    By .chad in forum AutoLISP
    Replies: 1
    Last Post: 2007-11-28, 06:26 AM
  5. Area of Polyline or Hatch
    By robert.1.hall72202 in forum AutoCAD General
    Replies: 3
    Last Post: 2006-08-08, 05:25 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
  •