szuki 发表于 2009-10-26 09:19:00

如何删除指定名字图层上的所有对象?

<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>

szuki 发表于 2009-10-26 10:08:00

<p>'删除图层上所有对象<br/>Function DelAllInLayer(ByVal LName As String)<br/>&nbsp;&nbsp;&nbsp; 'On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; Dim SSet As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp; Set SSet = CreateSelectionSet("XXX")<br/>&nbsp;&nbsp;&nbsp; Dim Ft(0) As Integer, Fd(0)<br/>&nbsp;&nbsp;&nbsp; Ft(0) = 8: Fd(0) = LName<br/>&nbsp;&nbsp;&nbsp; SSet.Select acSelectionSetAll, , , Ft, Fd<br/>&nbsp;&nbsp;&nbsp; Dim E As AcadEntity<br/>&nbsp;&nbsp;&nbsp; 'MsgBox SSet.Count<br/>&nbsp;&nbsp;&nbsp; For Each E In SSet<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; E.Delete<br/>&nbsp;&nbsp;&nbsp; Next<br/>End Function<br/>Function CreateSelectionSet(Optional SSetName As String = "mjtd") As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; ThisDrawing.SelectionSets(SSetName).Delete<br/>&nbsp;&nbsp;&nbsp; Set CreateSelectionSet = ThisDrawing.SelectionSets.Add(SSetName)<br/>End Function</p><p></p><p>大侠看看,测试通过了</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ft(0) = 8 是何意?</p>

Saging 发表于 2009-10-26 19:38:00

<p>表示以"图层"组码为条件的过滤器,必须与图层名组合起来用.如果会LISP的话,可以用</p><p>(setq obj (entset (ssname (ssget) 0)))看来所选择对象相应的组码值.<br/></p>

mycad 发表于 2009-10-27 07:32:00

<p>1按图层过滤实体</p><p>2删除</p>
页: [1]
查看完整版本: 如何删除指定名字图层上的所有对象?