Tuesday, October 30, 2007

Customize AreaText.LSP for AutoCAD

In the earlier post about AreaText.LSP the result was in SQ. FT. Several users have asked how to get it in other formats like m², cm², etc.

Here is what you do. Draw a polyline. Run the FIELD command and select the Objects Field category>the Object Field name>Area Property and select the polyline. Make changes as you want to the Format, Precision and Additional Format.

FIELD

Notice the result in Field expression.

Copy the text for example it can look like this:

%<\AcObjProp.16.2 Object(%<\_ObjId 2130314088>%).Area \f "%lu2%pr1%ps[,m²]%ct8[0.001]">%

What is maked bold green is what is the important part.

Now look at the code for AreaText.LSP. Change this row below in the code.

">%).Area \\f \"%pr2%lu2%ct4%qf1 SQ. FT.\">%"

Now pick the correct piece of the field expression so the code look like this instead using one decimal as precision, the conversion factor of .001 and the suffix m².

">%).Area \\f \"%lu2%pr1%ps[,m²]%ct8[0.001]\">%"

21 comments:

  1. I've been having problems with getting the AreaText.lsp to work with AutoCAD 2010. Is anyone else experiencing the same problem? If so is there a fix?

    ReplyDelete
  2. It should work with AutoCAD 2010. What is the problem?

    ReplyDelete
  3. i don't know why - but it gives a wrong number... for example - instead of 190 sqm. --> 1.34 sqm.
    how come?

    ReplyDelete
  4. It is probably because the factor is incorrect or because of different settings for units in the drawing. Try to run FIELDS manually and figure out what settings you need to use.

    ReplyDelete
  5. The AreaText lisp I use allows me to select the pline and place the text, but then only displays 4 pound signs (####). Any ideas what lisp modification may fix this glitch? I'm using MEP 2009...

    ReplyDelete
  6. What happens if you use the FIELDS command, select the polyline and then try to get the area of it? You may also check the code at the bottom of the FIELDS dialog box and take note of what it says and if needed make adjustment to the lsp code.

    ReplyDelete
  7. Can anyone help fix this error?
    Command: at
    Select object: Select point: #

    ReplyDelete
  8. Not sure what this error could be. I would need to know more like AutoCAD version, if you used the code exactly as it is or if you modified it.

    ReplyDelete
  9. Scott NewcombeSeptember 07, 2012

    This works really well for me. I have tried modifying to return the perimeter of the area but I get the error shown below. Any ideas?
    "Select object: Select point: ; error: bad argument type: stringp nil"
    Thanks
    Scott

    ReplyDelete
  10. Scott, What code change did you do?

    ReplyDelete
  11. Hey,
    How can I use command AT to show the sum of multiple polylines instead of individual length of them?

    ReplyDelete
    Replies
    1. See the ATM command. Use the latest LSP here https://jtbworld.com/autocad-areatext-lsp

      Delete
  12. Hi Jimmy,
    Love your code but wanted to let you know about a switch if you are using Civil 3d We normally use Survey Feet or International feet for our units in Civil so I had to change the %ct4 to %ct8 to get the units to work correctly.

    ReplyDelete
  13. AnonymousJuly 15, 2022

    I want to change Precision , look like this 28.00 Sq. Ft. But I want 28.000 Sq. Ft.

    ReplyDelete
  14. To change from 2 to 3 decimals change precision %pr2 to %pr3.

    ReplyDelete
  15. Jack CAD DrafterJune 03, 2024

    Starting, this is a great lsp. I've been using it for Square Footage for a long while.
    I was wanting to use this for 3 decimal; Acres(conversion factor: 0.00002295684 [or] 1/43560) which codes as...
    %lu2%pr3%ps[, AC]%ct8[2.295683999999996E-005]%th44">%
    When loaded...
    AreaText.lsp successfully loaded.
    Command: ; error: misplaced dot on input
    I have attempted changing in brackets to 0.00002295684 with no success.
    Suggestions?

    ReplyDelete
    Replies
    1. Jack, what Field expression do you get if you manually change it as you want on a field? Did you try it exactly as that?

      Delete
    2. AnonymousJune 05, 2024

      Yes, As I mentioned earlier, but for more detail...
      Feild category: Object>Object type: Polyline> Property: Area> Format: Decimal> Precision: 0.000>
      Additional Format...Conversion Factor: 1/43560 > Additional text...Suffix: AC> Thousands: ','

      Delete
    3. Is this what your code change look like? (setq jtbfieldformula ">%).Area \f ""%lu2%pr3%ct8[2.295683999999998E-005]"">%")

      Delete
    4. Or: (setq jtbfieldformula ">%).Area \f ""%lu2%pr3%ps[, AC]%ct8[2.295684113865930E-005]"">%")

      Delete