sifeng001 发表于 2010-8-12 04:30:00

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

<p>如题</p>
<p>&nbsp;各位大侠,代码怎么写?谢谢!</p>

sifeng001 发表于 2010-8-12 04:49:00

<font face="Verdana">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<br/>网上找到的,不知道怎么用。</font>

AirCD 发表于 2010-8-12 09:52:00

<p>建立选择集-用选择集过滤器根据图层名称选择指定图层上所有对象-删除对象-删除选择集</p>
<p>&nbsp;</p>
<p>实际上你找到的程序已经足够清楚了,不知道怎么用说明你大概还没有入门。建议你再看看这方面的资料。明经里有很多入门学习资料,足够满足你的需要。</p>
页: [1]
查看完整版本: 请问如何删除指定名字图层上的所有对象