本帖最后由 mandala 于 2010-12-19 18:45 编辑
小弟刚开始接触lisp,很是喜欢,最近一直在弄一个画围墙的lsp,过程中明经的很多朋友帮了我不少忙,尤其是Gu_xl和Longfin这两位高手,给了我太大的帮助。总之现在这个东西搞下来是这样的:
- (DEFUN C:wq()
- (setvar "celtype" "wq")(setvar "CMDECHO" 1)
- (if (= (setq th (getreal "输入墙厚度:(默认为0.5):")) nil)(setq th 0.5))
- (command "_.PLINE" )
- (while (= (getvar "CMDACTIVE") 1) (command pause))
- (setq E1 (entlast))
- (setq a (vlax-ename->vla-object (entlast)))
- (vla-offset a (- th));;作平行线
- (setq E2 (entlast))
- (command "_.LINE" "_NON" (vlax-curve-getStartPoint E1) "_NON" (vlax-curve-getStartPoint E2) "")
- (command "_.LINE" "_NON" (vlax-curve-getEndPoint E1) "_NON" (vlax-curve-getEndPoint E2) "");;连接头尾两端
- (command "chprop" E2 "" "lt" "continuous" "");;改变第二条线的线型
- (command "_.explode" E1)
- )
上边这段知识产权几乎完全属于Longfin先生,原帖在这里:http://bbs.mjtd.com/thread-84585-1-1.html
我只是稍稍改动了一下,汗一个。
然后我发现打散后,有些圆弧的线型是反向的,于是只好继续求助:http://bbs.mjtd.com/thread-84628-1-1.html
于是Gu_xl 先生很热心地为我提供了以下这段程序:
- ;;;线型 810 和810a互为反向线型
- (defun c:tt(/ en enl enlist n el)
- (setvar "celtype" "810")
- (command "pline")
- (while (= 1 (getvar "cmdactive"))
- (command pause)
- )
- (setq en (entlast))
- (setq enl (entget en))
- (setq enl (vl-remove-if '(lambda (x) (/= 42 (car x))) enl))
- (command "explode" en)
- (while (setq en (entnext en))
- (setq enlist (cons en enlist))
- )
- (setq enlist (reverse enlist)
- n 0)
- (repeat (length enl)
- (if (/= 0 (cdr (nth n enl)))
- (if (< (cdr (nth n enl)) 0)
- (progn
- (setq el (entget (nth n enlist)))
- (setq el (subst (cons 6 "810a") (assoc 6 el) el))
- (entmod el)
- )
- )
- )
- (setq n (1+ n))
- )
- (princ)
- )
我试过这段程序,也很好用。但当我试着把这两个程序组合起来时,却怎么也无法得到想要的结果:
- (defun c:wq()
- (setvar "celtype" "wq")(setvar "CMDECHO" 1)
- (if (= (setq th (getreal "输入墙厚度:(默认为0.5):")) nil)(setq th 0.5))
- (command "_.PLINE" )
- (while (= (getvar "CMDACTIVE") 1) (command pause))
- (setq E2 (entlast))
- (setq en (entlast))
- (setq enl (entget en))
- (setq enl (vl-remove-if '(lambda (x) (/= 42 (car x))) enl))
- (setq a (vlax-ename->vla-object (entlast)))
- (vla-offset a (- th))
- (setq E3(entlast))
- (command "_.LINE" "_NON" (vlax-curve-getStartPoint E2) "_NON" (vlax-curve-getStartPoint E3) "")
- (command "_.LINE" "_NON" (vlax-curve-getEndPoint E2) "_NON" (vlax-curve-getEndPoint E3) "")
- (command "chprop" E3 "" "lt" "continuous" "")
- (command "_.explode" en)
- (while (setq en (entnext en))
- (setq enlist (cons en enlist))
- )
- (setq enlist (reverse enlist)
- n 0)
- (repeat (length enl)
- (if (/= 0 (cdr (nth n enl)))
- (if (< (cdr (nth n enl)) 0)
- (progn
- (setq el (entget (nth n enlist)))
- (setq el (subst (cons 6 "wqa") (assoc 6 el) el))
- (entmod el)
- )
- )
- )
- (setq n (1+ n))
- )
- )
请大家帮我看看问题到底出在哪里啊?
|