Madruga_SP Posted December 17, 2013 Posted December 17, 2013 Hi guys! I'm using that excellent code from Mr. Lee Mac. And I need a help to make a little modification in that code. I'd like to control the text size. That code doesn't have any option for that. Anybody Can help me out, please? Thank in advance ;;-------------------=={ Areas 2 Field }==--------------------;; ;; ;; ;; 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 ;; ;;------------------------------------------------------------;; (defun c:a2f ( / *error* fmt inc ins lst sel str ) (setq fmt "%lu6%qf1%ds44%th46") ;; 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")))) (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 "\">%" ) ) (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)) (vla-addmtext (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)) (vlax-3D-point (trans ins 1 0)) 0.0 str ) (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 ;; ;;------------------------------------------------------------;; Quote
Spaj Posted December 17, 2013 Posted December 17, 2013 Hi If you read the Lee's page http://www.lee-mac.com/fieldformat.html you'll see how to alter the text size. Quote
Spaj Posted December 17, 2013 Posted December 17, 2013 Hi Read Lee's instruction page for this LISP. Also (setq fmt "%lu6%qf1%ds44%th46") ;; Field Formatting If I recall the th refers to text height. I'm sure Lee will confirm. Quote
Madruga_SP Posted December 17, 2013 Author Posted December 17, 2013 Hi Spaj, Thanks for the quick replay I was thinking if possible to create a input for the text size instead of modify inside the code. Quote
Lee Mac Posted December 18, 2013 Posted December 18, 2013 Hi Madruga, Since the program is creating an MText Field, the text height will be determined by the value of the TEXTSIZE system variable at the time of running the program. However, here is a quick mod to include an additional prompt for the height: ;;-------------------=={ Areas 2 Field }==--------------------;; ;; ;; ;; 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 ;; ;;------------------------------------------------------------;; ;; Modified to prompt for text height - Lee Mac 2013-12-18 (defun c:a2f ( / *error* fmt hgt inc ins lst sel str ) (setq fmt "%lu6%qf1%ds44%th46") ;; Field Formatting (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) ;; <Modified> (initget 6) (if (setq hgt (getdist (strcat "\nSpecify text height <" (rtos (getvar 'textsize)) ">: "))) (setvar 'textsize hgt) (setq hgt (getvar 'textsize)) ) ;; </Modified> (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 "\">%" ) ) (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)) (vla-put-height ;; mod (vla-addmtext (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)) (vlax-3D-point (trans ins 1 0)) 0.0 str ) hgt ;; mod ) ;; mod (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) @Spaj, thank you for your responses + suggestions, appreciated. Quote
Madruga_SP Posted December 19, 2013 Author Posted December 19, 2013 Wow! many Thanks Mr. Lee, The modification improved the code. Make it better! Regards Quote
Lee Mac Posted December 21, 2013 Posted December 21, 2013 Excellent - you're welcome Madruga, happy to help Quote
Madruga_SP Posted January 6, 2014 Author Posted January 6, 2014 Hi guys, How Can I put the text area only 2 decimal units? I'd like to learn which part of the code I can do that. Anybody Can teach me, please? Best Regards Quote
Tharwat Posted January 6, 2014 Posted January 6, 2014 Hi guys,How Can I put the text area only 2 decimal units? I'd like to learn which part of the code I can do that. Anybody Can teach me, please? Best Regards Change the LUPREC system variable to your desired one Quote
Madruga_SP Posted January 6, 2014 Author Posted January 6, 2014 Thank for the quick replay Tharwat, I'd like to put it inside the code. I mean always been 2 decimal units Because I know how change it through LUPREC, but today I forgot to change it and I plot the wrong text. Quote
Tharwat Posted January 6, 2014 Posted January 6, 2014 Thank for the quick replay Tharwat, Because I know how change it through LUPREC, but today I forgot to change it and I plot the wrong text. No worries Add the following line at the top of the routine and you'd get it equal to two all the time . (setvar 'LUPREC 2) Quote
Madruga_SP Posted January 6, 2014 Author Posted January 6, 2014 I've already calculate all areas in my project with 2 decimal units. But today when I opened the project, I didn't realize that LUPREC was 3 and plot the wrong area. I was wondering if there is any way to lock the area showing always 2 decimal units. Thank in advance 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.