VAC Posted August 9, 2021 Posted August 9, 2021 Hi, please, how to modify Lee Mac lisp (http://www.lee-mac.com/areafieldtoattribute.html) to add area field to text (I need) or mtext? Or it shoud be different lisp that does it. Many thanks Quote
zwonko Posted August 9, 2021 Posted August 9, 2021 (edited) Maybe You need explaint it better. I think that maybe that is what you looking for: http://www.lee-mac.com/areastofield.html or http://www.lee-mac.com/quickfield.html or http://www.lee-mac.com/arealabel.html Quickfield is more "changeable" Edited August 9, 2021 by zwonko Quote
VAC Posted August 9, 2021 Author Posted August 9, 2021 (edited) To Mhupp - Hi, thank you for your reaction, but it doesn't seem to fit my requirement. Example dwg attached. area2txt.dwg To zwonko - Quick Filed does it! (but only support one polyline) - maybe I will use it (99% ares are in one polyline). How to modify my format (%lu2%pr2%ds44%ct8[1e-006]%ps[, m2]) to support "m2" as an upper index? Edited August 9, 2021 by VAC Quote
zwonko Posted August 9, 2021 Posted August 9, 2021 a2f support more polylines. I don't know how to put stuck. Maybe is the thing that i use zwcad not autocad. the stack mtext code is for example \S2^; Quote
VAC Posted August 9, 2021 Author Posted August 9, 2021 a2f supports more polylines, but creates new mtext instead of putting it into an existing one m2 can be added next to inserted area field as a simple text (not as a field suffix), but I don't know where (script line Quick Field lisp) and how to add it in (syntax). Any idea? Quote
zwonko Posted August 10, 2021 Posted August 10, 2021 (edited) in quickfield everything is explanind in the file. Bassically you should add on the end (defun c:youarea ( ) (LM:QuickField "Area" "%lu2%pr2%ds44%ct8[1e-006]%ps[, m2]" 1)) or maybe (defun c:youareastack ( ) (LM:QuickField "Area" "%lu2%pr2%ds44%ct8[1e-006]%ps[, m\S2^;]" 1)) to get stack (in ZWCAD it is not working. Eventually try to inspect mtext properties how is the code for stack in your cad. Eventually you can modiffy: (defun LM:quickfield ( prop format mode / ent ins obj str ) (if (setq str (LM:quickfield:constructfieldstring prop format)) (cond ( (= 1 mode) (if (setq ent (LM:quickfield:selectifhasprop "Textstring" nentsel)) (progn (setq obj (vlax-ename->vla-object ent)) (vla-put-textstring obj "") ;; To clear any existing field (vla-put-textstring obj (strcat str "square meter")) (if (= "ATTRIB" (cdr (assoc 0 (entget ent)))) (vl-cmdf "_.updatefield" ent "") (where i add suare meter) also you can check changed a2f which update text instead off putting new. FOr me is not working becouse zwcad can't sum fields in formulas. (defun c:a2fmodoverwrite ( / *error* fmt inc ins lst sel str ) (setq fmt "%lu6%qf1") ;; Field Formatting (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (if (and (setq sel (ssget '((0 . "ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE")))) ) (progn (if (= 1 (sslength sel)) (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:ObjectID (vlax-ename->vla-object (ssname sel 0))) ">%).Area \\f \"" 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>%" " + " lst ) ) ) (setq str (strcat "%<\\AcExpr " (apply 'strcat (reverse (cdr (reverse lst)))) " \\f \"" fmt "\">%" ) ) ) ) (LM:startundo (LM:acdoc)) (if (setq ent (LM:quickfield:selectifhasprop "Textstring" nentsel)) (progn (setq obj (vlax-ename->vla-object ent)) (vla-put-textstring obj "") ;; To clear any existing field (vla-put-textstring obj str) (if (= "ATTRIB" (cdr (assoc 0 (entget ent)))) (vl-cmdf "_.updatefield" ent "") ) ) ) (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) (defun LM:quickfield:selectifhasprop ( prop func / ent ) (while (progn (setvar 'errno 0) (setq ent (car (func (strcat "\nSelect object with " prop " property: ")))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null ent) nil ) ( (not (vlax-property-available-p (vlax-ename->vla-object ent) prop)) (princ (strcat "\nSelected object does not have " prop " property.")) ) ) ) ) ent ) ;;------------------------------------------------------------;; ;; End of File ;; ;;------------------------------------------------------------;; Edited August 10, 2021 by zwonko Quote
BIGAL Posted August 11, 2021 Posted August 11, 2021 A way may be to add the unicode \U+00B2 to the mtext string. Which is superscript 2. Quote
VAC Posted August 11, 2021 Author Posted August 11, 2021 Zwonko, Bigal, both script works great (I add succesfully unicode string for m2 from Bigal) - many thanks. If in a2f script (is better) should persist the possibility to add field even to table cell (you changed this function) - depending on where I will click - so field should be added to any text(works), mtext(works), attribute(works) or table cell(works in original lisp) in one lisp - you will be my HERO(s)! Quote
zwonko Posted August 11, 2021 Posted August 11, 2021 You didn't say what You need on the beggining. So the thing is to use this one: http://www.lee-mac.com/lengthfield.html on the beggining make your own like: (defun c:afm ( ) (areafield nil "%lu6%qf1%ct8[1e-6]")) ;; Current units with 1e-6 (0.000001) conversion factor (mm2->m2) In this lisp you could add new text/ replace table cell, or select Object to change (object is text, mtext, atrib, bla bla) Quote
BIGAL Posted August 12, 2021 Posted August 12, 2021 Look into initget for fixed options or my Multi Radio buttons.lsp for the choices, must select as get cell needs a special program. Multi radio buttons.lsp 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.