See the top rated post in this thread. Click here

Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: calculating polygons areas using autocad field

  1. #11
    Member
    Join Date
    2009-09
    Posts
    13
    Login to Give a bone
    0

    Default Re: calculating polygons areas using autocad field

    Code:
    ;SqMetersField;(vl-load-com);
    ;^C^C^P(or C:SqMetersField (load "SqMetersField.lsp"));SqMetersField
    (defun c:SqMetersField (/ ufa actDoc tab obid tpt lin plineReactor) 
    ;|  (defun ufa (notifier-object reactor-object parameter-list) 
        (cond 
          ((vlax-property-available-p notifier-object "Area") 
           (setq actDoc 
           (vla-get-ActiveDocument (vlax-get-acad-object))) 
           (vla-SAVE actDoc) 
          ) 
        ) 
      ) |;
      (setvar"cmdecho" 0) 
     (princ "\nSelect closed Object or Hatch ")
     (setq ss (ssget "+.:E:S" '((0 . "lwpolyline,spline,circle,ellipse,hatch"))))
    ; :E  Everything in aperture
    ; :S  Force single object selection only
    ; The "+." puts (ssget) into "point" mode. It helps the ":S"
    ; single-mode act just like (entsel) by avoiding implied
    ; selection windows.
    ; (if ss
       (setq ent (ssname SS 0)
             EnTyp (cdr (assoc 0 (entget ent)))
             obj (vlax-ename->vla-object ent)
               obid (vla-get-objectid obj)
               tpt (getpoint"\nSelect Area Text Point: ")
       )
       (setq lin (strcat "%<\\AcObjProp Object(%<\\_ObjId " (rtos obid 2 0) ">%).Area \\f \"%lu2%pr3%ps[±, Sq Meters]%ct8[1e-004]%th44\">%"))
      (command "mtext" tpt "w" "0" lin "") 
      (princ) 
    )




    so it should be like this?
    Last edited by RobertB; 2009-09-30 at 12:43 AM. Reason: Added [code] tags

  2. #12
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: calculating polygons areas using autocad field

    Quote Originally Posted by franciscorefosco View Post
    ;SqMetersField;(vl-load-com);
    ;^C^C^P(or C:SqMetersField (load "SqMetersField.lsp"));SqMetersField
    so it should be like this?
    No. The semicolon is for comments. Nothing after one on that line is evaluated. Just put the (vl-load-com) on a new line before everything else. It only has to be loaded once so I have it in my Acad.lsp file rather than putting it in all my routines.

  3. #13
    Woo! Hoo! my 1st post
    Join Date
    2011-12
    Posts
    1
    Login to Give a bone
    1

    Default Re: calculating polygons areas using autocad field

    Hi!

    Tried this function and everything seems okay until it places the square meter text. Instead of writing the square meter information it writes #### instead.
    What’s wrong? I use AutoCAD 2013

  4. #14
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: calculating polygons areas using autocad field

    Not sure of 2013 ... perhaps something's changed. Unfortunately I'm still on 2012. The routine seems to work for me.

    Perhaps try my version from here: http://forums.augi.com/showthread.ph...l=1#post967005
    It's a bit more comprehensive as it allows you to change settings like unit conversion, prefix / suffix, and add/subtract multiple polygons into the fieldcode.

  5. #15
    Member
    Join Date
    2014-10
    Posts
    2
    Login to Give a bone
    0

    Default Re: calculating polygons areas using autocad field

    Hi Tom,

    When I run the lisp, after selecting the object i show the text location the field is showing the content #### (not the area). How to solve this?

Page 2 of 2 FirstFirst 12

Similar Threads

  1. add areas of multiple selected polygons
    By Darren Allen in forum AutoLISP
    Replies: 3
    Last Post: 2014-09-26, 03:48 PM
  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. Calculating Y Position Within a Field in ACA 2008.
    By rdaniel in forum ACA General
    Replies: 2
    Last Post: 2008-03-13, 11:22 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
  •