Wwx95 发表于 2022-7-5 18:26:14

 
好的,我知道了,所以每次我用LISP编写AutoCAD命令时,最好添加下划线和前缀,并在点输入中使用“non”,谢谢!

Grrr 发表于 2022-7-5 18:31:00

我知道这个帖子已经过时了,但我最近在练习/玩这些:
; Grrr
; Another attempt for emaking pline (loop with cond behaviour):

(defun C:test ( / oldcmd ptx pt ptlst cnt )

(setq oldcmd (getvar 'cmdecho))
(while T
        (setvar 'cmdecho 0)
        (initget 1 "D Done")
        (while
                (cond
                        (
                                (not
                                        (if ptx
                                                (setq pt (getpoint "\nSpecify point or : " ptx))
                                                (setq pt (getpoint "\nSpecify point or : " ))
                                        )
                                )
                                (princ "\nYou must specify a point!")
                        )
                        ( (and (= (type pt) 'LIST) (not (or (= (type pt) 'STR) (= pt "") )) )
                                (setq ptx pt)
                                (setq ptlst (cons pt ptlst))
                                (if (>= (length ptlst) 2)
                                        (progn
                                                (setq cnt 0)
                                                (redraw)
                                                (repeat (length ptlst)
                                                        (if (nth (+ cnt 1) ptlst)
                                                                (progn
                                                                        (grdraw (nth cnt ptlst) (nth (+ cnt 1) ptlst) 2 3)
                                                                        (setq cnt (+ cnt 1))
                                                                )
                                                        )
                                                )
                                        )
                                )
                        )
                        (       
                                (or
                                        (and (wcmatch pt "DONE") (>= (length ptlst) 2) )
                                        (and (wcmatch pt "D") (>= (length ptlst) 2) )
                                )
                                (redraw)
                                (if
                                        (and
                                                (entmake '( (0 . "POLYLINE") (66 . 1)))
                                                (setq cnt 0)
                                                (repeat (length ptlst)
                                                        (entmake (list (cons 0 "VERTEX") (cons 10 (nth cnt ptlst))))
                                                        (setq cnt (+ cnt 1))
                                                )
                                                (entmake '((0 . "SEQEND")))
                                        )
                                        (progn
                                                (setq ptx nil)
                                                (setq pt nil)
                                                (setq ptlst nil)
                                                (setq cnt nil)
                                        )
                                )
                        )
                );cond
        )
        (setvar 'cmdecho oldcmd)
)
(princ)
)

由于我的grread练习:
8
我以前也见过类似的LISP,但当我试图使用grread分析光标移动并按下LMB时,意外地得到了这个结果。

fan_zh 发表于 2022-7-5 18:34:49

我打赌wwx95是中国人
页: 1 [2]
查看完整版本: 使用Autolisp绘制pline。