shakuhachi Posted August 10, 2011 Posted August 10, 2011 (edited) I've been using this neat routine for couple of months now. How can I change the output into "feet". I always divide the total with 144 to get the value in ft2. Thanks ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;; ;;------------------------------------------------------------;; (defun c:A2A nil (c:Areas2Attribute)) (defun c:Areas2Attribute ( / *error* _StartUndo _EndUndo doc att ss ) (vl-load-com) (defun *error* ( msg ) (if doc (_EndUndo doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (defun _StartUndo ( doc ) (_EndUndo doc) (vla-StartUndoMark doc) ) (defun _EndUndo ( doc ) (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-EndUndoMark doc) ) ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (ssget '((0 . "ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE"))) (setq att (LM:Selectif (lambda ( x ) (eq "ATTRIB" (cdr (assoc 0 (entget x))))) nentsel "\nSelect Attribute: " ) ) ) (progn (_StartUndo doc) ( (lambda ( ss fld ) (vlax-for obj ss (setq fld (strcat fld "%<\\AcObjProp Object(%<\\_ObjId " (LM:GetObjectID doc obj) ">%).Area>% + " ) ) ) (vla-put-TextString (vlax-ename->vla-object att) (setq fld (strcat (substr fld 1 (- (strlen fld) (if (< 1 (vla-get-Count ss)) 3 5)) ) " \\f \"%lu6%qf1\">%" ) ) ) (vla-delete ss) (vla-regen doc acActiveViewport) ) (setq ss (vla-get-ActiveSelectionSet doc)) (if (< 1 (vla-get-Count ss)) "%<\\AcExpr " "") ) (_EndUndo doc) ) ) (princ) ) ;;---------------------=={ Select if }==----------------------;; ;; ;; ;; Continuous selection prompts until the predicate function ;; ;; foo is validated ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; foo - optional predicate function taking ename argument ;; ;; fun - selection function to invoke ;; ;; str - prompt string ;; ;;------------------------------------------------------------;; ;; Returns: selected entity ename if successful, else nil ;; ;;------------------------------------------------------------;; (defun LM:Selectif ( foo fun str / e ) (while (progn (setvar 'ERRNO 0) (setq e (car (fun str))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\n** Missed, Try again **") ) ( (eq 'ENAME (type e)) (if (and foo (not (foo e))) (princ "\n** Invalid Object Selected **") ) ) ) ) ) e ) ;;-------------------=={ Get ObjectID }==---------------------;; ;; ;; ;; Returns the ObjectID string for the supplied VLA-Object ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; doc - VLA Document Object (req'd for 64-bit systems) ;; ;; obj - VLA Object to query ;; ;;------------------------------------------------------------;; ;; Returns: ObjectID string for VLA-Object ;; ;;------------------------------------------------------------;; (defun LM:GetObjectID ( doc obj ) (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false) (itoa (vla-get-Objectid obj)) ) ) Edited August 10, 2011 by shakuhachi Quote
Lee Mac Posted August 10, 2011 Posted August 10, 2011 Change: " \\f \"%lu6%qf1\">%" To: " \\f \"%lu6%qf1%ct8[0.006944444444444444]\">%" 1/144 = 0.00694444444444 ... Quote
shakuhachi Posted August 10, 2011 Author Posted August 10, 2011 Thanks Lee, as always you very helpful. Quote
Lee Mac Posted August 10, 2011 Posted August 10, 2011 You're very welcome Shakuhachi. In my other field related program 'Areas2Field', I include a separate line at the top of the program to allow the user to easily modify the field formatting, I may now update the 'Areas2Attribute' program you have posted to match. Cheers, Lee Quote
mikitari Posted October 17, 2017 Posted October 17, 2017 Dear Lee, current version v1-2 does work fine on polylines, but does not work in the attribute TAG option: lisp does not allow me to select blocks with predefined by me attribute "POW", unless I have added "INSERT" to the first setq filter, like below: (ssget '((0 . "INSERT,ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE")))) ...then lisp permits to pick blocks, fine, but when it comes to insert sum into the other attributed block, the sum equals "####". When I look up resulting filed formatting it is a sum of Objects "Block Unit" and not the tag in out case "POW". Lisp picks wrong object property, please correct me where I went wrong. Best regards mate! Quote
Lee Mac Posted October 17, 2017 Posted October 17, 2017 Dear Lee,current version v1-2 does work fine on polylines, but does not work in the attribute TAG option: lisp does not allow me to select blocks with predefined by me attribute "POW", unless I have added "INSERT" to the first setq filter, like below: (ssget '((0 . "INSERT,ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE")))) I think you have misunderstood how the program operates: The 'tag' parameter allows you to specify a predefined attribute tag to house the output from the program - you should not modify the ssget filter which is used to obtain the input. 1 Quote
mikitari Posted October 17, 2017 Posted October 17, 2017 Hello Lee! Thanks for quick replay! In beginning I thought, and sorry my bad, that lisp as an option served to withdraw numeric data from predefined attribute, and then insert the formula sum of that attribute values into the other block attribute picked form list of its attributes. And you see, with the proposed addition of INSERT in ssget line, it almost does the job! I believe it is sooooo close! Could you please try to adjust your program to accept blocks, so in case of blocks it ads the predefined TAG, not the first appearing Object property "Block Units"? That would be very very neat and useful program of yours, don't you agree? Pleeeeease Cheers Lee! Quote
mikitari Posted October 18, 2017 Posted October 18, 2017 May I ask you to explain, how to to change the subfunctions of yours, to adopt this program to the described functionality? To learn from you would be even better approach here, as we are at cadtutor Years pass, and I have only basic understanding of lisp programming. Quote
justin.grant Posted July 22, 2022 Posted July 22, 2022 Hello Lee Mac, I know this post is nearly 5 years old, but I thought I'd try anyway. I'm using your Areas2AttributeV1-2.lsp and it works great, especially adding the total to an attribute, but it's not quite what I need. I'd like to be able to ADD one polyline, such as a building outline, then SUBTRACT multiple polylines, such as staircases and elevators. Any help you can provide would be much appreciated. Thank you very much. Quote
justin.grant Posted September 27, 2022 Posted September 27, 2022 I'm checking back in on this thread. This LISP works great, but would like the option to ADD one polyline, such as a building outline, then SUBTRACT multiple polylines, such as staircases and elevators. Thank you. Quote
BIGAL Posted September 27, 2022 Posted September 27, 2022 This was answered in another post maybe on another forum. You can have a room say with say columns and get floor area. Anyway the simple answer is if you can make a hatch that reflects the correct shape then you can get the area, so would need to edit Lee's code to pick a hatch rather than a pline. 1 1 Quote
justin.grant Posted September 28, 2022 Posted September 28, 2022 Thank you BIGAL for the response. I hadn't thought of selecting hatch rather than a polyline. This seems to solve my question, from a certain point of view 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.