乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 58|回复: 13

[编程交流] Change Layer-Keep original pro

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 17:37:35 | 显示全部楼层 |阅读模式
I am looking for a LISP routine that will change the layer of multiple objects yet have is so each object maintains the same properties(i.e. color, linetype) of the original layer.  
 
Thanks BigJim2112
 
My name was suppose to be BigJim2112 not "Bib" but must have pressed the wrong button.  :roll:
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 17:45:34 | 显示全部楼层
Welcome to CADTutor.
 
Try this program;
  1. (defun c:chglay  (/ lay sel int) ;; Tharwat - date: 30.may.2016 ;; (cond   ((and (setq lay (getstring t "\nSpecify layer name:"))         (not (tblsearch "LAYER" lay)))    (alert (strcat "Layer name  is not found !")))   ((and (princ (strcat "\nSelect objects to move to layer  :"))         (setq sel (ssget "_:L" '((0 . "~VIEWPORT")))))    (repeat (setq int (sslength sel))      (entmod (append (entget (ssname sel (setq int (1- int))))                      (list (cons 8 lay)'(62 . 256) '(6 . "ByLayer") '(370 . -1))))      )    )   ) (princ) )
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 17:51:01 | 显示全部楼层
Thanks Tharwat for the post.  The routine changes the layers of the objects but the objects take on the color and linetype of the new layer.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:54:34 | 显示全部楼层
BibJim2112 you need a two step entmod read the colour and linetype of the object and reset the "bylayer" to the old colour, if (assoc 62 obj) returns nil then obj is by layer so you must then go and read the layer table to find its default color setting.
 
  1. ; not tested !!(repeat (setq int (sslength sel))(setq obj (ssname sel (setq int (1- int))))(setq col (assoc 62 obj)) ; need check here for by colour and look up layer table(setq lt (assoc 1 obj)) ; need check here for by layer and look up layer table      (entmod (append obj)                      (list (cons 62 Col))                      (list (cons 6 Lt))                      (list (cons 8 lay))      )
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 18:00:10 | 显示全部楼层
 
 
I thought you did want them to change as described into your first post !
Anyway CODES UPDATED ABOVE.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:00:53 | 显示全部楼层
Assuming I've correctly understood, please try the following:
  1. (defun c:layerchange ( / enx idx itm lay lst new old sel )   (while (and (/= "" (setq new (getstring t "\nSpecify new layer: "))) (not (snvalid new)))       (princ "\nLayer name invalid.")   )   (if (and (/= "" new) (setq sel (ssget "_:L" '((0 . "~VIEWPORT")))))       (repeat (setq idx (sslength sel))           (setq enx (entget (ssname sel (setq idx (1- idx))))                 old (assoc 8 enx)           )           (if (setq itm (cdr (assoc old lst)))               (setq enx (append enx itm))               (setq lay (entget (tblobjname "layer" (cdr old)))                     lst (cons (list old (assoc 62 lay) (assoc 6 lay) (assoc 370 lay)) lst)                     enx (append enx (cdar lst))               )           )           (entmod (subst (cons 8 new) old enx))       )   )   (princ))
回复

使用道具 举报

2

主题

84

帖子

83

银币

初来乍到

Rank: 1

铜币
9
发表于 2022-7-5 18:09:15 | 显示全部楼层
Thank you Lee Mac. Very nice lisp to have if you want to move things to a hidden layer, but still want everything to look the same.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:12:49 | 显示全部楼层
 
You're welcome - I'm glad you find it useful!
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 18:15:32 | 显示全部楼层
Thanks guys for the help on this!!!!  Programs work amazing.   Lee Mac...not only has your program worked flawlessly but you have some cool stuff on your website.   I am just starting to learn LISP and your site was a HUGE help.  If you ever get to Orlando Florida I will buy you a beer(assuming you are 21 of course).  LOL
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:19:16 | 显示全部楼层
 
Many thanks Jim - I'm delighted that you find the program and my site so useful, and I'll certainly keep your offer in mind if ever I'm in Orlando!
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 03:16 , Processed in 0.371108 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表