btraemoore 发表于 2022-7-6 07:57:41

<--这家伙需要帮助

;;;get a working list of all the layers
(vl-load-com)
(setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))
(setq layertable (vla-get-layers acadDocument))
;;;make layers an array and editable
;;;make the properites of the layers accessable
;;;check the names against a standard list of valid layer names
;;;remove valid layers from the working list
;;;check the first layers color
;;;get a list of all valid layers with that color from the standard layers list
;;;check the line type of the first layer
;;;get a list of all valid layers with same line type from the modified list
;;;change the layer name to the standard valid layer name
 
 
这是我的清单,我已经通过了第一步,现在不知所措,我很确定我离目标还有很长的路要走。。。我需要一些重定向,有人能帮我吗?

MSasu 发表于 2022-7-6 08:03:33

这将帮助您构建与列表相关的图层列表:
(setq theLayer (cdr (assoc 2 (tblnext "LAYER" 1))))
(while theLayer
(setq listLayers (append listLayers (list (entget (tblobjname "LAYER" theLayer))))
      theLayer (cdr (assoc 2 (tblnext "LAYER"))))
)

btraemoore 发表于 2022-7-6 08:06:35

太棒了,这是一个好的开始。现在我需要弄清楚如何得到颜色。我在想vlax dump或vla getcolor,但我试了一下,发现了一个listp错误

MSasu 发表于 2022-7-6 08:08:01

在图层的相关列表中,颜色存储在DXF代码62下。

BIGAL 发表于 2022-7-6 08:13:17

你能更详细地阐述一下你真正想要实现的是什么吗?是为用户提供某种形式的层管理还是什么?暂时忽略代码问题。

btraemoore 发表于 2022-7-6 08:15:21

实际上,我正在尝试制作一个例程,根据图层颜色和线型自动更改图层的名称。

MSasu 发表于 2022-7-6 08:18:46

然后,您应该查找DXF代码62(颜色)和6(线型)。
(setq assocLayer (tblsearch "LAYER" LayerName)
   theName (strcat (itoa (cdr (assoc 62 assocLayer)))   ;color
                     "-"
                     (cdr (assoc 6 assocLayer))))         ;linetype

btraemoore 发表于 2022-7-6 08:21:26

是的,我大胆地使用代码来设置lt和color变量,我试图找出如何获得表长度,以便设置while循环,然后我必须找出如何将其与我拥有的列表进行比较。

pBe 发表于 2022-7-6 08:23:58

那是线型和颜色搭配吗?
 
无论如何,我认为您将在层名称上添加后缀或前缀,而不是替换整个名称。

btraemoore 发表于 2022-7-6 08:28:59

是的,线型和颜色将匹配。不,我将替换整个名称。一旦我把列表缩小到与现有层匹配的LT和颜色,我想让它比较两个名称变量中的第一个字符,并根据它选择要保存的正确层名称,或者让它通过strcat ascii评估适用层名称中的总匹配字符,也许。。。
页: [1] 2
查看完整版本: <--这家伙需要帮助