PDA

View Full Version : Layer State Deletion


martyk
2004-12-30, 02:56 PM
Some time back, I asked for and received a lisp routine to delete Layer Filters. I now have another request. Is there a routine out there that will delete Layer States? I know they can be deleted one at a time, but I am hoping for something that will delete all of them. Maybe even allow the user to select which ones they want deleted. Thanks!

Mike.Perry
2004-12-30, 03:34 PM
Hi

Below comes from a couple of old LISP Guild posts...

-----Original Message-----
From: owner-guild-lisp@augi.com [mailto:owner-guild-lisp@augi.com]On
Behalf Of Peter Jamtgaard
Sent: 14 June 2002 12:38
To: guild-lisp@augi.com
Subject: RE: [LISP] Deleting random stuff

As for layerstates and filters

This is the example for layerstates, it is almost identical to the similar program for layerfilters. Just change the word acad_layerstates to acad_layerfilters.

Peter Jamtgaard

(defun C:DEL_LSTATE (/ EXTDOBJ LSTATEOBJ)
(setq EXTDOBJ (vla-GetExtensionDictionary
(vla-Get-Layers
(vla-Get-ActiveDocument
(vlax-Get-Acad-Object)
)
)
)
)
(if (> (vla-get-count EXTDOBJ) 0)
(progn
(setq LSTATSOBJ (vla-item EXTDOBJ
"ACAD_LAYERSTATES"
)

)
(vlax-for FOR-ITEM LSTATSOBJ
(vla-delete FOR-ITEM)
)
)
)
(princ)
)************

-----Original Message-----
From: owner-guild-lisp@augi.com [mailto:owner-guild-lisp@augi.com]On
Behalf Of R. Robert Bell
Sent: 14 June 2002 14:27
To: guild-lisp@augi.com
Subject: Re: [LISP] Deleting random stuff

Peter,

Here is a version that I wrote a while back. This one has the advantage of trapping the error if layer states don't exist.

(defun C:LayerStatesDelete ()
(vl-load-com)
(vl-Catch-All-Apply
'(lambda ()
(vla-Remove (vla-GetExtensionDictionary
(vla-Get-Layers (vla-Get-ActiveDocument
(vlax-Get-Acad-Object))))
"ACAD_LAYERSTATES")))
(princ "\nAll layer states have been deleted.")
(princ))R. Robert Bell

************

For LMan States (Express Tools) take a look at...

ID: TS44806 - Error: Object reference missing: AcDbLayerTableRecord, to AcDbPlaceHolde (http://usa.autodesk.com/getdoc/id=TS44806)

Have a good one, Mike

martyk
2004-12-30, 07:50 PM
Thanks for the responses. However, I think I am missing something. After I have run the lisp routines, both options, my layer states still exist. Even the lisp routine "DeleteLayerStates" tells me all layer states have been deleted. However, when I go back up into "Express\Layer Manager" all of my layer states are still listed. Just for your information, I'm trying to run this routine in Acad 2002, if that has any bearing. We are looking to switch to 2005 very soon, but until then. Please help! Thanks!

RobertB
2004-12-30, 08:42 PM
Are these non-vanilla drawings? ADT/LDD can cause this behavior with filters so it might with states too.

Glenndp
2004-12-30, 08:54 PM
He stated he is using the express tools layer manager for the layerstates. Are these stored the same way as the ones in the standard layer manager?

RobertB
2004-12-30, 09:24 PM
He stated he is using the express tools layer manager for the layerstates. Are these stored the same way as the ones in the standard layer manager?
Oops, I missed that in his 2nd post.

Martin, the Express Tools Layer Manager was superceded in A2k2 (?) by the core product. I would advise to stop using the Express Tools version.

The Express Tools version stored state info in each layer's XData. So the utils you tried had no effect.

RobertB
2004-12-30, 09:35 PM
Here is some code to kill those AcET Layer States:
Sub StripAcETLMan()
Dim wipeType(0) As Integer
Dim wipeData(0) As Variant
wipeType(0) = 1001: wipeData(0) = "RAK"
Dim aLayer As AcadLayer
For Each aLayer In ThisDrawing.Layers
aLayer.SetXData wipeType, wipeData
Next aLayer
End Sub

Mike.Perry
2004-12-30, 11:31 PM
However, when I go back up into "Express\Layer Manager" all of my layer states are still listed. Hi

You need to refer to the Technical Document I gave in my original post OR use the code Robert kindly supplied in above post.

Have a good one, Mike

msjca
2005-01-11, 08:57 PM
Does Peter Jamtgaard's (defun C:DEL_LSTATE (/ EXTDOBJ LSTATEOBJ) delete all layer states? I want to delete invalid layer states -- ones which have settings for layers not present in the dwg, please. I guess it would be nice if something could provide a report indicating how many layers in a layer state are not found. I regret I don't yet understand the code provided. (I not trying to be lazy about figuring it out and how to get what I have described but if it already exists, it be helpful, please.)