Message 1 of 6

Not applicable
10-29-2018
05:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have found this code on the forums and need to modify it so it will use the rotation of the already existing text. IE if my existing text is at 92 degrees the newly inserted block should be at 92 degrees after the lisp is complete. How would I go about doing that?
(defun get_block_name (/ blkName) (if (eq (getvar "users5") "") (prompt "\nBlock name: ") (prompt (strcat "\nBlock name <" (getvar "users5") ">: ")) ); if (if (= (setq blkName (getstring t)) "") (setq blkName (getvar "users5")) (setvar "users5" blkName) ); if (if (/= blkName "") (if (null (tblsearch "block" blkName)) (progn (vlr-beep-reaction) (prompt (strcat "\nBlock " (strcase blkName) " is not exist.")) (setvar "users5" (setq blkName "")) ) ) ) blkName ) (defun get_middle_text_point (e / insPt box t0 t1 p0 p1) (setq ins (cdr (assoc '10 e))) (setq box (textbox (list (assoc '1 e)))) (setq t0 (car box) t1 (cadr box)) (setq p0 (list (+ (car ins) (car t0)) (+ (cadr ins) (cadr t0)))) (setq p1 (list (+ (car ins) (car t1)) (+ (cadr ins) (cadr t1)))) (polar p0 (angle p0 p1) (/ (distance p0 p1) 2)) ) (defun c:txt2blk (/ savOSmode savAttdia savAttreq blkName ss i ent e p10 text) (vl-load-com) (setvar "cmdecho" 0); disable command echo (command ".undo" "begin") (setq savOSmode (getvar "osmode")); save osnap (setq savAttdia (getvar "attdia")); save attdia (setq savAttreq (getvar "attreq")); save attreq (setvar "attdia" 0); disable attribute dialog (setvar "attreq" 1); enable attribute request (if (/= (setq blkName (get_block_name)) "") (if (setq ss (ssget (list '(0 . "TEXT")))); select only TEXT objects (progn (setvar "osmode" 0); disable osnap (setq i -1) (repeat (sslength ss) (setq i (1+ i)) (setq e (entget (setq ent (ssname ss i)))) (setq p10 (get_middle_text_point e)) (setq text (cdr (assoc '1 e))) (command ".insert" blkName p10 "" "" "" text) (entdel ent) ); repeat (setvar "osmode" savOSmode) ); progn ); if ); if (setvar "attdia" savAttdia); restore attdia (setvar "attreq" savAttreq); restore attreq (command ".undo" "end") (setvar "cmdecho" 1); restore command echo (princ) ); defun
Solved! Go to Solution.