ksperopoulos 发表于 2022-7-6 11:00:40

Setbylayer口齿不清

我正试图将这个命令(setbylayer)合并到一个lisp例程中,以清理外部参照。我正在尝试调整设置,以仅更改颜色,选择图形中的所有对象,将byblock更改为bylayer,并包括块。任何帮助都将不胜感激。

The Buzzard 发表于 2022-7-6 11:14:35

 
对于初学者,您可以查看SETBYLAYERMODE变量。
 
 
SetByLayer模式
 
类型:整数
保存在:注册表
初始值:127
 
从系统变量下的AutoCAD帮助部分。
 
控制为SETBYLAYER选择哪些特性
 
使用以下值之和将设置存储为整数:
 
0未选择属性
1颜色属性
2线型属性
4线宽特性
8材料特性
16打印样式属性
32将ByBlock更改为Bylayer
64将ByBlock更改为ByLayer时包括块
 
这里还没有显示其他信息。
 
还可以在开发者帮助部分查看ssget
 
从选定对象创建选择集
 
(ssget]
[过滤器列表])
选择集可以包含图纸空间和模型空间中的对象,但在操作中使用选择集时,ssget会从当前无效的空间中过滤出对象。ssget返回的选择集仅包含主实体(没有属性或多段线顶点)。
 
也许这条线索会给你一些想法:http://www.cadtutor.net/forum/showthread.php?t=42062&highlight=SET+BYLAYER+LISP

ksperopoulos 发表于 2022-7-6 11:24:45

这是怎么回事。(仅供参考-我是这方面的新手)
 

(defun c:cleanxref2 ()
(command "setvar" "cmdecho" 0)(command "setbylayermode" "1")
(command "setvar" "cmdecho" 0)(command "setbylayer" "all" "" "y" "y")(princ))

ksperopoulos 发表于 2022-7-6 11:32:21

setbylayer命令似乎无法获取文本设置为不同颜色的维度。此命令中是否有可以访问图形中所有注释项以及此命令更改为“bylayer”的所有其他项的设置?

The Buzzard 发表于 2022-7-6 11:45:07

这是因为它是命名dimstyle的一部分。在这种情况下,需要获取所有尺寸的选择集,并将命名的dimstyle的dimstyle变量更改为bylayer。看起来你需要做一些额外的编码。
 
 
标注文字:DIMCLRT
尺寸线:DIMCLRD
尺寸外部线:DIMCLRE

The Buzzard 发表于 2022-7-6 11:53:49

ksperopoulos,
 
下面是我在Afralisp上找到的代码http://www.afralisp.net/archive/lisp/clay.htm这涉及到将图元颜色属性设置为“bylayer”的主题。还有其他方面,例如线型和块,可以让您更好地了解如何继续。一旦你对这段代码有了想法,我希望剩下的事情会变得更容易。Afralisp有一种很好的方法,可以用简单的术语解释事情,使它更容易学习。对于线型和块,您也可以在Afralisp上找到编码。您可以根据自己的需要对其进行优化。
 
此代码处理大多数通用实体的颜色设置。
我刚把长名字从ColorToLayer改了。lsp到CTL。lsp。
;CODING BEGINS HERE

(defun c:CTL ()
(setq i 0 n 0)                                          ;clear the loop control variables
(prompt "\n Select entities to analyze ")               ;prompt the user
(setq sel (ssget))                                        ;get the selection set
(setq n (sslength sel))                                 ;get the number of objects
(repeat n                                                 ;start the loop
   (setq entity (ssname sel i))                            ;get the entity name
   (setq name (entget entity))                           ;now get the entity list
   (if (not (assoc 6 name))                              ;if not Bylayer
   (progn                                                ;do the following
       (setq layer (cdr (assoc 8 name)))                   ;retrieve the layer name
       (setq layerinf (tblsearch "LAYER" layer))         ;get the layer data
       (setq layercol (cdr (assoc 62 layerinf)))         ;extract the default layer colour
       (setq name (append name (list (cons 62 layercol)))) ;construct an append the new list
       (entmod name)                                       ;update the entity
       (entupd entity)                                     ;update the screen
   )                                                   ;progn
   )                                                       ;if
   (setq i (1+ i))                                       ;increment the counter
)                                                         ;repeat
(princ))                                                ;defun
(princ)

;CODING END HERE

ksperopoulos 发表于 2022-7-6 12:08:23

谢谢Buzzard!我有很多东西要学。
页: [1]
查看完整版本: SetbylayerLisp程序