乐筑天下

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

[编程交流] LISP Routine to Change ALL �

[复制链接]

47

主题

257

帖子

216

银币

后起之秀

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

铜币
229
发表于 2022-7-6 03:30:13 | 显示全部楼层 |阅读模式
Can someone provide me a basic routine to change ALL layers that have the color 'GREEN' to color 104. Doesn't matter what layers they are on (i.e. '0', 'text', 'tblock'), our office standards have switched from 'GREEN' to '104' in color.
 
So maybe just a routine that I can add to my startup routine to change ALL layers that are GREEN to 104 immediately upon opening a drawing.
 
I have racked my brain searching for a routine or even bits and pieces to create my own lisp to solve my problem. Thanks
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 03:42:35 | 显示全部楼层
Try this .
 
  1. (defun c:To104 (/ l e) (while (setq l (tblnext "LAYER" (not l))) (if (eq 3 (cdr (assoc 62 (setq e (entget (tblobjname "LAYER" (cdr (assoc 2 l))))))))   (entmod (subst '(62 . 104) (assoc 62 l) e))   ) )(princ))
回复

使用道具 举报

47

主题

257

帖子

216

银币

后起之秀

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

铜币
229
发表于 2022-7-6 03:48:59 | 显示全部楼层
Hey Tharwat,
 
Thanks for chiming in, unfortunately when I run command, it returns nothing at all. No results. Sorry. Maybe something is missing?
回复

使用道具 举报

47

主题

257

帖子

216

银币

后起之秀

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

铜币
229
发表于 2022-7-6 03:55:55 | 显示全部楼层
Hey my apologies, I misspoke when I requested the routine. The routine works, it changes the layers in the layer manager from green to 104 but I meant I also needed to change the objects and text and stuff within the drawing that have the color set to GREEN changed to 104.
 
My apologies for the confusion!!! Thanks look forward to your reply!
回复

使用道具 举报

47

主题

257

帖子

216

银币

后起之秀

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

铜币
229
发表于 2022-7-6 03:57:57 | 显示全部楼层
For instance right now what I am having to do when I enter a drawing is isolate the TEXT layer, select all and change to another layer with 104 color. I have a routine I wrote for that. simple. Then I do 'BEDIT' and click on my titleblock (with attributes), then I select all the text thats on LAYER 0 but on COLOR 3 and CHANGE TO TEXT layer with 104 as color. I click close block editor, then run 'BATTMAN' and click 'sync' then ok!
 
This seems like I can automate this with a better solution! THANKS!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 04:09:23 | 显示全部楼层
Try this routine and let me know how things went on with you .
 
  1. (defun c:Test (/ doc *error* ColorTo104 lst s) ;; Author : Tharwat AL Shoufi        ;; ;; www.CadTutor.com 11.Oct.2013    ;; (or doc     (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) ) (defun *error* (u)   (if lst     (foreach it lst       (vla-put-lock (vla-item (vla-get-layers doc) it) :vlax-true)     )   )   (princ "\n *Cancel*") ) (defun ColorTo104 (ent)   (if (eq 3 (vla-get-color ent))     (vla-put-color ent 104)   ) ) (vlax-for l (vla-get-layers doc)   (ColorTo104 l)   (if (eq :vlax-true (vla-get-lock l))     (progn       (vla-put-lock l :vlax-false)       (setq lst (cons (vla-get-name l) lst))     )   ) ) (vla-startUndomark doc) (vlax-for b (vla-get-blocks doc)   (if (and (eq :vlax-false (vla-get-IsXref b))            (eq :vlax-false (vla-get-IsLayout b))       )     (vlax-for x b       (ColorTo104 x)     )   ) ) (if (ssget "_X"            '(              (-4 . "")             )     )   (progn     (vlax-for e (setq s (vla-get-ActiveSelectionSet doc))       (if (and (eq (vla-get-objectname e) "AcDbBlockReference")                (eq :vlax-true (vla-get-hasattributes e))           )         (foreach att (vlax-invoke e 'GetAttributes)           (ColorTo104 att)         )         (ColorTo104 e)       )     )     (vla-delete s)   ) ) (if lst   (foreach u lst     (vla-put-lock (vla-item (vla-get-layers doc) u) :vlax-true)   ) ) (vla-regen doc AcActiveViewport) (vla-EndUndoMark doc) (princ))(vl-load-com)
回复

使用道具 举报

0

主题

99

帖子

99

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 04:10:25 | 显示全部楼层
Tharwat, why not filter the selection?
 
  1. (ssget "_X" '(               (-4 . "")              ) )
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 04:22:10 | 显示全部楼层
 
Thank you jdiala for the suggestion , honestly I tried to add that filter to the ssget function but all my tries failed .
 
Codes updated .
回复

使用道具 举报

47

主题

257

帖子

216

银币

后起之秀

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

铜币
229
发表于 2022-7-6 04:29:59 | 显示全部楼层
You are a saint! :notworthy::notworthy:
 
WORKED FLAWLESSLY!!! Now thanks to you a 1-2 minute routine in a drawing takes milliseconds with the type of my shortcut!!
 
I am decent when it comes to editing and manipulating certain routines but am totally unfamiliar with the VLAX, VLA, etc.... its gibberish to me. But hey I am still young and I learn new things everyday. One day I will be as good as you!!
 
GOD BLESS YOU AND THANK YOU THANK YOU THANK YOU!! PROPS!!!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 04:34:42 | 显示全部楼层
 
Excellent , You're very welcome.
 
I am very happy for you too .
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 18:49 , Processed in 0.792698 second(s), 72 queries .

© 2020-2025 乐筑天下

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