- UID
- 750948
- 积分
- 4
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2015-6-12
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2015-6-14 12:51:40
|
显示全部楼层
下面是个LSP源码,是否可以按这个思路改下,由于本人不懂,所以请请高手编写一个重叠相同的字和字符串变色变色的LSP,万分感谢
(defun c:max (/ ss ename i% ent string maxlist1
x y h ss1 ename1 string1 maxlist2
n% str1 str2 str3 newstr
)
(command "_.undo" "begin")
(command "_.color" "")
(setq dimzin0 (getvar "dimzin"))
(setq ss (ssget (list (cons 0 "TEXT")
(cons 62 5)
)
)
)
(setq i% 0)
(while (setq ename (ssname ss i%))
(setq ent (entget ename)
string (cdr (assoc 1 ent))
)
(setq maxlist1 (string->maxlist string))
(setq x (cadr (assoc 10 ent))
y (caddr (assoc 10 ent))
h (/ (cdr (assoc 40 ent)) 2)
)
(setq ss1 (ssget "X"
(list
(cons -4 "<AND")
(assoc 0 ent)
(assoc 50 ent)
(cons -4 "<NOT")
(cons 62 5)
(cons -4 "NOT>")
(cons -4 ">=,>=,*")
(list 10 (- x h) (- y h) 0)
(cons -4 "<=,<=,*")
(list 10 (+ x h) (+ y h) 0)
(cons -4 "AND>")
)
)
)
(setq n% 0)
(while (setq ename1 (ssname ss1 n%))
(setq string1 (cdr (assoc 1 (entget ename1))))
(setq maxlist2 (string->maxlist string1))
(setq maxlist1 (mapcar 'max maxlist1 maxlist2))
(entdel ename1)
(setq n% (1+ n%))
)
(setvar "dimzin" 8)
(setq str1 (rtos (car maxlist1) 2 2))
(if (cadr maxlist1)
(setq str2 (rtos (cadr maxlist1) 2 2))
)
(if (caddr maxlist1)
(setq str3 (rtos (caddr maxlist1) 2 2))
)
(cond ((wcmatch string "*-*-*")
(setq newstr (strcat str1 "=" str2 "=" str3))
)
(t
(setq newstr str1)
)
)
(setq ent (subst (cons 1 newstr) (assoc 1 ent) ent))
(entmod ent)
(setq i% (1+ i%))
)
(setvar "dimzin" dimzin0)
(command "_.undo" "end")
)
(defun string->maxlist
(string / n str Posit1 posit2 str1 str2 str3 maxlist)
(setq n 1)
(while (if (wcmatch (substr string n 1) "@")
(setq n (1+ n))
)
)
(if (setq posit1 (vl-string-position (ascii "-") string))
(progn
(setq str1 (atof (substr string n Posit1))
str (substr string (+ Posit1 2))
)
(if (setq posit2 (vl-string-position (ascii "-") str))
;*-*-*
(setq str2 (atof (substr str 1 Posit2 ))
str3 (atof (substr str (+ Posit2 2)))
)
;*-*
(setq str2 (atof str))
)
)
;无"-"
(setq str1 (atof (substr string n)))
)
(foreach i (list str3 str2 str1) (if i (setq maxlist (cons i maxlist))))
)
|
|