Lt Dan's legs Posted August 3, 2010 Posted August 3, 2010 Is it possible to get a polyline around a single line text without having to draw it in? TEXT: (defun C:TEST (/ # TXT INS) (setq # (getstring "\nSpecify item #: ")) (setq TXT (strcat "ITEM #:" #)) (setq INS (getpoint "\nSpecify insertion point: ")) (entmake (list (cons 0 "text")(cons 1 TXT)(cons 10 ins) (cons 11 ins)(cons 40 2.5)(cons 72 0))) (princ) ) Quote
MSasu Posted August 3, 2010 Posted August 3, 2010 Please take a look on TEXTBOX function - it will return the bounding box for a piece of text (as opposite corners). Regards, Quote
ReMark Posted August 3, 2010 Posted August 3, 2010 Why go through all the bother? The city of Grand Rapids has a lisp routine that does just that (i.e. - places a lightweight polyline around selected Text or MText. The routine's file name is GR_TBOX.lsp. I just downloaded it and gave it a try. Seems to work OK to me. Quote
mdbdesign Posted August 3, 2010 Posted August 3, 2010 What about "tcircle" from Express Tools. It has offset options. Quote
ReMark Posted August 3, 2010 Posted August 3, 2010 What about "tcircle" from Express Tools. It has offset options. Learn something new every day here. Quote
mdbdesign Posted August 3, 2010 Posted August 3, 2010 Button macro (for rectangle): *^C^Cselect;\tcircle;p;;0.3;R;V; Works for single and window selection with preset offset (0.3) ^C^C_text;\;;\^C^C_select;L;;_tcircle;p;;0.35;R;V;; _qleader Insert text, wrap it with rectangle and add leadder (may be done in reverse) Quote
Lt Dan's legs Posted August 3, 2010 Author Posted August 3, 2010 Thanks mdbdesign, but why a macro? Quote
mdbdesign Posted August 3, 2010 Posted August 3, 2010 Good question. Get used to button instead of typing...easier than write lisp with all option... I don't know...your pick. Quote
Lt Dan's legs Posted August 3, 2010 Author Posted August 3, 2010 I found an example of textbox in acad help. That helped a lot! Thanks for the effort and knowledge of tcircle. I bet it will come in handy. I found something weird though. When I tried to write tcircle into lisp and it didn't work.. (defun c:test (/ ss) (setq ss (ssget)) (command "_.tcircle" ss "" 0.3 "retangles" "variable") (princ) ) Quote
alanjt Posted August 3, 2010 Posted August 3, 2010 I found an example of textbox in acad help. That helped a lot! Thanks for the effort and knowledge of tcircle. I bet it will come in handy. I found something weird though. When I tried to write tcircle into lisp and it didn't work.. (defun c:test (/ ss) (setq ss (ssget)) (command "_.tcircle" ss "" 0.3 "retangles" "variable") (princ) ) From a LISP, another LISP routine cannot be called like that. Quote
alanjt Posted August 3, 2010 Posted August 3, 2010 work around... (defun c:Test (/ ss) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (progn (sssetfirst nil ss) (vla-sendcommand (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) "_.TCIRCLE 0.3 RECTANGLES VARIABLE " ) ) ) (princ) ) Quote
Lee Mac Posted August 3, 2010 Posted August 3, 2010 SendCommand - on rare occasions, pretty useful stuff Quote
alanjt Posted August 3, 2010 Posted August 3, 2010 SendCommand - on rare occasions, pretty useful stuff Rare and if used with caution. Quote
Lee Mac Posted August 3, 2010 Posted August 3, 2010 To offer an alternative, this should work with all TEXT, in any UCS or View: (defun c:tBox ( / ss ) ;; © Lee Mac 2010 (if (and (setq ss (ssget '((0 . "TEXT")))) (setq *o* (cond ( (getdist (strcat "\nSpecify Offset <" (rtos (setq *o* (cond ( *o* ) ( (* 0.5 (getvar 'TEXTSIZE)) )) ) ) "> : " ) ) ) ( *o* ) ) ) ) ( (lambda ( i / e ) (while (setq e (ssname ss (setq i (1+ i)))) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (assoc 8 (entget e)) (cons 90 4) (cons 70 1) (cons 38 (caddr (dxf 10 (entget e)))) (assoc 210 (entget e)) ) (mapcar '(lambda ( x ) (cons 10 x)) (LM:TextBox e *o*)) ) ) ) ) -1 ) ) (princ) ) (defun dxf ( code lst ) (cdr (assoc code lst))) ;;---------------------=={ Text Box }==-----------------------;; ;; ;; ;; Returns the coordinates (in OCS) of the rectangle ;; ;; enclosing the specified Text entity with specified offset ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; ent - Text Entity ;; ;; offset - Optional offset ;; ;;------------------------------------------------------------;; ;; Returns: List of Points (in OCS) framing the text ;; ;;------------------------------------------------------------;; (defun LM:TextBox ( ent offset / el base ang m ) ;; © Lee Mac 2010 (if (eq "TEXT" (dxf 0 (setq el (entget ent)))) (mapcar (function (lambda ( x ) (mapcar (function +) (mxv m x) base)) ) (progn (setq base (reverse (cdr (reverse (dxf 10 el)))) ;; 2D OCS ang (dxf 50 el) ;; to OCS X-axis m (list (list (cos ang) (- (sin ang)) 0) (list (sin ang) (cos ang) 0) (list 0 0 1) ) ) ( (lambda ( data ) (mapcar (function (lambda ( g ) (mapcar (function (lambda ( f ) ((eval f) data)) ) g ) ) ) '( ( (lambda ( x ) (- (caar x) offset)) (lambda ( x ) (- (cadar x) offset)) ) ( (lambda ( x ) (+ (caadr x) offset)) (lambda ( x ) (- (cadar x) offset)) ) ( (lambda ( x ) (+ (caadr x) offset)) (lambda ( x ) (+ (cadadr x) offset)) ) ( (lambda ( x ) (- (caar x) offset)) (lambda ( x ) (+ (cadadr x) offset)) ) ) ) ) (textbox el) ) ) ) ) ) (defun mxv ( m v ) (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m) ) Quote
ccowgill Posted January 17, 2011 Posted January 17, 2011 Is there a simple way to modify this program so it will work with both mtext and multileaders as well? I'm getting a dxf error when trying to use it on a multileader, and it doesnt appear to draw anything when selecting mtext. Quote
Lee Mac Posted January 17, 2011 Posted January 17, 2011 Latest code here: http://lee-mac.com/boxtext.html Although I haven't modified it to work with MLeaders, but it could be done. Quote
ccowgill Posted January 18, 2011 Posted January 18, 2011 Thanks, I had to cheat a little as Multileader text doesnt quite have the same properties as mtext, but It does appear to work in my testing. Quote
Lee Mac Posted January 18, 2011 Posted January 18, 2011 Thanks, I had to cheat a little as Multileader text doesnt quite have the same properties as mtext, but It does appear to work in my testing. You're welcome Chris 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.