明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1953|回复: 5

求助:程序有何问题

[复制链接]
发表于 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2011-11-1 13:04:26 | 显示全部楼层
(setq m (1 + n))
==>
(setq m (1+ n))
--------------------
( < = test (1 -m))   ==> 得改

 楼主| 发表于 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)
)
发表于 2011-11-1 18:03:27 | 显示全部楼层
874185423 发表于 2011-11-1 17:55
已做修改,另外怎样加入对象捕捉开(捕捉圆心),怎样循环使用?
(defun c:gscg ()
(command "layer" "se ...

  1. ......
  2. (setq os (getvar "osmode"))
  3. (setvar "osmode" 4)
  4. ......
  5. (setvar "osmode" os)
 楼主| 发表于 2011-11-2 12:12:00 | 显示全部楼层
上面的程序选择两点内插高程后就结束了,如何修改为选择两点内插高程后重复选择两点,直到用户取消为止?
发表于 2011-11-2 12:33:14 | 显示全部楼层
(setq P1 (getpoint "\n 第一个点:"))
==>
(while (setq P1 (getpoint "\n 第一个点:"))
....
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-6-10 19:51 , Processed in 0.176138 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表