Modification in LISP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi guys,
I have a 2 lisp codes one is aligning the text and label on the right and another is placing it in the left.The text align for right lisp is working perfectly but the left align lisp is making issue.
When i give the lisp command "1" the text aligned on the right
defun c:1();to keep the text aligned at right side
(command "ucs" "world")
(setq objs (ssget)
scalef (/ (cdr(assoc 40(entget(ssname objs 0))))9))
(setq x_x (* scalef 4.0))
(setq y_y (* scalef 4.0))
(setq text_gap (* scalef 16.0))
(setq text_height (* scalef 9.0))
(setq ss_len (sslength objs))
(setq osm (getvar "osmode"))
(command "osnap" "qui,end")
(setq cxy (getpoint "pick a point"))
(command "osmode" 0)
(setq cx (car cxy))
(setq cy (car (cdr cxy)))
(setq count 0)
(repeat ss_len
(if (= count 0)
(progn
(setq tx1 (+ cx x_x))
(setq ty1
(+ cy
(/ (+ (* (- ss_len 1.0) text_gap) text_height)
2
)
)
)
(setq tx2 tx1)
(setq ty2 (- ty1 text_height))
)
(setq ty2 (- ty2 text_gap))
)
(setq obj (ssname objs count))
(setq objp (entget obj))
(setq objj_new (cons 72 0))
(setq objc_11 (cons 11 (list 0 0 0)))
(setq objc_10 (cons 10 (list tx2 ty2 0)))
(setq objp (subst objc_10 (assoc 10 objp) objp))
(setq objp (subst objc_11 (assoc 11 objp) objp))
(setq objp (subst objj_new (assoc 72 objp) objp))
(entmod objp)
(setq count (+ count 1))
)
(setvar "osmode" osm)
(setq lpx1 (+ cx (* 12.0 SCALEF)))
(setq lpx2 cx)
(setq lpx3 cx)
(setq lpx4 lpx1)
(setq lpy1 (+ ty1 x_x))
(setq lpy2 lpy1)
(setq lpy3
(- ty1
(+ (+ (* text_gap (- count 1)) text_height) (* scalef 5.0))
)
)
(setq lpy4 lpy3)
(setq lp1 (list lpx1 lpy1))
(setq lp2 (list lpx2 lpy2))
(setq lp3 (list lpx3 lpy3))
(setq lp4 (list lpx4 lpy4))
(setq clay (setvar "clayer" "0-25text"))
;(setvar "clayer" "0-25text")
(command "pline" lp1 lp2 lp3 lp4 "")
;(setvar "clayer" clay)
(setvar "clayer" "0-35")
)
;----------------------------------------------
when i give the lisp command "2" the text is moved to another location
--------------------------------------
(defun c:2();to the text algined at left side
(command "ucs" "World")
(setq objs (ssget)
scalef (/ (cdr(assoc 40(entget(ssname objs 0))))9))
(setq x_x (* scalef 4.0))
(setq y_y (* scalef 4.0))
(setq text_gap (* scalef 16.0))
(setq text_height (* scalef 9.0))
(setq ss_len (sslength objs))
(setq osm (getvar "osmode"))
(command "osnap" "qui,end")
(setq cxy (getpoint "pick a point"))
(command "osmode" 0)
(setq cx (car cxy))
(setq cy (car (cdr cxy)))
(setq count 0)
(repeat ss_len
(if (= count 0)
(progn
(setq tx1 (- cx x_x))
(setq ty1
(+ cy
(/ (+ (* (- ss_len 1.0) text_gap) text_height)
2
)
)
)
(setq tx2 tx1)
(setq ty2 (- ty1 text_height))
)
(setq ty2 (- ty2 text_gap))
)
(setq obj (ssname objs count))
(setq objp (entget obj))
(setq objj_new (cons 72 2))
(setq objp (subst objj_new (assoc 72 objp) objp))
(entmod objp)
(setq objp (entget obj))
(setq objj (assoc 10 objp))
(setq objjj (assoc 11 objp))
(setq objjx (car (cdr objj)))
(setq objjjx (car (cdr objjj)))
(setq deltaxx (- objjjx objjx))
(setq objc_11 (cons 11 (list tx2 ty2 0)))
(setq objc_10 (cons 10 (list (- tx2 deltaxx) ty2 0)))
(setq objp (subst objc_10 (assoc 10 objp) objp))
(setq objp (subst objc_11 (assoc 11 objp) objp))
(entmod objp)
(setq count (+ count 1))
)
(setvar "osmode" osm)
(setq lpx1 (- cx (* SCALEF 12.0)))
(setq lpx2 cx)
(setq lpx3 cx)
(setq lpx4 lpx1)
(setq lpy1 (+ ty1 x_x))
(setq lpy2 lpy1)
(setq lpy3
(- ty1
(+ (+ (* text_gap (- count 1)) text_height) (* scalef 5.0))
)
)
(setq lpy4 lpy3)
(setq lp1 (list lpx1 lpy1))
(setq lp2 (list lpx2 lpy2))
(setq lp3 (list lpx3 lpy3))
(setq lp4 (list lpx4 lpy4))
(setq clay (setvar "clayer" "0-25text"))
;(setvar "clayer" "0-25text")
(command "pline" lp1 lp2 lp3 lp4 "")
;(setvar "clayer" clay)
(setvar "clayer" "0-35")
)
Can anyone help me to fix this issue