PDA

View Full Version : Offsettintg text off a line



rortiz
2005-06-06, 01:39 PM
Hello All

I have multiple instances of text (Mtext and Dtext) whose insertions are aligned to lines at various angles (ie: Center or TC) I would like to shift the text away from the line a set distance based on the insertion point of the text. That is, I would like to offset the Center aligned text "up" and the TC aligned text down. I've searched and Googled "text" and "shift" and "offset" and have had no luck. Is anyone aware of a lisp routine that can do what I'm seeking?

Thanks!

Ron

pracslipkerm
2012-03-11, 11:50 AM
Try this, fairly rough but should do the job I hope

(defun c:ot ( / ss flt N )
; Save Current Echo State
(setq oldCmdEcho (getvar 'CMDECHO))
; Turn Echo Off
(setvar "cmdecho" 0)
; Set Selection Set Filter to Text and MText
(setq flt '((-4 . "<OR")
(0 . "TEXT") (0 . "MTEXT")
(-4 . "OR>")
)
);setq
(setq ss (ssget flt))
(if (/= nil ss)
(progn
; Set Offsets, Counter, Entity Name and Entity
(setq offset1 "0,-5"
offset2 "0,5"
N 0
enam nil
en nil
);setq
; Cycle through Selection Set
(repeat (sslength ss)
; Get Name of Entity in Selection Set
(setq enam (ssname ss N))
; Get DXF code list for Current Entity
(setq en (entget enam))
; Get Justification of Current Entity
(setq eJust (cdr (assoc 71 en)))
; Add Current Entity to Temporary Selection Set
(setq sstemp (ssadd enam))
; Check Current Entity
(cond ((= eJust 2)
; If Aligned Top Centre
(command "move" sstemp "" "D" offset1 "")
);End Condition 1
((= eJust 0)
;If aligned Centre
(command "move" sstemp "" "D" offset2 "")
);End Condition 2
);End Conditions
(setq N (+ N 1))
) ;end loop
(princ (strcat "\n" (itoa (sslength ss)) " objects modified."))
);progn then got a selection set
);if
; Restore Echo State
(setvar "cmdecho" oldCmdEcho)
;Exit cleanly
(princ)
)
Cheers
Steve :-)