明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1462|回复: 7

[已解答] 各位大师请问为什么SSGET选择会出错?

[复制链接]
发表于 2014-9-9 08:10:49 | 显示全部楼层 |阅读模式
(defun c:1 ()
(if (setq ss (ssget "i")) ;;
  (command "chprop" ss "" "c" "BYLAYER" "lt" "BYLAYER" "la" "01-粗实线层" "")
  (command "Layer" "s" "01-粗实线层" "")
)
(princ)
)

(ssget "i")出错,PICKFIRST变量也写为1了,chprop提示无效参数,但是已经有选择集了。
如果为(SSGET)就不报错,可以执行下去。不知道为什么,请个位大师解释一下。谢谢
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2014-9-9 11:39:32 | 显示全部楼层
(defun c:hi (/ ss)
  (setvar "cmdecho" 0)
  (if (not (tblsearch "layer" "dim"))
    (command "-layer" "n" "dim" "c" "4" "dim" "")
    (princ "\ndim图层已存在\n")
  );if

  (setq ss (ssget "i"))
  (if (= ss nil)
    (command "_.clayer" "dim")
    (command "_.chprop" ss "" "la" "dim" "")
  );if                                       
  
  (princ)
)
发表于 2014-9-9 12:06:22 | 显示全部楼层
(ssget "i")是什么意思?

I Implied [automated] [documented]
Implied selection (objects selected while PICKFIRST is in effect).
发表于 2014-9-9 12:50:42 | 显示全部楼层
自贡黄明儒 发表于 2014-9-9 12:06
(ssget "i")是什么意思?

I Implied [automated] [documented]

i 我的理解是,把选中的对象加入选择集,
要先选对象,再执行命令,
没选对象,再执行别的命令
 楼主| 发表于 2014-9-9 12:54:20 | 显示全部楼层
自贡黄明儒 发表于 2014-9-9 12:06
(ssget "i")是什么意思?

I Implied [automated] [documented]

请问黄大师,应该怎么改?
程序的作用是如果有选择集就将选择集设置为指定图层,如果没有选择集就将当前图层改为指定图层。谢谢
 楼主| 发表于 2014-9-9 13:05:08 | 显示全部楼层
琴剑江山_10184 发表于 2014-9-9 12:50
i 我的理解是,把选中的对象加入选择集,
要先选对象,再执行命令,
没选对象,再执行别的命令

我也是这样认为的,就是不知道为什么会出错?请问一下,把 (setq ss (ssget "i"))
这一句从if里拿出来有什么区别吗?谢谢,请指教一下?
发表于 2014-9-9 13:43:15 | 显示全部楼层
zkq1212 发表于 2014-9-9 13:05
我也是这样认为的,就是不知道为什么会出错?请问一下,把 (setq ss (ssget "i"))
这一句从if里拿出来有 ...

05下,下面是正确的
(if (setq ss (ssget "i"))
  (command "chprop" ss "" "c" "BYLAYER"        "lt" "BYLAYER" "la" "0"        "" "" "")
  (command "Layer" "s" "0" "" "")
)
发表于 2014-9-9 18:46:42 | 显示全部楼层
(setq ss (ssget "i"))
  (if (= ss nil) 改成这样
    (command "_.clayer" "dim")没选到执行这句,改成你的
    (command "_.chprop" ss "" "la" "dim" "")选中对象执行这句,改成你的
  );if                                       
  
  (princ)
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-24 04:16 , Processed in 0.171549 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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