shakuhachi 发表于 2022-7-5 15:55:22

Help on Lee Mac's "Areas

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 "%% + "             )         )         )                   (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)) "%

Lee Mac 发表于 2022-7-5 16:04:14

Change:
 

" \\f \"%lu6%qf1\">%"To:
 

" \\f \"%lu6%qf1%ct8\">%"1/144 = 0.00694444444444 ...

shakuhachi 发表于 2022-7-5 16:13:53

Thanks Lee, as always you very helpful.

Lee Mac 发表于 2022-7-5 16:26:39

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

mikitari 发表于 2022-7-5 16:34:22

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!

Lee Mac 发表于 2022-7-5 16:44:28

 
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.

mikitari 发表于 2022-7-5 16:52:07

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!

mikitari 发表于 2022-7-5 17:00:46

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 cadtutorYears pass, and I have only basic understanding of lisp programming.
页: [1]
查看完整版本: Help on Lee Mac's "Areas