vernonlee Posted July 22, 2015 Share Posted July 22, 2015 Now sure how to explain so here goes. I am working on an existing drawings that came polylines that has a length attached to it. The amazing thing is that when we stretch the line longer or shorter, & reload the drawing, the text length changes. How is this done? Through LISP? I attached a drawing for easy reference length that changes when line gets longer.dwg Thanks Quote Link to comment Share on other sites More sharing options...
Dadgad Posted July 22, 2015 Share Posted July 22, 2015 I haven't opened your file yet, but it certainly sounds like a field has been added, which reports the LENGTH of the object to which it is keyed. Try double clicking on the text, and in your right click shortcut menu, you may see UPDATE FIELD as one of the available options? You could pretty much do the same thing by creating a dimension style devoid of extension and dimension lines, but it would report changes real time. The fact that the reporting of new length is delayed indicates that it is a field. Having now dug a bit deeper, it is as I suspected, as shown in the screenshot. When setting up a field like this, there are additional options available in the Precision and Additional Format dialogues. Quote Link to comment Share on other sites More sharing options...
nod684 Posted July 22, 2015 Share Posted July 22, 2015 Now sure how to explain so here goes. I am working on an existing drawings that came polylines that has a length attached to it. The amazing thing is that when we stretch the line longer or shorter, & reload the drawing, the text length changes. How is this done? Through LISP? I attached a drawing for easy reference [ATTACH]54922[/ATTACH] Thanks it can be done manually or thru lisp. LeeMac's QuickField is a good start http://www.lee-mac.com/quickfield.html Quote Link to comment Share on other sites More sharing options...
Dadgad Posted July 22, 2015 Share Posted July 22, 2015 Vernon, I set up a new dimstyle, that would do the same thing, and thought you might like to see how to do it, without the need for a FIELD (which definitely does offer advantages, in certain applications). If the geometry which is dimensioned is stretched in modelspace, the dimension, which I placed in Paperspace, will immediately display real time length, as it is Associative. Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 22, 2015 Author Share Posted July 22, 2015 it can be done manually or thru lisp.LeeMac's QuickField is a good start http://www.lee-mac.com/quickfield.html Thanks. Tried it out & it worked Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 22, 2015 Author Share Posted July 22, 2015 Vernon, I set up a new dimstyle, that would do the same thing, and thought you might like to see how to do it, without the need for a FIELD (which definitely does offer advantages, in certain applications). If the geometry which is dimensioned is stretched in modelspace, the dimension, which I placed in Paperspace, will immediately display real time length, as it is Associative. Thanks Dadgad for the clear description. Quote Link to comment Share on other sites More sharing options...
nod684 Posted July 22, 2015 Share Posted July 22, 2015 Thanks. Tried it out & it worked All credits to Lee Quote Link to comment Share on other sites More sharing options...
Dadgad Posted July 22, 2015 Share Posted July 22, 2015 Should you be unfamiliar with the use of fields, you might want to see the SYSVDLG description of the FIELDEVAL system variable. Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 22, 2015 Author Share Posted July 22, 2015 Should you be unfamiliar with the use of fields, you might want to see the SYSVDLG description of the FIELDEVAL system variable. Thanks Dadgad. That is useful to me. Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 22, 2015 Author Share Posted July 22, 2015 I encounter "Length at Midpoint" from LEE. http://www.lee-mac.com/midlen.html Except that instead of the text field being position in the center of the line, what would i need to change if i need the text field to be above/bottom of the line? Thanks Quote Link to comment Share on other sites More sharing options...
Dadgad Posted July 27, 2015 Share Posted July 27, 2015 Hi vernon, surprised I missed your response on this post., let's give it a little bump. I should think it would be pretty easy to do, but it is too late here for me to start monkeying around with it. I'll give it a shot tomorrow, if nobody else gets you sorted out before then. Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 27, 2015 Author Share Posted July 27, 2015 Hi vernon, surprised I missed your response on this post., let's give it a little bump.I should think it would be pretty easy to do, but it is too late here for me to start monkeying around with it. I'll give it a shot tomorrow, if nobody else gets you sorted out before then. Thanks alot Dadgad Quote Link to comment Share on other sites More sharing options...
tombu Posted July 27, 2015 Share Posted July 27, 2015 (edited) I encounter "Length at Midpoint" from LEE. http://www.lee-mac.com/midlen.html Except that instead of the text field being position in the center of the line, what would i need to change if i need the text field to be above/bottom of the line? Thanks Try: ;;----------------------=={ Length at Midpoint }==----------------------;; ;; ;; ;; This program prompts the user for a selection of objects to be ;; ;; labelled and proceeds to generate an MText object located at ;; ;; the midpoint of each object displaying a Field Expression ;; ;; referencing the length of the object. ;; ;; ;; ;; The program is compatible for use with Arcs, Circles, Lines, ;; ;; LWPolylines, 2D & 3D Polylines, and under all UCS & View settings. ;; ;; ;; ;; The program will generate MText objects positioned directly over ;; ;; the midpoint of each object, and aligned with the object whilst ;; ;; preserving text readability. The MText will have a background mask ;; ;; enabled and will use the active Text Style and Text Height settings ;; ;; at the time of running the program. ;; ;;----------------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2013 - www.lee-mac.com ;; ;; Above/Below line added by Tom Beauford ;;----------------------------------------------------------------------;; ;; Version 1.1 - 12-11-2013 ;; ;; ;; ;; First release. ;; ;;----------------------------------------------------------------------;; (defun c:midlen ( / *error* ent fmt idx ins ocs par sel spc txt typ uxa ang pt str1) (setq fmt "%lu6") ;; Field Formatting (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (if (setq sel (ssget (list '(0 . "ARC,CIRCLE,LINE,*POLYLINE") '(-4 . "<NOT") '(-4 . "<AND") '(0 . "POLYLINE") '(-4 . "&") '(70 . 80) '(-4 . "AND>") '(-4 . "NOT>") (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model") ) ) ) ) (progn (setq spc (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) ) (setq ocs (trans '(0.0 0.0 1.0) 1 0 t) uxa (angle '(0.0 0.0) (trans (getvar 'ucsxdir) 0 ocs t)) ) (initget "Yes No") (or (setq str1 (getkword "\nBelow Line? [Yes/No] <Yes>: ")) (setq str1 "Yes") ) (if (= str1 "Yes") (setq up-dn (/ pi 2)) (setq up-dn (-(/ pi 2))) ) (LM:startundo (LM:acdoc)) (repeat (setq idx (sslength sel)) (setq ent (ssname sel (setq idx (1- idx))) par (vlax-curve-getparamatdist ent (/ (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) 2.0)) ins (vlax-curve-getpointatparam ent par) typ (cdr (assoc 0 (entget ent))) ) (setq txt (vlax-invoke spc 'addmtext ins 0.0 (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object ent)) ">%)." (cond ( (= "CIRCLE" typ) "Circumference") ( (= "ARC" typ) "ArcLength") ( "Length" ) ) " \\f \"" fmt "\">%" ) ) ) (setq ins (polar ins(-(LM:readable (- (angle '(0.0 0.0 0.0) (trans (vlax-curve-getfirstderiv ent par) 0 ocs t)) uxa))up-dn)(*(vla-get-Height txt)0.)) (vla-put-backgroundfill txt :vlax-true) (vla-put-attachmentpoint txt acattachmentpointmiddlecenter) (vla-put-insertionpoint txt (vlax-3D-point ins)) (vla-put-rotation txt (LM:readable (- (angle '(0.0 0.0 0.0) (trans (vlax-curve-getfirstderiv ent par) 0 ocs t)) uxa))) (setq elist (entget (vlax-vla-object->ename txt)) elist (subst (cons 45 1.15) (assoc 45 elist) elist) ;Set 'Border Offset Factor' to 1.15 elist (subst (cons 41 (* (cdr (assoc 42 elist))1.015))(assoc 41 elist) elist) ;Trim excess width ) (entmod elist) ) (LM:endundo (LM:acdoc)) ) ) (princ) ) ;; Readable - Lee Mac ;; Returns an angle corrected for text readability. (defun LM:readable ( a ) ( (lambda ( a ) (if (and (< (* pi 0.5) a) (<= a (* pi 1.5))) (LM:readable (+ a pi)) a ) ) (rem (+ a pi pi) (+ pi pi)) ) ) ;; 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 (strcat "\n:: MidLen.lsp | Version 1.0 | \\U+00A9 Lee Mac " (menucmd "m=$(edtime,0,yyyy)") " www.lee-mac.com ::" "\n:: Type \"midlen\" to Invoke ::" ) ) (princ) ;;----------------------------------------------------------------------;; ;; End of File ;; ;;----------------------------------------------------------------------;; Edited July 30, 2015 by tombu Replaced (getvar "textsize") with (vla-get-Height txt) Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 28, 2015 Author Share Posted July 28, 2015 Very nice tombu. It worked. what is the code that i can adjust how far the text field is reference from below/above the line? Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 28, 2015 Share Posted July 28, 2015 tombu has used: (*(getvar "TEXTSIZE")0. as the distance from the object - you can change the 0.8, or replace this expression by a fixed distance. Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 30, 2015 Author Share Posted July 30, 2015 tombu has used: (*(getvar "TEXTSIZE")0. as the distance from the object - you can change the 0.8, or replace this expression by a fixed distance. Thanks Lee. I change the 0.8 to another number & it worked. But what do you mean by "replace this expression by a fixed distance"? Also, is it possible to have the "distance from the line" proportionate to the size of the text? How do I change the text size? Thanks Quote Link to comment Share on other sites More sharing options...
Dadgad Posted July 30, 2015 Share Posted July 30, 2015 (edited) Just guessing, as I am illisperate, but I suspect that will be defined by your CURRENT Text style's Text Size, when you run the lisp. Worth doing a test and seeing if that controls it. Edited July 30, 2015 by Dadgad Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 30, 2015 Author Share Posted July 30, 2015 Just guessing, as I am illisperate, but I suspect that will be defined by your CURRENT Text style's Text Size, when you run the lisp.Worth doing a test and seeing if that controls it. Oh. It did worked. Quote Link to comment Share on other sites More sharing options...
vernonlee Posted July 30, 2015 Author Share Posted July 30, 2015 Hi LEE or anyone who can help. I have a couple of queries: 1) How to list the text in meters instead of millimeters? I change the units to meters but it still came out in millimeters 2) How to adjust the "distance from the line" proportionate to the size of the text? Thanks Quote Link to comment Share on other sites More sharing options...
tombu Posted July 30, 2015 Share Posted July 30, 2015 Hi LEE or anyone who can help. I have a couple of queries: 1) How to list the text in meters instead of millimeters? I change the units to meters but it still came out in millimeters Change (setq fmt "%lu6") to (setq fmt "%lu6%ct8[0.001]") 2) How to adjust the "distance from the line" proportionate to the size of the text? I modified the code above and replaced (getvar "textsize") with (vla-get-Height txt) Using the textsize worked for me because I don't assign heights to text styles. This should work in any case and again change the 0.8 to whatever you need to adjust the "distance from the line" proportionate to the size of the text. Quote Link to comment Share on other sites More sharing options...
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.