如何删除指定名字图层上的所有对象?
<p>RT</p><p>Public Sub delete()</p><p>Dim objLayer As AcadLayer<br/>Set objLayer = ThisDrawing.Layers("testlayer")</p><p>'这里用什么方法?</p><p></p><p>End Sub</p> <p>'删除图层上所有对象<br/>Function DelAllInLayer(ByVal LName As String)<br/> 'On Error Resume Next<br/> Dim SSet As AcadSelectionSet<br/> Set SSet = CreateSelectionSet("XXX")<br/> Dim Ft(0) As Integer, Fd(0)<br/> Ft(0) = 8: Fd(0) = LName<br/> SSet.Select acSelectionSetAll, , , Ft, Fd<br/> Dim E As AcadEntity<br/> 'MsgBox SSet.Count<br/> For Each E In SSet<br/> E.Delete<br/> Next<br/>End Function<br/>Function CreateSelectionSet(Optional SSetName As String = "mjtd") As AcadSelectionSet<br/> On Error Resume Next<br/> ThisDrawing.SelectionSets(SSetName).Delete<br/> Set CreateSelectionSet = ThisDrawing.SelectionSets.Add(SSetName)<br/>End Function</p><p></p><p>大侠看看,测试通过了</p><p> Ft(0) = 8 是何意?</p> <p>表示以"图层"组码为条件的过滤器,必须与图层名组合起来用.如果会LISP的话,可以用</p><p>(setq obj (entset (ssname (ssget) 0)))看来所选择对象相应的组码值.<br/></p> <p>1按图层过滤实体</p><p>2删除</p>
页:
[1]