;;;===================================================
;;;
; 加强版偏移-可偏移标注和文字[mini_offset_txt].lsp
;;;===================================================
(defun c:mini_offset_txto ( / dname loop lpi2 pt temp lhj_start
				lhj_end	do_dim do_text
			)


(defun do_dim ( / ang dlist pint pt10 pt14)
	(mai_copy dname nil nil)
	(setq
		dlist (entget (entlast))
		pt10 (mai_dxf 10 dlist)
		pt14 (mai_dxf 14 dlist)
		pint (mai_point_per2line (trans pt 1 0) pt10 pt14)
		ang	(angle pt10 pint)
		dlist
			(subst
				(cons 10 (polar pt10 ang mai_off_txt))
				(assoc 10 dlist)
				dlist
			)
	)
	(entmod dlist)
)

(defun do_text ( / ali1 ali2 ang dlist pint pt10 pt11)
	(setq
		pt (trans pt 1 0)
		dlist (entget dname)
		pt10 (mai_dxf 10 dlist)
		pt11 (mai_dxf 11 dlist)
		ang (mai_dxf 50 dlist)
		pint (mai_point_per_2_line pt pt10 (polar pt10 ang 1000))
		ang (angle pint pt)
		ali1 (mai_dxf 72 dlist)
		ali2 (mai_dxf 73 dlist)
		pint (if (= ali1 ali2 0) 10 11)
		dlist
			(subst
				(cons pint (polar (if (= pint 10) pt10 pt11) ang mai_off_txt))
				(assoc pint dlist)
				dlist
			)
	)
	(entmake (vl-remove-if '(lambda(x)(member (car x) (list -1 5))) dlist))
)


	(mini_start nil)
	(mai_last_com "mini_break_at")
	(or mai_off_txt (setq mai_off_txt 800))
	(if (setq temp (getdist (strcat "\n请输入加强版偏移<可偏移标注和文字>距离:< " (rtos mai_off_txt 2 2) " >")))
		(setq mai_off_txt temp)
	)



	(while
		(and
			(setq
				dname
					(mai_entsel
						nil
						"选择连续标注、文字和各种偏移线:<退出>"
						"选择的不是标注、文字和各种偏移线."
						'((0 . "*Polyline,line,arc,circle,spline,ellipse,ray,xline,dimension,text"))
						nil
					)
			)
			(setq pt (getpoint "\n请点取offset方向:<退出>"))
		)
		(setq
			dname (car dname)
		)
		(redraw dname 3)
		(cond
			((= (mai_dxf 0 dname) "DIMENSION") (do_dim))
			((= (mai_dxf 0 dname) "TEXT") (do_text))
			(t (command "offset" mai_off_txt dname "non" pt ""))
		)
		(redraw dname 4)
	)
	(mai_end)
)
