乐筑天下

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

[编程交流] Changes entities to layer 0, c

[复制链接]

4

主题

7

帖子

3

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 11:48:02 | 显示全部楼层 |阅读模式
Looking for lisp to do the following:
Changes entities to layer 0, color GREEN and nothing else.
 
any help?
 
Thanks
jim
回复

使用道具 举报

10

主题

109

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 11:54:32 | 显示全部楼层
OK, change simple entities green, move them to layer zero and nothing else.
(Requires preselect, so PICKFIRST must be on)
 
  1. (defun c:lzg (/ gsel sslen n en el)(setq gsel (ssget "I"))(setq sslen (sslength gsel))(setq n 0)(if gsel(while (< n sslen) (setq en (ssname gsel n)) (setq el (entget en)) (setq el (subst (cons 62 3) (assoc 62 el) el)) (setq el (subst (cons 8 "0") (assoc 8 el) el)) (entmod el) (setq n (+ n 1)) ))(setq gsel nil)(princ))
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-6 12:05:17 | 显示全部楼层
Yikes!  I hope I never have to work on your drawings....
回复

使用道具 举报

14

主题

719

帖子

706

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 12:09:19 | 显示全部楼层
 
Not that I doubt the lisp-capability, but why not do a Ctrl+A (to select everything) then change the layer and color in the Properties palette?
 
But I agree with above, this sounds like you'll just mess up your drawing. IF you care to let us know what the purpose is, there might be better ways to do it.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:15:13 | 显示全部楼层
CALCAD,
 
You will need to allow for those ent's without a DXF 62 code
 
  1. (defun c:doit (/ i ss ent eLst) (if (setq i -1 ss (ssget "_:L"))   (while (setq ent (ssname ss (setq i (1+ i))))     (setq eLst (entget ent))          (setq eLst (subst '(8 . "0") (assoc 8 eLst) eLst))     (entmod       (if (assoc 62 eLst)         (subst '(62 . 3) (assoc 62 eLst) eLst)         (append eLst '((62 . 3))))))) (princ))
回复

使用道具 举报

10

主题

109

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 12:18:58 | 显示全部楼层
Lee,
    You're right, of course, about handling entities without the 62 dxf code (the BYLAYER entities, I guess - are there others?)
  Thanks for that. But I can't get your code to work on my old Intellicad. I looked up the "_:L" option and I see that one would
  want to avoid selecting from locked layers, but does (ssget "_:L") select anything else? I have to substitute with (ssget "I")
  to make it work.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:29:41 | 显示全部楼层
 
Hmmm.. it works fine on ACAD2010, so it could just be an issue in Intellicad with the "_:L", although I've never had that issue reported before.
 
As for the DXF 62 code, I would normally use VL to change color, as the property is always available, and its a quick one-liner, but, when dealing with DXF codes, I would always check, as BYLAYER ents won't have it.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:33:00 | 显示全部楼层
An alternative to "_:L" would be this I suppose:
 
  1. (defun c:doit (/ lock tdef i ss ent eLst) (setq lock "")  (while (setq tdef (tblnext "LAYER" (not tdef)))   (if (= 4 (logand 4 (cdr (assoc 70 tdef))))     (setq lock (strcat lock (cdr (assoc 2 tdef)) ",")))) (if (setq i -1 ss (ssget (list '(-4 . ""))))      (while (setq ent (ssname ss (setq i (1+ i))))     (setq eLst (entget ent))          (setq eLst (subst '(8 . "0") (assoc 8 eLst) eLst))     (entmod       (if (assoc 62 eLst)         (subst '(62 . 3) (assoc 62 eLst) eLst)         (append eLst '((62 . 3))))))) (princ))
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 12:36:23 | 显示全部楼层
What about heavy polylines sequential entities?  Attributes?  BLOCK table entities?
 
I actually do this a good bit.  Merge only the elements of an architect's backgound that I need onto a single layer ( "1D-ARCH" I call it ).  I retain the entity original color though, even if bylayer ( I make it the color of the original layer )
 
-David
回复

使用道具 举报

10

主题

109

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 12:47:08 | 显示全部楼层
And it sounded like such a simple question. Damn.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 10:44 , Processed in 0.552704 second(s), 83 queries .

© 2020-2025 乐筑天下

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