明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: jackieshaw

lisp中怎样调用自己编写的程序

  [复制链接]
发表于 2008-11-26 13:39:00 | 显示全部楼层

(defun c:tt (/ a) (setq a(car(entsel)))(entdel a))
(defun c:tt1()
  (c:tt)
  (princ "hello")
  )

命令: tt1

选择对象: hello"hello"

没有出现什么错误,你指的是什么错误?

发表于 2008-11-26 13:54:00 | 显示全部楼层

老兄理解错了,我重新举个例子:

;;定义一个和命令 ERASE 功能一样的程序
(defun c:tt (/ ss i)
  (setq ss (ssget))
  (repeat (setq i (sslength ss))
    (entdel (ssname ss (setq i (1- i))))
  )
  (princ)
)

;;调用command
(defun c:tt1 (/ a)
  (setq a (ssget))
  (command "_.ERASE" a "")
)

;;调用c:tt
(defun c:tt1 (/ a)
  (setq a (ssget))
  (c:tt a "");;我的意思是不能像command一样使用
)

将c:开头的函数注册为command,有时候会出错,不知为什么?

 楼主| 发表于 2008-11-26 14:50:00 | 显示全部楼层

(defun c:xpp()
(c:xp "all" "" "i" "")
)

我的输入这段之后出现这样的错误提示:

Command: xpp
; error: too many arguments

请问怎么回事

发表于 2008-11-26 18:46:00 | 显示全部楼层
caoyin发表于2008-11-26 13:54:00老兄理解错了,我重新举个例子:;;定义一个和命令 ERASE 功能一样的程序(defun c:tt (/ ss i)  (setq ss (ssget))  (repeat (setq i (sslength ss))    (entdel (ssna

;;定义一个和命令 ERASE 功能一样的程序
(defun tt (/  i)
  (setq ss (ssget))
  (repeat (setq i (sslength ss))
    (entdel (ssname ss (setq i (1- i))))
  )
  (princ)
)
(vlax-add-cmd "tt" 'tt) ;;!!!!!!!!
;;调用command
(defun c:tt1 (/ a)
  (setq a (ssget))
  (command "_.ERASE" a "")
)

;;调用c:tt
(defun c:tt2 (/ a)
  (setq a (ssget))
  (command "tt" a  "");;我的意思是不能像command一样使用
  (princ)
)

发表于 2008-11-26 19:04:00 | 显示全部楼层

这样当然不能用了

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-18 08:15 , Processed in 0.147876 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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