慧不绘 发表于 2016-2-13 11:59:02

自学lisp,写了个小程序,遇到问题望高手帮忙

程序运行过程,选取p1、p2点,输入t值,自动出来上面的矩形框。现在的问题是,如果选取p1、p2点时,生成的矩形框不在屏幕视图内运行正确,如果在屏幕视图内就会错误。请高手解答,谢谢!坐等回复




(defun c:mj()
   (setq p1 (getpoint "\n选取模板俯视图左上角:"))
   (setq p2 (getpoint "\n选取模板俯视图右下角:"))
   (setq t (getreal "\n材料厚度:"))
   (setq p1x (car p1))
   (setq p1y (cadr p1))
   (setq p2x (car p2))
   (setq p3y (+ p1y 600) p4y (+ p3y 20) p5y (+ p4y 30) p6y (+ p5y t) p7y (+ p6y 25) p8y (+ p7y 20)
         p9y (+ p8y 10) p10y (+ p9y 20) p11y (+ p10y 20))
   (setq p3 (list p1x p3y) p4 (list p1x p4y) p5 (list p1x p5y) p6 (list p1x p6y) p7 (list p1x p7y)
         p8 (list p1x p8y) p9 (list p1x p9y) p10 (list p1x p10y) p11 (list p1x p11y)
         ph4 (list p2x p4y) ph7 (list p2x p7y) ph9 (list p2x p9y) ph11 (list p2x p11y))
   (command "rectang" p3 ph4 "chprop" "l" """la""7"""
            "rectang" ph4 p5 "chprop" "l" """la""6"""
            "rectang" p6 ph7 "chprop" "l" """la""5"""
            "rectang" ph7 p8 "chprop" "l" """la""4"""
            "rectang" p8 ph9 "chprop" "l" """la""35"""
            "rectang" ph9 p10 "chprop" "l" """la""3"""
            "rectang" p10 ph11 "chprop" "l" """la""2""")
(princ)
)


lijiao 发表于 2016-2-13 16:55:26

关闭捕捉模式就行了

aihuyujian 发表于 2016-2-13 20:34:03

(command "rectang" "none" p3 "none" ph4 "chprop" "l" """la""7"""
            "rectang" "none" ph4 "none" p5 "chprop" "l" """la""6"""
            "rectang" "none" p6 "none" ph7 "chprop" "l" """la""5"""
            "rectang" "none" ph7 "none" p8 "chprop" "l" """la""4"""
            "rectang" "none" p8 "none" ph9 "chprop" "l" """la""35"""
            "rectang" "none" ph9 "none" p10 "chprop" "l" """la""3"""
            "rectang" "none" p10 "none" ph11 "chprop" "l" """la""2""")

慧不绘 发表于 2016-2-13 22:13:03

aihuyujian 发表于 2016-2-13 20:34 static/image/common/back.gif
(command "rectang" "none" p3 "none" ph4 "chprop" "l" """la""7"""
            "rectang" "none" ph4...

原来是捕捉的问题,谢谢!

慧不绘 发表于 2016-2-13 22:18:34

lijiao 发表于 2016-2-13 16:55 static/image/common/back.gif
关闭捕捉模式就行了

按3楼的方式关闭捕捉,问题解决了,谢谢!
页: [1]
查看完整版本: 自学lisp,写了个小程序,遇到问题望高手帮忙