See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: calculating polygons areas using autocad field

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

    Default calculating polygons areas using autocad field

    hello guys,
    this is my first post here.
    i have a doubt and i can find an answear on internet.
    i draw my cad files in CENTIMETER.
    all texts and dimmensions i insert on the LAYOUT.
    i created a FIELD that calculates the area of a closed polygon, which i insert on the LAYOUT and it refers to a polygon on the MODEL.
    so far, everything works fine.
    the thing is that this field calculates the area in SQUARE CENTIMETER, and i need it to calculate SQUARE METER.
    lets say there is a square of 2m x 2m (which i draw 200cm x 200cm), the area should be 4.00m2. instead, it calculates 200cm x 200cm = 40000cm2.
    its correct, but i would like to see the result as SQUARE METER, or 4.00m2
    So i found out that i could use "SCALE FACTOR" on the field properties, and change the factor from 1 to 0.0001.
    then it works fine, it shows as i want.
    but.... there is an issue.
    when i copy and paste this field, to calculate the area of another closed polygon (which would be another room of the house, lie bathroom, bedroom, kitchen or something else), i need to point the FIELD to the new polygon i want it to calculate. when i do it, the FIELD loses the "SCALE FACTOR" that i had eddited before, so i need to manually change againg the factor of "SCALE FACTOR" from 1 to 0,0001.
    as i have to calculate the area of several rooms of the houses i design, it takes a long time to go and edit the factor of "SCALE FACTOR" one by one.
    i also tried to change the ambient scale, but could make it work as i need.

    what do you guys recommend?

    thanks a lot,

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

    Default Re: calculating polygons areas using autocad field

    Welcome to AUGI!

    Use a formula in your field. You can insert multiple fields within your formula.
    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
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: calculating polygons areas using autocad field

    Quote Originally Posted by Opie
    Use a formula in your field.
    Per his comment below, he is already using a formula
    Quote Originally Posted by franciscorefosco
    So i found out that i could use "SCALE FACTOR" on the field properties, and change the factor from 1 to 0.0001.
    The problem seems to be when you copy this field and select a new Object to tie it to, the formula is dropped.
    Quote Originally Posted by franciscorefosco
    when i copy and paste this field, to calculate the area of another closed polygon (which would be another room of the house, lie bathroom, bedroom, kitchen or something else), i need to point the FIELD to the new polygon i want it to calculate. when i do it, the FIELD loses the "SCALE FACTOR" that i had eddited before, so i need to manually change againg the factor of "SCALE FACTOR" from 1 to 0,0001.
    The only solution I can see is to write a lisp routine to place the field and automatically include the formula.
    R.K. McSwain | CAD Panacea |

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

    Default Re: calculating polygons areas using autocad field

    hello guys,

    thanks for the replies.
    RKMCSWAIN, could you explain a little more about LISP?
    i have no clue what's that, or how to make it work...

    =]

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: calculating polygons areas using autocad field

    Quote Originally Posted by franciscorefosco View Post
    RKMCSWAIN, could you explain a little more about LISP?
    i have no clue what's that, or how to make it work...
    AutoLISP is a programming language for AutoCAD.
    Take a look at these posts for some examples of making fields using lisp.

    http://forums.augi.com/search.php?searchid=2269633
    R.K. McSwain | CAD Panacea |

  6. #6
    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

    Try:
    Code:
    ;SqMetersField
    ;^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) 
    )

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

    Default Re: calculating polygons areas using autocad field

    Hello TOM,

    could you please tell me where should I paste this code?
    FIELD -> OTHER -> LISPVARIABLE -> ?

    thank you,

  8. #8
    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

    Copy the code and paste into a text editor. Save it as "SqMetersField.lsp" in a support folder. On the Command line enter: (load "SqMetersField.lsp")
    Then enter: SqMetersField
    Pick the object you wish to have the area of, then pick the text location. It will add the label at the current text size.

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

    Default Re: calculating polygons areas using autocad field

    hello again guys,

    i followed step by step this website, to learn how to use the LISP code which TOM has provided http://www.cadtutor.net/forum/showthread.php?t=1390
    unfortunatelly, i didnt succeed.
    when i was trying to use the command on autocad, after selecting a closed object, it would return a message saying that thre was an error, "Select objects: ; error: bad argument type: lselsetp nil"
    maybe i should just give up, this issue doesnt seem to be easy to solve.

    =]

  10. #10
    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
    hello again guys,

    i followed step by step this website, to learn how to use the LISP code which TOM has provided http://www.cadtutor.net/forum/showthread.php?t=1390
    unfortunatelly, i didnt succeed.
    when i was trying to use the command on autocad, after selecting a closed object, it would return a message saying that thre was an error, "Select objects: ; error: bad argument type: lselsetp nil"
    maybe i should just give up, this issue doesnt seem to be easy to solve.

    =]
    Try adding
    Code:
    (vl-load-com)
    as the first line in the routine. What version of Autocad are you running?

Page 1 of 2 12 LastLast

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
  •