<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Delete all objects on a layer in VBA in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298580#M69094</link>
    <description>Ent works fast &amp;amp; easy. if  I'm writing sometime where I'm going to access a &lt;BR /&gt;
huge drawing I'll use a selectionset or if it's a routine I plan to add to &lt;BR /&gt;
my companies routines I would add the selectionset but if it's sometime fast &lt;BR /&gt;
down and dirty I'll use ent&lt;BR /&gt;
John Coon&lt;BR /&gt;
&lt;BR /&gt;
" Nemorarius"  wrote in message news:5144326@discussion.autodesk.com...&lt;BR /&gt;
Why not use a selectionset and then call the erase method on it?&lt;BR /&gt;
&lt;BR /&gt;
"John Coon" &lt;JDCNH&gt; wrote in message&lt;BR /&gt;
news:5144339@discussion.autodesk.com...&lt;BR /&gt;
Sachin,&lt;BR /&gt;
This might get you going&lt;BR /&gt;
&lt;BR /&gt;
Public Sub eraselayer()&lt;BR /&gt;
    Dim ent As AcadEntity&lt;BR /&gt;
    For Each ent In ThisDrawing.ModelSpace&lt;BR /&gt;
        If ent.Layer = "1ST-PBASE" Then ' put layer name to delete here...&lt;BR /&gt;
            ent.Delete&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
john coon&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;SACHINPISE&gt; wrote in message news:5143966@discussion.autodesk.com...&lt;BR /&gt;
Hey Joe&lt;BR /&gt;
&lt;BR /&gt;
Why you have taken this:&lt;BR /&gt;
Public Const LAYER = 8 'by layer&lt;BR /&gt;
&lt;BR /&gt;
what is 8??&lt;BR /&gt;
&lt;BR /&gt;
Sachin&lt;/SACHINPISE&gt;&lt;/JDCNH&gt;</description>
    <pubDate>Tue, 18 Apr 2006 10:39:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-04-18T10:39:47Z</dc:date>
    <item>
      <title>Delete all objects on a layer in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298574#M69088</link>
      <description>HI All,&lt;BR /&gt;
&lt;BR /&gt;
I've seen the example code in the Developer help.&lt;BR /&gt;
&lt;BR /&gt;
The example is as follows:&lt;BR /&gt;
&lt;BR /&gt;
for each obj in ThisDrawing.Groups&lt;BR /&gt;
    obj.Delete&lt;BR /&gt;
next obj&lt;BR /&gt;
&lt;BR /&gt;
How can I apply this to all objects on a layer AND how should I declare obj&lt;BR /&gt;
&lt;BR /&gt;
DIm obj as ??</description>
      <pubDate>Fri, 01 Nov 2002 06:37:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298574#M69088</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-11-01T06:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all objects on a layer in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298575#M69089</link>
      <description>if obj.layer  = "your layer name" then&lt;BR /&gt;
    obj.delete&lt;BR /&gt;
&lt;BR /&gt;
you can use AcadObject or AcadEntity - not sure which is best&lt;BR /&gt;
&lt;BR /&gt;
"Mike Rand" &lt;MIKE.RAND&gt; wrote in message&lt;BR /&gt;
news:2ADA336FBC8C45DEC28F45752A59D3BA@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; HI All,&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; I've seen the example code in the Developer help.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; The example is as follows:&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; for each obj in ThisDrawing.Groups&lt;BR /&gt;
&amp;gt;     obj.Delete&lt;BR /&gt;
&amp;gt; next obj&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; How can I apply this to all objects on a layer AND how should I declare&lt;BR /&gt;
obj&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; DIm obj as ??&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/MIKE.RAND&gt;</description>
      <pubDate>Fri, 01 Nov 2002 06:39:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298575#M69089</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-11-01T06:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all objects on a layer in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298576#M69090</link>
      <description>Mike,&lt;BR /&gt;
&lt;BR /&gt;
Here is how you would do that.&lt;BR /&gt;
&lt;BR /&gt;
Joe&lt;BR /&gt;
--&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
Public Const LAYER = 8          'by layer&lt;BR /&gt;
&lt;BR /&gt;
Public Function CreateSelectionSet(SelectionSet As AcadSelectionSet, _&lt;BR /&gt;
                                   FilterCode As Integer, _&lt;BR /&gt;
                                   FilterValue As String) As Boolean&lt;BR /&gt;
Dim iFilterCode(0) As Integer&lt;BR /&gt;
Dim vFilterValue(0) As Variant&lt;BR /&gt;
  &lt;BR /&gt;
  iFilterCode(0) = FilterCode&lt;BR /&gt;
  vFilterValue(0) = FilterValue&lt;BR /&gt;
  &lt;BR /&gt;
  SelectionSet.Select acSelectionSetAll, , , iFilterCode, vFilterValue&lt;BR /&gt;
  'SelectionSet.SelectOnScreen intFilterCode, varFilterValue&lt;BR /&gt;
  &lt;BR /&gt;
  If SelectionSet.Count Then&lt;BR /&gt;
    CreateSelectionSet = True&lt;BR /&gt;
  End If&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Public Sub DeleteEntitiesOnLayer(LayerName As String)&lt;BR /&gt;
Dim objSS As AcadSelectionSet&lt;BR /&gt;
Dim oEntity As AcadEntity&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  'delete any previous selection set&lt;BR /&gt;
  ThisDrawing.SelectionSets("Entities").Delete&lt;BR /&gt;
  'create our new selection set&lt;BR /&gt;
  Set objSS = ThisDrawing.SelectionSets.Add("Entities")&lt;BR /&gt;
  'get the actual entities for the selection set&lt;BR /&gt;
  CreateSelectionSet objSS, LAYER, LayerName&lt;BR /&gt;
  'iterate through selection set delete each entity&lt;BR /&gt;
  For Each oEntity In objSS&lt;BR /&gt;
    oEntity.Delete&lt;BR /&gt;
  Next oEntity&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Public Sub Test()&lt;BR /&gt;
  DeleteEntitiesOnLayer "... Your Layer Name Goes Here ..."&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Nov 2002 07:40:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298576#M69090</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2002-11-01T07:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all objects on a layer in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298577#M69091</link>
      <description>Hey Joe&lt;BR /&gt;
&lt;BR /&gt;
Why you have taken this:&lt;BR /&gt;
Public Const LAYER = 8 'by layer&lt;BR /&gt;
&lt;BR /&gt;
what is 8??&lt;BR /&gt;
&lt;BR /&gt;
Sachin</description>
      <pubDate>Sat, 15 Apr 2006 12:19:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298577#M69091</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-04-15T12:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all objects on a layer in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298578#M69092</link>
      <description>Sachin,&lt;BR /&gt;
This might get you going&lt;BR /&gt;
&lt;BR /&gt;
Public Sub eraselayer()&lt;BR /&gt;
    Dim ent As AcadEntity&lt;BR /&gt;
    For Each ent In ThisDrawing.ModelSpace&lt;BR /&gt;
        If ent.Layer = "1ST-PBASE" Then ' put layer name to delete here...&lt;BR /&gt;
            ent.Delete&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
john coon&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;SACHINPISE&gt; wrote in message news:5143966@discussion.autodesk.com...&lt;BR /&gt;
Hey Joe&lt;BR /&gt;
&lt;BR /&gt;
Why you have taken this:&lt;BR /&gt;
Public Const LAYER = 8 'by layer&lt;BR /&gt;
&lt;BR /&gt;
what is 8??&lt;BR /&gt;
&lt;BR /&gt;
Sachin&lt;/SACHINPISE&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:34:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298578#M69092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-04-17T10:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all objects on a layer in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298579#M69093</link>
      <description>Why not use a selectionset and then call the erase method on it?&lt;BR /&gt;
&lt;BR /&gt;
"John Coon" &lt;JDCNH&gt; wrote in message&lt;BR /&gt;
news:5144339@discussion.autodesk.com...&lt;BR /&gt;
Sachin,&lt;BR /&gt;
This might get you going&lt;BR /&gt;
&lt;BR /&gt;
Public Sub eraselayer()&lt;BR /&gt;
    Dim ent As AcadEntity&lt;BR /&gt;
    For Each ent In ThisDrawing.ModelSpace&lt;BR /&gt;
        If ent.Layer = "1ST-PBASE" Then ' put layer name to delete here...&lt;BR /&gt;
            ent.Delete&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
john coon&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;SACHINPISE&gt; wrote in message news:5143966@discussion.autodesk.com...&lt;BR /&gt;
Hey Joe&lt;BR /&gt;
&lt;BR /&gt;
Why you have taken this:&lt;BR /&gt;
Public Const LAYER = 8 'by layer&lt;BR /&gt;
&lt;BR /&gt;
what is 8??&lt;BR /&gt;
&lt;BR /&gt;
Sachin&lt;/SACHINPISE&gt;&lt;/JDCNH&gt;</description>
      <pubDate>Mon, 17 Apr 2006 10:39:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298579#M69093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-04-17T10:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all objects on a layer in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298580#M69094</link>
      <description>Ent works fast &amp;amp; easy. if  I'm writing sometime where I'm going to access a &lt;BR /&gt;
huge drawing I'll use a selectionset or if it's a routine I plan to add to &lt;BR /&gt;
my companies routines I would add the selectionset but if it's sometime fast &lt;BR /&gt;
down and dirty I'll use ent&lt;BR /&gt;
John Coon&lt;BR /&gt;
&lt;BR /&gt;
" Nemorarius"  wrote in message news:5144326@discussion.autodesk.com...&lt;BR /&gt;
Why not use a selectionset and then call the erase method on it?&lt;BR /&gt;
&lt;BR /&gt;
"John Coon" &lt;JDCNH&gt; wrote in message&lt;BR /&gt;
news:5144339@discussion.autodesk.com...&lt;BR /&gt;
Sachin,&lt;BR /&gt;
This might get you going&lt;BR /&gt;
&lt;BR /&gt;
Public Sub eraselayer()&lt;BR /&gt;
    Dim ent As AcadEntity&lt;BR /&gt;
    For Each ent In ThisDrawing.ModelSpace&lt;BR /&gt;
        If ent.Layer = "1ST-PBASE" Then ' put layer name to delete here...&lt;BR /&gt;
            ent.Delete&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
john coon&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;SACHINPISE&gt; wrote in message news:5143966@discussion.autodesk.com...&lt;BR /&gt;
Hey Joe&lt;BR /&gt;
&lt;BR /&gt;
Why you have taken this:&lt;BR /&gt;
Public Const LAYER = 8 'by layer&lt;BR /&gt;
&lt;BR /&gt;
what is 8??&lt;BR /&gt;
&lt;BR /&gt;
Sachin&lt;/SACHINPISE&gt;&lt;/JDCNH&gt;</description>
      <pubDate>Tue, 18 Apr 2006 10:39:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/delete-all-objects-on-a-layer-in-vba/m-p/298580#M69094</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-04-18T10:39:47Z</dc:date>
    </item>
  </channel>
</rss>

