+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Forum Newbie
    Discipline
    Construction
    Using
    AutoCAD 2017
    Join Date
    Jan 2018
    Posts
    9

    Exclamation Lisp routine to clean up architects layout

    Registered forum members do not see this ad.

    Hi need help with a lisp routine to clean up architects drawings with the following.
    Unlock,Unfreeze & turn on all layers
    Burst
    Change all layers to bylayer
    Change all hatch’s to colour 254 and send to back
    Change all line weights to 0.18
    Change all to Colour 8
    Overkill
    Purge

  2. #2
    Quantum Mechanic
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,020

    Default

    A couple of questions

    The layers set to bylayer or all objects bylayer also ? If all by layer then set the line weight as part of change layer settings same as colour.

    Code:
    (defun allbylayer ( / x obj ssall)
    (setq ssall (ssget "x"))
    (repeat (setq x  (sslength ssall))
    (setq obj (vlax-ename->vla-object (ssname ssall (setq x (- x 1)))))
    (vlax-put-property obj "Linetype" "Bylayer") 
    (vlax-put-property obj "Lineweight" " -1")
    (vlax-put-property obj "Color" acbylayer)
    )
    )
    (allbylayer)
    (Alert "All objects now by layer")
    Code:
    ; open database
    (setq  doc (vla-get-activedocument  (vlax-get-acad-object))) 
    (setq lays (vla-get-Layers doc))
    (vlax-for lay lays
    (vla-put-color lay 8)
    (vla-put-lineweight lay 18) ; note 18 for metric =0.18 not tested on feet dwg must match a known size.
    )
    Burst has an alias when used with lisp will find. But this works

    Code:
    (while (setq ss (ssget "X" ))
    (sssetfirst nil ss)
    (C:Burst)
    )
    Purge use
    Code:
    (command "-purge" "all" "*" "n")
    Overkill help anyone
    A man who never made mistakes never made anything

  3. #3
    Forum Deity steven-g's Avatar
    Computer Details
    steven-g's Computer Details
    Operating System:
    Win 7
    Discipline
    Construction
    steven-g's Discipline Details
    Occupation
    Draughtsman
    Discipline
    Construction
    Details
    I work in the estimating department of a large building contractor.
    Using
    AutoCAD 2018
    Join Date
    May 2013
    Location
    An Englishman in Belgium
    Posts
    2,087

    Default

    I could do with a LISP that would work on the Architect's before they start on the drawings
    I've just been down graded from 2012LT to full Autocad 2017. I WANT LT BACK

  4. #4
    Forum Newbie
    Discipline
    Construction
    Using
    AutoCAD 2017
    Join Date
    Jan 2018
    Posts
    9

    Default

    Thanks BIGAL will give it a go & let you know how it goes!

  5. #5
    Forum Newbie
    Discipline
    Construction
    Using
    AutoCAD 2017
    Join Date
    Jan 2018
    Posts
    9

    Default

    BIGAL yes all layers changed to bylayer & all to colour 8, also any joy with the hatch to 254 & set to back?

  6. #6
    Forum Newbie
    Discipline
    Construction
    Using
    AutoCAD 2017
    Join Date
    Jan 2018
    Posts
    9

    Default

    Thanks BIGAL will give it a go & let you know how it goes!

    BIGAL yes all layers changed to bylayer & all to colour 8, also any joy with the hatch to 254 & set to back?

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

    Default

    THIS could be modified to do what you want.

  8. #8
    Forum Newbie
    Discipline
    Construction
    Using
    AutoCAD 2017
    Join Date
    Jan 2018
    Posts
    9

    Default

    Thanks could you send a lsp for me to try?

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

    Default

    Quote Originally Posted by ronjonp View Post
    THIS could be modified to do what you want.
    Here's a start:
    Unlock,Unfreeze & turn on all layers
    Burst
    Change all layers to bylayer Assume this is all objects to bylayer
    Change all hatch’s to colour 254 and send to back
    Change all line weights to 0.18
    Change all to Colour 8
    Overkill
    Purge

    Code:
    (defun c:drawingtobylayer
           ;;-----------------------------------------------------------------
           ;;
           ;;  Copyright © 2004 Michael Puckett. All Rights Reserved
           ;;
           ;;-----------------------------------------------------------------
           ;;
           ;;  Forces the entire drawing to "ByLayer" (even xrefs for
           ;;  the lifetime of the session or until an xref reload
           ;;  occurs).
           ;;
           ;;  Forces block definition child entities to layer "0".
           ;;
           ;;  Existing attributes are forced to the same layer the
           ;;  parent block reside on.
           ;;
           ;;  Nominally tested, let me know if you find anything wonky.
           ;;
           ;;  * Use at your own risk. Please test on a dummy dwg *
           ;;
           ;;-----------------------------------------------------------------
           (/ _unlockalllayers _locklayers _objecttolayerzero _objecttobylayer _documenttobylayer _main)
      ;; (idt_draworder (idt_ss->vla-list (ssget)) 'movetobottom)
      (defun _unlockalllayers (document / result)
        (vlax-for layer (vlax-get-property document 'layers)
          (cond ((eq :vlax-true (vlax-get-property layer 'lock))
    	     (vlax-put-property layer 'lock :vlax-false)
    	     (setq result (cons layer result))
    	    )
          )
          ;; RJP added: Change all layers to color 8, linewight to 18mm, thaw and turn on
          (foreach property	'((color . 8) (lineweight . 18) (freeze . 0) (layeron . -1))
    	(vl-catch-all-apply 'vlax-put (list layer (car property) (cdr property)))
          )
        )
        result
      )
      (vlax-ename->vla-object (tblobjname "layer" "0"))
      (defun _locklayers (layers) (foreach layer layers (vlax-put-property layer 'lock :vlax-true)))
      ;; (defun _objecttolayerzero (object) (vlax-put-property object 'layer "0"))
      (defun _objecttobylayer (obj / layer)
        ;; RJP added lineweight and transparency
        (foreach property '((color . 256)
    			(linetype . "ByLayer")
    			(lineweight . "ByLayer")
    			(transparency . "ByLayer")
    		       )
          (vl-catch-all-apply 'vlax-put (list obj (car property) (cdr property)))
        )
        (cond ((and	(eq "AcDbBlockReference" (vlax-get obj 'objectname))
    		(eq :vlax-true (vlax-get-property obj 'hasattributes))
    	   )
    	   (setq layer (vlax-get-property obj 'layer))
    	   (foreach child (vlax-invoke obj 'getattributes)
    	     (_objecttobylayer child)
    	     (vlax-put-property child 'layer layer)
    	   )
    	  )
    	  ;; RJP added hatch to color 254
    	  ((eq "AcDbHatch" (vlax-get obj 'objectname))
    	   (vl-catch-all-apply 'vla-put-color (list obj 254))
    	  )
        )
      )
      (defun _documenttobylayer (document)
        (vlax-for block (vlax-get-property document 'blocks)
          (if (eq :vlax-true (vlax-get-property block 'islayout))
    	(vlax-for object block (_objecttobylayer object))
    	(vlax-for object block (_objecttobylayer object))
          )
        )
      )
      (defun _main (/ document lockedlayers)
        (setq lockedlayers
    	   (_unlockalllayers
    	     (setq document (vlax-get-property (vlax-get-acad-object) 'activedocument))
    	   )
        )
        (_documenttobylayer document)
        ;; RJP leave layers unlocked
        ;; (_locklayers lockedlayers)
        (princ)
      )
      (_main)
    )

  10. #10
    Forum Newbie
    Discipline
    Construction
    Using
    AutoCAD 2017
    Join Date
    Jan 2018
    Posts
    9

    Default

    Registered forum members do not see this ad.

    Thanks Ronjonp will give this a try!

Similar Threads

  1. LISP | Clean Drawing | Explode and Purge
    By bluebravo in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 9th Aug 2017, 04:25 am
  2. Lisp routine for Rebar Layout
    By guyzen2004 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 20th May 2014, 06:08 am
  3. Lisp to clean files
    By NineteenHand in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 28th Jan 2014, 09:14 pm
  4. Lisp routine to print layout tabs and exclude model tab
    By jason_a in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 11th Nov 2010, 08:28 pm
  5. Architectural Clean Up Routine?
    By thedissident001 in forum CAD Management
    Replies: 6
    Last Post: 14th Sep 2010, 12:16 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