更改单个图元图层到指定图层的代码,求诊断
(defun c:test (/ ss)(vl-load-com)
(setq entlay (entsel "\n选择目标图层:"))
(setq objlay (vla-get-layer (vlax-ename->vla-object (car entlay))))
(prompt "\n选择要移动的图元: ")
(setq ss (ssget))
(setq n 0)
(while (< n (sslength ss))
(vla-put-layer (vlax-ename->vla-object (ssname ss n)) objlay)
(setq n (1+ n))
)
)
上面是批量改变图元图层到指定图层的代码,我想去掉循环,每次只改变一个图元的图层,如何写之歌代码?下面是运行不了的代码:
(defun c:T1 (/ ss)
(vl-load-com)
(prompt "\n选择要移动的图元: ")
(setq ss (ssget))
(vla-put-layer (vlax-ename->vla-object (ssname ss)) "1轮廓实线层")
)
(vla-put-layer (vlax-ename->vla-object (car(entsel)) "1轮廓实线层") 大侠早啊~~~
(defun c:T1 (/ ss)
(vl-load-com)
(prompt "\n选择要移动的图元: ")
(setq ss (ssget))
(vla-put-layer (vlax-ename->vla-object(car(entsel)) "1轮廓实线层")
)
-----------------
是这样吗?运行不了,估计是SS这个选择对象语句要调整? (defun c:T1 (/ ss)
(vl-load-com)
(prompt "\n选择要移动的图元: ")
(setq ss (ssget))
(vla-put-layer (vlax-ename->vla-object (ssname ss 0)) "1轮廓实线层")
) (command "CHANGE" (ssget ":S") "" "p" "la""1轮廓实线层" "") 谢谢各位!我想用下面的代码,怎么运行不了呢?
(defun c:T1 ()
(vl-load-com)
(entsel "选择一条直线:"))
(vla-put-layer (vlax-ename->vla-object (car(entsel)) "1轮廓实线层")
) (defun c:T1 ()
(vl-load-com)
(vla-put-layer (vlax-ename->vla-object (car(entsel "\n选择一条直线:"))) "1轮廓实线层")
) (defun c:T1 ()
(vl-load-com)
(if (setq ent (entsel "\n选择一条直线:"))
(vla-put-layer (vlax-ename->vla-object (car ent)) "1轮廓实线层")
)
(princ)
)
fedd 发表于 2021-11-23 12:28
谢谢各位!我想用下面的代码,怎么运行不了呢?
(defun c:T1 ()
(vl-load-com)
(entsel "选择一条直线:"))后面多个括号。vla-put-layer括号不匹配
entsel一次就够了
(defun c:T1 ()
(vl-load-com)
(vla-put-layer
(vlax-ename->vla-object(car (entsel "选择一条直线:")))
"1轮廓实线层"
)
(princ)
) 各位大侠,本小菜鸟有礼了,多谢多谢,论坛真的太温暖了,太给力了!!
页:
[1]
2