Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Redefine the Purge command to keep certain Layers

  1. #1
    100 Club
    Join Date
    2012-03
    Posts
    111
    Login to Give a bone
    0

    Default Redefine the Purge command to keep certain Layers

    I have a user who has a habit of purging layers out of our drawings. i don't want to discourage this because it it good to purge drawings. The problem is i need those layers to remain in the drawing. Could i write a program to redefine the purge command which would allow purging of everything except a list of layers that i want to remain in the drawing?

  2. #2
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    I approach this from another direction. Where our tools are expecting certain layers, I call a LISP function that constructs said layer first. That way it doesn't matter how clever they get, when the tool is used the correct layer is created if needed.

    But yes, you could redefine the PURGE command or add a command-reactor, probably having it rebuild layers after the core command is called.

  3. #3
    100 Club
    Join Date
    2012-03
    Posts
    111
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Quote Originally Posted by dgorsman View Post
    I approach this from another direction. Where our tools are expecting certain layers, I call a LISP function that constructs said layer first. That way it doesn't matter how clever they get, when the tool is used the correct layer is created if needed.

    But yes, you could redefine the PURGE command or add a command-reactor, probably having it rebuild layers after the core command is called.
    We have viewports set up to have certain layers turned off. When someone purges them out it screws everything up because even if you put the layer back in the viewport has it turned on by default & i have to reset it. I was hoping that i could redefine the purge command to be able to purge everything except a list of desired layers.

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Place the layers in a invisible block and insert said block into the drawing. This should keep the layers within the drawing as they would remain in use in the block definition.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    100 Club
    Join Date
    2012-03
    Posts
    111
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Quote Originally Posted by Opie View Post
    Place the layers in a invisible block and insert said block into the drawing. This should keep the layers within the drawing as they would remain in use in the block definition.
    what do you mean by an invisible block? I created a block with points on each layer but the user deleted it. I guess i didn't make it small enough

  6. #6
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Quote Originally Posted by sovby254640 View Post
    what do you mean by an invisible block? I created a block with points on each layer but the user deleted it. I guess i didn't make it small enough
    Save a copy of your drawing then delete and purge everything out of it except for layers. Then insert it back into your drawing as a block which contains all your layers. Since there is nothing to select it's somewhat harder to delete.

  7. #7
    Member
    Join Date
    2001-03
    Location
    ROMANIA
    Posts
    35
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Quote Originally Posted by sovby254640 View Post
    I have a user who has a habit of purging layers out of our drawings. i don't want to discourage this because it it good to purge drawings. The problem is i need those layers to remain in the drawing. Could i write a program to redefine the purge command which would allow purging of everything except a list of layers that i want to remain in the drawing?
    Try this:
    Code:
    ;;lay-keept=list of layers to be keept
    ;;Usage: (purge-layer (list "layer-keep1" "layer-keep2" etc.))
    
    (defun PURGE-LAYER (lay-keept / acobj lay-lst lay-pge pglayer)
    ;;Function to purge layer "name"
    	(defun pglayer (name)
    		(if	(vl-catch-all-error-p
    				(vl-catch-all-apply (quote vla-delete)
    					(list (vl-catch-all-apply (quote vla-item)(list (vla-get-layers acobj) name)))
    				)
    			)
    			nil
    			(princ (strcat "\nLayer " name " purged.")) ;;For test
    		)
    	)
    	(vl-load-com)
    	(setq acobj	(vla-get-activedocument (vlax-get-acad-object)))
    ;;lay-lst=list of all layers
    	(vlax-for lay (vla-get-layers acobj)
    		(setq lay-lst (cons (vla-get-name lay) lay-lst))
    	)
    ;;lay-pge=lay-lst "minus" lay-keept (list of layers allowed to be purged)
    	(foreach a lay-lst
    		(if	(not	(member a lay-keept))
    			(setq	lay-pge (cons a lay-pge))
    		)
    	)
    ;;purge allowed layers
    	(mapcar (function (lambda (x)(pglayer x))) lay-pge)
    ;;release vl-object	
    	(vlax-release-object acobj)
    	(princ)
    )

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Create a drawing with your desired layers. Do not add any visible objects within the drawing. Then insert this drawing into the drawing without exploding it. The user will not be able to select this block with the mouse, however, the block will be selectable through other means.

    Another suggestion is to add these layers to your title block drawing, and then redefine your inserted title block with the updated drawing.

    Other than those two suggestions, it becomes a training and management issue. Record the time it takes to correct the issue once the layers are removed and must be restored. Then estimate your time to fix the issue going forward. If you can document the time savings doing it the correct way along with training time, management can approve the fix and training and also help with the enforcement and backup afterward.

    Trying to program a labor management issue into AutoCAD is not the correct way to go, IMO.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #9
    100 Club
    Join Date
    2012-03
    Posts
    111
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Quote Originally Posted by Tom Beauford View Post
    Save a copy of your drawing then delete and purge everything out of it except for layers. Then insert it back into your drawing as a block which contains all your layers. Since there is nothing to select it's somewhat harder to delete.
    I'll try that. the block will still have an insertion point so they may still delete it but it's worth a shot

  10. #10
    100 Club
    Join Date
    2012-03
    Posts
    111
    Login to Give a bone
    0

    Default Re: Redefine the Purge command to keep certain Layers

    Thanks. So how would this work exactly? Would i run this in a drawing that has all the correct layers to get the list? Or do i have to add the layers that i want to keep into the routine & then redefine the purge command in said user's configuration?

Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 2018-07-20, 07:28 PM
  2. Purge: The existing purge command misses some stuff that could be purged from a file.
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2010-03-12, 12:28 PM
  3. Purge a layer without purge command
    By cadconcepts in forum AutoLISP
    Replies: 6
    Last Post: 2007-09-24, 06:11 PM
  4. Managing Layers, unable to purge / remove Layers
    By asenbauer in forum AutoCAD General
    Replies: 3
    Last Post: 2006-11-10, 09:50 AM
  5. Replies: 6
    Last Post: 2006-08-16, 07:55 AM

Posting Permissions

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