874185423 发表于 2011-11-1 12:23:17

求助:程序有何问题

我照搬论文上的程序有何错误,如何改正?多谢。此程序是两高程点间按个数内插高程的程序,部分命令为CASS命令,代码如下

(defun c:gscg ()
(command "layer" "set" "GCD" "")
(setq P1 (getpoint "\n 第一个点:"))
(princ p1)
(setq P2 (getpoint "\n 第二个点:"))
(princ p2)
(setq n (getint "\n 插入点个数:"))
(setq y1 (car p1))
(setq x1 (cadr p1))
(setq z1 (caddr p1))
(setq y2 (car p2))
(setq x2 (cadr p2))
(setq z2 (caddr p2))
(setq m (1 + n))
(setq y0 (/ (- y1 y2) m))
(setq x0 (/ (- x1 x2) m))
(setq z0 (/ (- z1 z2) m))
(setq test 1)
(while ( < = test (1 -m))
(setq y ( + y2 ( * test y0)))
(setq x ( + x2 ( * test x0)))
(setq z ( + z2 ( * test z0)))
(setq test (1 + test))
(setq p (list y x z))
(setq pp (list (1 + (1 + (1 +y))) x))
(command "insert" "gc200" "s" "1" p "0.00")
(command "point" p)
(setq zz (rtos z 2 2))
(command "dtext" "j" "ml" pp "1.00" "0.00" zz)
(command "zjwz" "2.000000" zz pp)
)
)


运行如下:
命令: gscg
第一个点:(100.429 56.0487 30.27)
第二个点:(197.486 76.2345 31.45)
插入点个数:5
; 错误: 函数错误: 1

Andyhon 发表于 2011-11-1 13:04:26

(setq m (1 + n))
==>
(setq m (1+ n))
--------------------
( < = test (1 -m))   ==> 得改

874185423 发表于 2011-11-1 17:55:35

已做修改,另外怎样加入对象捕捉开(捕捉圆心),怎样循环使用?
(defun c:gscg ()
(command "layer" "set" "GCD" "")
(setq P1 (getpoint "\n 第一个点:"))
(princ p1)
(setq P2 (getpoint "\n 第二个点:"))
(princ p2)
(setq n (getint "\n 插入点个数:"))
(setq y1 (car p1))
(setq x1 (cadr p1))
(setq z1 (caddr p1))
(setq y2 (car p2))
(setq x2 (cadr p2))
(setq z2 (caddr p2))
(setq m (1+ n))
(setq y0 (/ (- y1 y2) m))
(setq x0 (/ (- x1 x2) m))
(setq z0 (/ (- z1 z2) m))
(setq test 1)
(while ( <= test (1- m))
(setq y ( + y2 ( * test y0)))
(setq x ( + x2 ( * test x0)))
(setq z ( + z2 ( * test z0)))
(setq test (1+ test))
(setq p (list y x z))
(setq pp (list (1+ (1+ (1+ y))) x))
(command "insert" "gc200" "s" "0.5" p "0.00")
(setq zz (rtos z 2 2))
(command "zjwz" zz "2.000000" pp)
)

vormittag 发表于 2011-11-1 18:03:27

874185423 发表于 2011-11-1 17:55 static/image/common/back.gif
已做修改,另外怎样加入对象捕捉开(捕捉圆心),怎样循环使用?
(defun c:gscg ()
(command "layer" "se ...


......
(setq os (getvar "osmode"))
(setvar "osmode" 4)
......
(setvar "osmode" os)

874185423 发表于 2011-11-2 12:12:00

上面的程序选择两点内插高程后就结束了,如何修改为选择两点内插高程后重复选择两点,直到用户取消为止?

Andyhon 发表于 2011-11-2 12:33:14

(setq P1 (getpoint "\n 第一个点:"))
==>
(while (setq P1 (getpoint "\n 第一个点:"))
....
)
页: [1]
查看完整版本: 求助:程序有何问题