rickfaction Posted September 17, 2020 Posted September 17, 2020 I found this area lisp tool that will give you an area based on an internal point, it will show a hatched area and then report individual areas in the command bar. I wonder if someone out there knows how to modify it so that it will also label the area in acreage. I'm currently faced with the task of pulling the drainage areas over an entire highway project and the ability to do this efficiently would be extremely helpful. I've been out of the autocad game for about 6 years so if there is a way to get Civil 3D to do this on it's own that would helpful as well. So far google has been unhelpful. Thanks in advan ce for any help. are.lsp Quote
BIGAL Posted September 18, 2020 Posted September 18, 2020 Try changing to this expects sq feet. area (/ (vla-get-area v-obj-new) 43560.0) 1 Quote
dlanorh Posted September 18, 2020 Posted September 18, 2020 20 hours ago, rickfaction said: I found this area lisp tool that will give you an area based on an internal point, it will show a hatched area and then report individual areas in the command bar. I wonder if someone out there knows how to modify it so that it will also label the area in acreage. I'm currently faced with the task of pulling the drainage areas over an entire highway project and the ability to do this efficiently would be extremely helpful. I've been out of the autocad game for about 6 years so if there is a way to get Civil 3D to do this on it's own that would helpful as well. So far google has been unhelpful. Thanks in advan ce for any help. are.lsp 8.7 kB · 4 downloads look at the autolisp cvunit function. and make the changes here (defun ARE_DCL (area / strArea list_textset); REFERENCE ONLY (setq strArea (strcat "\n Total Area: " (rtos area 2 2) "\n" ; (rtos (* 1 area) 2 2) "" ) ) You'll need to replace (rtos area 2 2) with (cvunit area "From units" "acre") 1 Quote
rickfaction Posted September 21, 2020 Author Posted September 21, 2020 Thanks so much!!! Is there any way to also make it produce a label or is that too complex? Quote
BIGAL Posted September 21, 2020 Posted September 21, 2020 If you google you will find multiple code answers including auto label. Quote
Dadgad Posted September 22, 2020 Posted September 22, 2020 You may want to check out this one by LeeMac http://www.lee-mac.com/areastofield.html. I think it does what you are after. Thanks Lee! Quote
tombu Posted September 28, 2020 Posted September 28, 2020 I couldn't get through a day without using some of Lee's code. Thanks Lee! With a slight modification Lee's code can be used to label areas or lengths in whatever units you wish. For acres I use this macro: ^C^C^P(or a2f (load "Areas2Field.lsp"));(a2f "acres") Slightly modified version of older version of Lee's code: ;|----{ Areas 2 Field }=http://lee-mac.com/areastofield.html ---------- Creates an MText object containing a Field Expression referencing the area, or sum of areas, of one or more selected objects. ------------------------------------------------------------ Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ------------------------------------------------------------ Version 1.2 - 26-05-2013 ------------------------------------------------------------ Tom Beauford added multiple properties & formats 7/3/2013 ^C^C^P(or a2f (load "Areas2Field.lsp"));(a2f "sqft") or (a2f "sqft×Scale") or (a2f "SY") or (a2f "acres") or (a2f "ft") or (a2f "mi") |; (defun a2f (units / *error* prop fmt inc ins lst viewtwist sel str) (cond ((eq units "sqm")(setq prop ">%).Area" fmt " \\f \"%lu2%pr0%qf1%ps[, SM]%th44\">%")) ((eq units "sqft")(setq prop ">%).Area" fmt " \\f \"%lu2%pr0%qf1%ps[, SF]%th44\">%")) ((eq units "sqft/2")(setq prop ">%).Area" fmt " \\f \"%lu2%qf1%pr0%ct8[0.5]%ps[, SF]%th44\">%")) ((eq units "sqft×Scale") (if (= nil ×Sca)(setq ×Sca 1.0)); (cond ((getreal "\nSpecify scale factor <1.0>: ")) (1.0)) (setq ×Sca (cond ((getreal(strcat"\nChange Scale factor from " (rtos ×Sca 2 2) " to : "))) (atof ×Sca ))) (princ "\nScale factor = ")(princ ×Sca) (setq prop ">%).Area" fmt (strcat " \\f \"%lu2%qf1%pr0%ct8[" (rtos ×Sca 2 2) "]%ps[, SF]%th44\">%")) ) ((eq units "SY")(setq prop ">%).Area" fmt " \\f \"%lu2%pr3%ps[, SY]%ct4%qf1%ct8[0.1111111111111111]%th44\">%")) ((eq units "acres")(setq prop ">%).Area" fmt " \\f \"%lu2%pr3%ps[±, Acres]%ct4%qf1%ct8[2.295684113865932e-005]%th44\">%")) ((eq units "ft")(setq prop ">%).Length" fmt " \\f \"%lu2%pr1%qf1%ps[, ft]%th44\">%")) ((eq units "mi")(setq prop ">%).Length" fmt " \\f \"%lu2%pr1%qf1%ps[, miles]%ct8[0.0001893939393939]%th44\">%")) ) (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (setq viewtwist (getvar "viewtwist")) (if (and (setq sel (ssget '((0 . "ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE")))) (setq ins (getpoint "\nPick Point for Field: ")) ) (progn (if (= 1 (sslength sel)) (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:ObjectID (vlax-ename->vla-object (ssname sel 0))) ; ">%).Area \\f \"" fmt "\">%" prop fmt ) ) (progn (repeat (setq inc (sslength sel)) (setq lst (vl-list* "%<\\AcObjProp Object(%<\\_ObjId " (LM:ObjectID (vlax-ename->vla-object (ssname sel (setq inc (1- inc))))) ; ">%).Area>%" " + " prop ">%" " + " lst ) ) ) (setq str (strcat "%<\\AcExpr " (apply 'strcat (reverse (cdr (reverse lst)))) ; " \\f \"" fmt "\">%" fmt ) ) ) ) (LM:startundo (LM:acdoc)) (vla-addmtext (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)) (vlax-3D-point (trans ins 1 0)) 0.0 str ) ; (setq obj (vlax-ename->vla-object (entlast))) ; (vlax-put-property obj 'BackgroundFill :vlax-true) (if(/= viewtwist 0.0)(vla-put-Rotation (vlax-ename->vla-object (entlast)) (- viewtwist))) ; Horizontal Text 6/21/2019 (LM:endundo (LM:acdoc)) ) ) (princ) ) ;; ObjectID - Lee Mac ;; Returns a string containing the ObjectID of a supplied VLA-Object ;; Compatible with 32-bit & 64-bit systems (defun LM:ObjectID ( obj ) (eval (list 'defun 'LM:ObjectID '( obj ) (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring) ) (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false) '(itoa (vla-get-objectid obj)) ) ) ) (LM:ObjectID obj) ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) (vl-load-com) (princ) ;;------------------------------------------------------------;; ;; End of File ;; ;;------------------------------------------------------------;; I use the scaled versions of "sqft" for labeling X-Section areas which usually have exaggerated vertical scale. His newer code like "MaskV1-5.lsp" has command line options for using it for whatever you want without modifying the code. Quote
xpr0 Posted October 28, 2020 Posted October 28, 2020 On 9/18/2020 at 1:39 PM, dlanorh said: look at the autolisp cvunit function. and make the changes here (defun ARE_DCL (area / strArea list_textset); REFERENCE ONLY (setq strArea (strcat "\n Total Area: " (rtos area 2 2) "\n" ; (rtos (* 1 area) 2 2) "" ) ) You'll need to replace (rtos area 2 2) with (cvunit area "From units" "acre") i want area in sqft plz tell me which part of this lisp should be modified. Quote
dlanorh Posted October 28, 2020 Posted October 28, 2020 4 hours ago, xpr0 said: i want area in sqft plz tell me which part of this lisp should be modified. What are your current units? 1 Quote
xpr0 Posted October 28, 2020 Posted October 28, 2020 33 minutes ago, dlanorh said: What are your current units? meter Quote
dlanorh Posted October 28, 2020 Posted October 28, 2020 3 hours ago, xpr0 said: meter replace area in (rtos area 2 2) with (cvunit area "sq m" "sq ft") (rtos (cvunit area "sq m" "sq ft") 2 2) or (rtos (* area 10.7639) 2 2) 1 Quote
xpr0 Posted November 2, 2020 Posted November 2, 2020 On 10/28/2020 at 11:35 PM, dlanorh said: replace area in (rtos area 2 2) with (cvunit area "sq m" "sq ft") (rtos (cvunit area "sq m" "sq ft") 2 2) or (rtos (* area 10.7639) 2 2) sorry for the late reply. i replaced (rtos area 2 2) with (cvunit area "sq m" "sq ft") (rtos (cvunit area "sq m" "sq ft") 2 2) its giving me the answer but with this error local error:bad argument type: stringp and then the answer. also it dose not work if the original are.lisp is also loaded in the drawing. i want to run both the lisps in the drawing plz help. Quote
dlanorh Posted November 2, 2020 Posted November 2, 2020 2 hours ago, xpr0 said: sorry for the late reply. i replaced (rtos area 2 2) with (cvunit area "sq m" "sq ft") (rtos (cvunit area "sq m" "sq ft") 2 2) its giving me the answer but with this error local error:bad argument type: stringp and then the answer. also it dose not work if the original are.lisp is also loaded in the drawing. i want to run both the lisps in the drawing plz help. Sorry, my answer was confusing, it should have read replaced (rtos area 2 2) with (rtos (cvunit area "sq m" "sq ft") 2 2) As for running both, copy the original lisp, make the changes to one copy and then rename the functions to c:arem (metres the unchanged one) and c:aref (feet). You will find this a the top of the file in the first function call i.e. (defun c:are ()... (change the red bit) 1 Quote
xpr0 Posted November 3, 2020 Posted November 3, 2020 (edited) 17 hours ago, dlanorh said: Sorry, my answer was confusing, it should have read replaced (rtos area 2 2) with (rtos (cvunit area "sq m" "sq ft") 2 2) As for running both, copy the original lisp, make the changes to one copy and then rename the functions to c:arem (metres the unchanged one) and c:aref (feet). You will find this a the top of the file in the first function call i.e. (defun c:are ()... (change the red bit) thanx for your reply. i've edited the lisp as per your post, now its giving me the area in both units sqm & sqft at the same time thats great but its also gives the total area of all the selected areas. now its only calculating the total area in sqft, i want total area in sqm as well plz tell me which part to edit. are sft.lsp Edited November 3, 2020 by xpr0 Quote
dlanorh Posted November 3, 2020 Posted November 3, 2020 7 hours ago, xpr0 said: thanx for your reply. i've edited the lisp as per your post, now its giving me the area in both units sqm & sqft at the same time thats great but its also gives the total area of all the selected areas. now its only calculating the total area in sqft, i want total area in sqm as well plz tell me which part to edit. are sft.lsp 8.75 kB · 1 download I'll take a look at the lisp later today. You want both sqm and sqft displayed in the same lisp correct? Quote
xpr0 Posted November 3, 2020 Posted November 3, 2020 3 hours ago, dlanorh said: I'll take a look at the lisp later today. You want both sqm and sqft displayed in the same lisp correct? yes, and this lisp does that, but the only thing that is missing is the total area in sqm. Quote
dlanorh Posted November 3, 2020 Posted November 3, 2020 Do you have the dcl file that this lisp is supposed to use? If not a large part of the lisp is superfluous and can be removed leaving the attached lisp, which I have renamed to arec. The lisp, as per the original, is set to auto-run when loaded. If you need to run it later it is now "arec" If you have the dcl file, please attach it so i can test the complete package with the changes. arec.lsp 1 Quote
xpr0 Posted November 4, 2020 Posted November 4, 2020 13 hours ago, dlanorh said: Do you have the dcl file that this lisp is supposed to use? If not a large part of the lisp is superfluous and can be removed leaving the attached lisp, which I have renamed to arec. The lisp, as per the original, is set to auto-run when loaded. If you need to run it later it is now "arec" If you have the dcl file, please attach it so i can test the complete package with the changes. arec.lsp 6.14 kB · 2 downloads thanks a lot for helping me with this lisp. now its working perfectly. i guess this lisp wont work if the dwg units are in inch or feet, right ?? and i don't have the dcl file. i downloaded this lisp from 1st post of this thread. there's no dcl file in there, if the op or someone else has it plz upload it. Quote
dlanorh Posted November 4, 2020 Posted November 4, 2020 (edited) 25 minutes ago, xpr0 said: thanks a lot for helping me with this lisp. now its working perfectly. i guess this lisp wont work if the dwg units are in inch or feet, right ?? and i don't have the dcl file. i downloaded this lisp from 1st post of this thread. there's no dcl file in there, if the op or someone else has it plz upload it. No, it will not work properly if the drawing is in feet or inches, as it assumes metres. The same applies to a drawing in millimetres as everything will be out by a factor of 1.0e6 (million). It can be altered to ask for the base units or assume the base units from system variables. The latter however assumes the drawing was initially set up correctly. The lisp can be adjusted to account for these possibilities as it is just converting areas. The loss of the dcl is not important as I think it was used to put the area (as text) in the center of polyline. Out of interest what are you using this lisp for, as there are several that allow multiple closed polylines to be selected e.g. Lot labelling or room labelling etc.? Edited November 4, 2020 by dlanorh Quote
mdbdesign Posted November 4, 2020 Posted November 4, 2020 Not to cut topic but: I just find: https://areatester.com/ looks nice. Free. 1 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.