TheSwamp
Code Red => VB(A) => Topic started by: Arizona on June 07, 2006, 01:10:40 PM
-
I have some drawings that have both the old layering scheme and the new layering scheme contained within them. I am able to iterate through the lists of old name and move all the entities to the new layer. The problem I encountered is that even though the layer is now empty it will not delete using VBA. What am I missing? Any ideas?
P.S. This is version 2000i, so no layer translator.
-
How are you trying to delete them?
-
Layer defined as acadlayer
If Layer.Name = UCase(oldLayers(intNum)) Then
intCnt = intNum
strName1 = oldLayers(intCnt)
strNewName = newLayers(intCnt)
CreateNewLayer(strNewName) 'create new layer
'selection set stuff (I deleted this just for simplification)and change
For Each entObj In objSelSet
entObj.Layer = strNewName
entObj.Linetype = "BYLAYER"
intEntity = intEntity + 1
Next entObj
intCnt = intCnt + 1 'increments thru old layer names
Layer.Delete (strName1) '***This is the staement that is failing.
End If
The error message I'm getting is "Wrong number of arguments or invalid property assignment"
If I comment out the layer delete line the code runs through doing everything that I need it to do except purge the layer.
-
Does it work if you change the line to
Layer.Delete
-
You probably need to check each ent in each block as well.
But I have found layers are resistant to deletion after wblocking and cant find out why. I delete that RAK crap, but there may be a timing issue with that.
-
No, it didn't work that way either. But I just figured it out. I think I must have had a brain fart...
I wasn't cycling through the entities within the blocks...dumb, dumb, dumb!
I knew I should have gone home before I wore out my brain.
Thanks Bryco, you were right on!
-
Also, if the layer is set to frozen in a PS viewport, that will keep it from being deleted.
-
If you have blocks that have entities inside that are on a layer you want to purge, there is an alternative way of cleaning it out. It's a favorite trick of mine I dig up every time nothing else works.
A dxf file is a text file, and a text search and replace will work. Say you have a layer "A-Glass-Wall". You can search for "A-Glass-Wall" and replace with 0.
A dxf file for a good sized .dwg will have several million lines, so you can't use an in-memory editor like notepad. I have Unix utilities, so I use SED. But, if you don't have a streaming editor, you can write a small program to open the dxf file and loop through it replacing as you go.
If you are a real dxf expert, there are other editing tricks -- like replacing z coordinates with 0. As always, be careful. A global search and replace could create a monster that crashes when you try to load it. Make sure you save everything before you start.
-
Basic principle Creating and deletein a layer
Sub Test()
Dim Ac As AcadLayer
ThisDrawing.Layers.Add "TEST"
Set Ac = ThisDrawing.Layers("Test")
Ac.Delete
End Sub
If you can't wo0rk it out from here ask for details....good luck
-
Berend,
I think Anozira got it worked out.
-
Mmmmh overlooked the post.......sorry.
Anozira??? funny.
-
Jeff, You brought up a good point in that I wasn't checking the state of any of the layers.
Mike, What an interesting concept. At this point for me, it will be easier to iterate through the entities that make up each block.
Berend, Thanks anyway. Sometimes it's the simplest/most obvious things that catch me up. I usually have to go have a cup of coffee and then it hits me what I overlooked.
Bob, Was that one cup of coffee too many? Or are you still typing at the speed of sound?