motee-z 发表于 2022-7-5 19:45:28

你好freinds

你好,朋友们
即使是bylayer,我们如何获得实体颜色
我使用这个语法
(setq e (car(entsel"\select entity>... ")))
(setq objcolor (vla-get-Color (vlax-ename->vla-object e)))
如果实体bylayer的颜色值为256,无论颜色是什么

Lee Mac 发表于 2022-7-5 19:54:36

快速示例:
(defun entcolor ( enx )
   (cond
       ((cdr (assoc 62 enx)))
       ((abs (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 enx)))))))
   )
)
使用DXF数据调用,例如:
(if (setq ent (car (entsel)))
   (entcolor (entget ent))
)

motee-z 发表于 2022-7-5 20:06:30

李出了点问题
我在获取value entcolor时收到一条消息
#
我想要的是拾取多段线或直线,然后获取其颜色将颜色存储在变量中以供以后使用

Lee Mac 发表于 2022-7-5 20:15:03

您如何调用该函数?
您如何使用函数返回的值?

motee-z 发表于 2022-7-5 20:25:40

(defun c:gcolr (/)
(defun objco ( enx )
   (cond
       ((cdr (assoc 62 enx)))
       ((abs (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 enx)))))))
   )
)
(if (setq e (car (entsel"\n pick polyline,line")))
   (objco (entget e))
)
)
颜色值存储在哪里

Lee Mac 发表于 2022-7-5 20:29:09

 
对于当前代码,不会存储颜色值,因为您没有使用“objco”函数返回的值。
 
考虑以下因素:
(defun c:gcolr ( / c e )
   (if (setq e (car (entsel)))
       (setq c (objco (entget e)))
   )
   (if c
       (princ (strcat "\nThe colour of the selected object is: " (itoa c)))
       (princ "\nThe user did not select an object.")
   )
   (princ)
)
(defun objco ( enx )
   (cond
       ((cdr (assoc 62 enx)))
       ((abs (cdr (assoc 62 (tblsearch "layer" (cdr (assoc 8 enx)))))))
   )
)

motee-z 发表于 2022-7-5 20:38:37

谢谢李,没关系

Lee Mac 发表于 2022-7-5 20:52:28

不客气。
页: [1]
查看完整版本: 你好freinds