+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Junior Member
    Using
    AutoCAD 2015
    Join Date
    Nov 2016
    Posts
    11

    Default LISP | Clean Drawing | Explode and Purge

    Registered forum members do not see this ad.

    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!

  2. #2
    Senior Member
    Discipline
    Civil
    Aftertouch's Discipline Details
    Discipline
    Civil
    Details
    Engineer
    Using
    AutoCAD 2017
    Join Date
    Jul 2016
    Location
    Netherlands
    Posts
    255

    Default

    Something like this?

    Code:
    (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)

  3. #3
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    573

    Default

    THIS should get you the layer 0 part.

  4. #4
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro K4200, 4GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2018
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    46,506

    Default

    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.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

    I'm now a full member of the Society for the Promotion of Mediocrity in CAD. Standards? We don't need no stinkin' standards! Take whatever advice I offer and do the opposite.

  5. #5
    Junior Member
    Using
    AutoCAD 2015
    Join Date
    Nov 2016
    Posts
    11

    Default

    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!

  6. #6
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro K4200, 4GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2018
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    46,506

    Default

    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?
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

    I'm now a full member of the Society for the Promotion of Mediocrity in CAD. Standards? We don't need no stinkin' standards! Take whatever advice I offer and do the opposite.

  7. #7
    Senior Member
    Discipline
    Civil
    Aftertouch's Discipline Details
    Discipline
    Civil
    Details
    Engineer
    Using
    AutoCAD 2017
    Join Date
    Jul 2016
    Location
    Netherlands
    Posts
    255

    Default

    Made a few changes, added in ReMarks suggestions.

    Code:
    (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)

  8. #8
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    573

    Default

    You also might add in something like this to unlock all layers and make sure the blocks can actually be exploded.
    Code:
      (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)

  9. #9
    Full Member
    Using
    AutoCAD 2017
    Join Date
    Oct 2013
    Posts
    72

    Default

    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"?

    Code:
    (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?

  10. #10
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    573

    Default

    Registered forum members do not see this ad.

    Code:
    (setq e "ICE BRIDGES,ICEBRIDGEDYN")

Similar Threads

  1. Replies: 7
    Last Post: 7th Mar 2014, 05:02 pm
  2. How do i can explode all blocks in drawing with lisp file??
    By hosyn in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 22nd Sep 2013, 10:50 am
  3. Clean up drawing
    By M76 in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 26th Feb 2010, 01:03 pm
  4. Drawing Clean Up Automation
    By Cad_Jockeys in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 17th Jul 2008, 10:49 pm
  5. explode and purge files
    By fbby in forum AutoLISP, Visual LISP & DCL
    Replies: 18
    Last Post: 17th Jun 2008, 04:49 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts