明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2135|回复: 4

[讨论] 请问怎样自动保存上次的选择

[复制链接]
发表于 2014-8-22 10:22:00 | 显示全部楼层 |阅读模式
5明经币
请问给位前辈,我写了个小程序,里面可以选择图层绘图

(initget "1 2 3 4 5 6 7 8 9")
               (setq GETK (getkword "图层(1)(2)(3)(4)(5)(6)(7)(8)(9):"))
(cond
    ((or (= GETK "1") (= GETK nil))
......

我想请问要怎么写才能自动保持上次的选择你?比如说我上一次选择了图层1,只要我再输入图层2选择前,每次按空格键就是上一次图层1的选择呢

最佳答案

查看完整内容

(setq oldlnm (if (= (type oldlnm) 'STR) oldlnm "")) (setq lnm (getstring (strcat "\n选择图层【1层到8层】" (if (> (strlen oldlnm) 0) (strcat"") ": "))) (setq lnm (if (= lnm "") oldlnm lnm)) (setq oldlnm lnm) ;...
发表于 2014-8-22 10:22:01 | 显示全部楼层
(setq oldlnm (if (= (type oldlnm) 'STR) oldlnm ""))
(setq lnm (getstring (strcat "\n选择图层【1层到8层】" (if (> (strlen oldlnm) 0) (strcat"<" oldlnm ">") ": ")))
(setq lnm (if (= lnm "") oldlnm lnm))
(setq oldlnm lnm)
;...

评分

参与人数 1金钱 +5 收起 理由
小师傅 + 5

查看全部评分

回复

使用道具 举报

发表于 2014-8-22 14:00:08 | 显示全部楼层
(if (= nil getk1) (setq getk1 1));默认图层1,
(initget "1 2 3 4 5 6 7 8 9")
               (setq GETK (getkword "图层(1)(2)(3)(4)(5)(6)(7)(8)(9):"))

(if (= getk nil)
(setq getk getk1)
(setq getk1 getk))

评分

参与人数 1明经币 +1 金钱 +5 收起 理由
小师傅 + 1 + 5

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2014-8-22 21:22:14 | 显示全部楼层
zjsru_18_505 发表于 2014-8-22 14:00
(if (= nil getk1) (setq getk1 1));默认图层1,
(initget "1 2 3 4 5 6 7 8 9")
               (setq GE ...

前辈你好,你教的东西让我受益匪浅,我还想请教一下:
(setq lnm (getstring "\n选择图层【1层到8层】: "))
if (or (= lnm "1") (= lnm "5")) (= lnm "8")) (progn
(command "-layer" "m" (strcat "QY" lnm "-墙") "c" 255 "" "")
(command "_.pline"   "non"   PT1   "non"   PT2  "non"   PT03   "non" PT04   "c" )
(command "_.pline"   "non"   PT5   "non"   PT3  "non"   PT7   "non" PT8   "c" )
....
我这样写时要做怎样才能记忆上次的图层选择呀
回复

使用道具 举报

 楼主| 发表于 2014-8-23 08:40:16 | 显示全部楼层
ZZXXQQ 发表于 2014-8-23 08:21
(setq oldlnm (if (= (type oldlnm) 'STR) oldlnm ""))
(setq lnm (getstring (strcat "\n选择图层【1层到 ...

谢谢Z版的鼎力相助,让我又学会了一招
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-24 05:27 , Processed in 0.189519 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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