乐筑天下

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

[编程交流] LISP | Clean Drawing | Explode

[复制链接]

2

主题

6

帖子

4

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:08:23 | 显示全部楼层 |阅读模式
Explanation: To clean up consultant drawings I explode everything multiple times, move all objects to 0 layer, change all properties to By Layer (or equivalent), and purge the file. Then I Ctrl+Shift+C to select base point and in my file Ctrl-Shift+V to create a clean block that serves as the base for our drawings.  
 
Goal: LISP that does all the cleaning! Including:
 
1. Explode everything multiple times
2. Select everything in file and
   layer --> 0
   color -->By Layer
   linetype --> By Layer
   lineweight --> By Layer
3. Purge everything (to be left with only 0 layer)
 
I've found bits and pieces in different posts, but I am hoping to get some more comprehensive help.
 
 
Thank you for your time, in advance!
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

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

铜币
390
发表于 2022-7-5 16:17:15 | 显示全部楼层
Something like this?
 
  1. (defun C:BIGBANG ( / );; First we busrt everything a few times...(setq timesexplode 10) ;Change number to suit your needs(repeat timesexplode(setvar "qaflags" 1)(command ".explode" (ssget "_X" ) "")(setvar "qaflags" 0));define allobjects(setq allobjects (ssget "_X" ));; Now set everything by layer...(command "_SetByLayer" allobjects "" "Yes" "Yes");; Set everything to layer 0(command "_CHANGE" allobjects "" "Properties" "Layer" "0" "");; Set current layer 0(setvar "CLAYER" "0");; Purge the drawing(command "-Purge" "All" "*" "No")(princ))(princ)
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:23:06 | 显示全部楼层
THIS should get you the layer 0 part.
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-5 16:29:17 | 显示全部楼层
Would running the Overkill command be necessary with these drawings?
 
You should purge Regapps first then do a Purge > All.
 
I would also suggest running the Audit command and answer Yes to fixing any errors that are found in the database.
回复

使用道具 举报

2

主题

6

帖子

4

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:34:07 | 显示全部楼层
Aftertouch -- Thanks, your lisp works great!
 
ReMark -- I do not necessarily need overkill; the goal is just to rid the cad of any consultant blocks, layers, styles, etc. And I will look into adding the audit command, thanks for the suggestion!
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-5 16:43:17 | 显示全部楼层
Overkill rids drawings of duplicate and overlapping lines, arcs and polylines.  Have you ever tested one of the drawings to see if such entities exist in the drawings you are receiving?
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

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

铜币
390
发表于 2022-7-5 16:47:18 | 显示全部楼层
Made a few changes, added in ReMarks suggestions.
 
  1. (defun C:BIGBANG ( / );; Set undo begin and silence program(setvar "cmdecho" 0)(command "UNDO" "BEGIN");; First we busrt everything a few times(setq timesexplode 10) ;Change number to suit your needs(repeat timesexplode(setvar "QAFLAGS" 1)(command ".explode" (ssget "_X" ) "")(setvar "QAFLAGS" 0));define allobjects(setq allobjects (ssget "_X" ));; Now set everything by layer...(command "_SETBYLAYER" allobjects "" "Yes" "Yes");; Set everything to layer 0(command "_CHANGE" allobjects "" "Properties" "Layer" "0" "");; Set current layer 0(setvar "CLAYER" "0");; Audit the drawing(command "_AUDIT" "Yes");; Purge the drawing(command "_PURGE" "Regapps" "*" "No")(command "_PURGE" "All" "*" "No");; Remove duplicates for better performance(command "-OVERKILL" allobjects "" "Ignore" "None" "Done");; Tell use the program is finished(princ "\n\nJobs done.");; Set undo end and wake up program(command "UNDO" "END")(setvar "cmdecho" 1)(princ))(princ)
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:53:19 | 显示全部楼层
You also might add in something like this to unlock all layers and make sure the blocks can actually be exploded.
  1.   (setq ad (vla-get-activedocument (vlax-get-acad-object))) (vlax-for b (vla-get-blocks ad) (vla-put-explodable b :vlax-true)) (vlax-for l (vla-get-layers ad) (vla-put-lock b :vlax-false))
 
Also don't forget to localize your variables: ( / ALLOBJECTS TIMESEXPLODE)
回复

使用道具 举报

22

主题

78

帖子

59

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
114
发表于 2022-7-5 16:58:22 | 显示全部楼层
I can't really find a thread that's exactly what i'm after. I have a code that works beautifully for finding a block by its name, then using the "BURST" command on it. I would like to add more block names to it "ICEBRIDGEDYN" is the one i want to add now. I'm very new to coding. Can anyone show me the code that would look for "ICE BRIDGES" and "ICEBRIDGEDYN"?
 
  1. (vl-load-com)(defun c:BIB ( / e ss objs blk) ; by name (setq e "ICE BRIDGES" ; (getstring T "ICE BRIDGES")       objs (ssadd)) (if (setq ss (ssget "_X" '((0 . "INSERT"))))   (progn     (repeat (setq i (sslength ss))       (setq name (strcase (vla-get-effectivename (vlax-ename->vla-object (setq blk (ssname ss (setq i (1- i))))))))       (if (wcmatch name (strcase e))         (ssadd blk objs)))   (if (> (sslength objs) 0)     (progn(sssetfirst nil objs)(c:burst))))) (princ))
 
can anyone help me out?
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 17:08:01 | 显示全部楼层
  1. (setq e "ICE BRIDGES,ICEBRIDGEDYN")
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 20:02 , Processed in 0.816275 second(s), 72 queries .

© 2020-2025 乐筑天下

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