Jump to content

Recommended Posts

Posted

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)
)

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • Lt Dan's legs

    5

  • Lee Mac

    4

  • mdbdesign

    3

  • alanjt

    3

Posted

Please take a look on TEXTBOX function - it will return the bounding box for a piece of text (as opposite corners).

 

Regards,

Posted

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.

Posted

What about "tcircle" from Express Tools. It has offset options.

Posted
What about "tcircle" from Express Tools. It has offset options.

 

Learn something new every day here.

Posted

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)

Posted

Thanks mdbdesign, but why a macro?

Posted

Good question. Get used to button instead of typing...easier than write lisp with all option... I don't know...your pick.

Posted

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)
)

Posted
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.
Posted

Good to know. Thank you

Posted

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)
)

Posted
SendCommand - on rare occasions, pretty useful stuff :)
Rare and if used with caution.
Posted

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)
)

  • 5 months later...
Posted

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.

Posted

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.

Posted
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 :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...