明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1882|回复: 4

[讨论] 请问如何实现这样加载?

[复制链接]
发表于 2010-4-7 11:39:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2010-4-7 15:00:51 编辑

请问如何实现这样加载?我实现想加载后先运行AA命令,才能运行BB命令,如果没有运行AA命令,则BB命令不能加载运行.如何才能做到?(这几个程序写在一个LISP文件KK.LSP内)

(defun c:aa()
       (load"C:/kk/kk.lsp")
)

(defun c:bb (/ a mumer tysm tysm tyl sjl tcl zqm chklay)
   (command "layer" "on" "*" "")
   (prompt "\n单显图层程序,请点取要打开的图层:")
   (setq a (ssget))
   (if (not a)
     (command "layer" "on" "*" "" "")
     (progn
       (command "layer" "off" "*" "y" "")
       (setq mumer 0)
       (setq tysm (sslength a))
       (repeat tysm
  (setq ty1 (ssname a mumer))
  (setq sj1 (entget ty1))
  (setq tc1 (cdr (assoc 8 sj1)))
  (command "layer" "on" tc1 "")
  (command "layer" "on" (strcat (cdr (assoc 8 sj1)) "*") "")
  (setq mumer (1+ mumer))
       )
     )
   )
   (princ)
)

本帖子中包含更多资源

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

x
发表于 2010-4-7 16:52:00 | 显示全部楼层

(defun c:aa ()

(setq flag t)

(if flag

(defun c:bb ()

 ...

)

)

)

程序加载后,只有运行aa后才能运行bb

 楼主| 发表于 2010-4-7 21:08:00 | 显示全部楼层
谢谢!我试试
 楼主| 发表于 2010-4-7 22:14:00 | 显示全部楼层
Gu_xl发表于2010-4-7 16:52:00(defun c:aa ()(setq flag t)(if flag(defun c:bb () ...)))程序加载后,只有运行aa后才能运行bb

我试了一下,确实不错,但是如果我的程序还有cc等与bb同级别命令程序加入,就会出现不认CC等命令,不知哪错了,如何改动?

(defun c:aa()
       (load"C:/kk/kk.lsp")
(setq flag t)
(if flag
(defun c:bb (/ a mumer tysm tysm tyl sjl tcl zqm chklay)
   (command "layer" "on" "*" "")
   (prompt "\n单显图层程序,请点取要打开的图层:")
   (setq a (ssget))
   (if (not a)
     (command "layer" "on" "*" "" "")
     (progn
       (command "layer" "off" "*" "y" "")
       (setq mumer 0)
       (setq tysm (sslength a))
       (repeat tysm
  (setq ty1 (ssname a mumer))
  (setq sj1 (entget ty1))
  (setq tc1 (cdr (assoc 8 sj1)))
  (command "layer" "on" tc1 "")
  (command "layer" "on" (strcat (cdr (assoc 8 sj1)) "*") "")
  (setq mumer (1+ mumer))
       )
     )
   )
   (princ)
)
(defun c:nd ()
   (setvar "CMDECHO" 0)
   (setq sc (getdist "\nselect a point to point 从一点到另一点确定字体高度 :"))
   (setq bn (getint "\nInput begin number 输入起始序号:"))
   (setq sc1 (* sc 0.53))
   (while (setq p1 (getpoint "\nInsert Point :"))
    (command "text" "j" "m" p1 sc1 "" bn)
    (setq s1 (entlast))
    (setq txtn (itoa bn))
    (setq bn (1+ bn))
    (while (and (setq ss (ssget "X" (list '(0 . "TEXT") (cons 1 txtn))))
           (= (sslength ss) 2))
     (setq ss (ssdel s1 ss)
           s1 (ssname ss 0)
           ent (entget s1)
           txtn (itoa (1+ (atoi txtn)))
           ent (subst (cons 1 txtn) (assoc 1 ent) ent))
     (entmod ent)
    )
   )
   (setvar "CMDECHO" 1)
   (princ)
)
)
)

发表于 2010-4-7 23:40:00 | 显示全部楼层
if的结束括号位置错了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-1 23:44 , Processed in 0.189682 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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