yycah 发表于 2005-10-18 09:27:00

求助!怎样将某个图层的所有图形放到一个选择集中?

本帖最后由 作者 于 2005-10-18 10:02:50 编辑 <br /><br /> <P>求助!怎样将某个图层的所有图形放到一个选择集中?lisp&nbsp;&nbsp;&nbsp; vba都要,万分感谢!</P>
<P>要实现这样的功能:将某图层的所有图形历篇,将每一类完全一样的图形COPY到工作区的另一个地方,之后还要对COPY出来的图形进行编辑,可以吗?万分感谢!!</P>

雪山飞狐_lzh 发表于 2005-10-18 21:15:00

<P>Function GetSel(Optional Name = "TLSSEL") As AcadSelectionSet<BR>On Error Resume Next<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.SelectionSets(Name).Delete<BR>&nbsp;&nbsp;&nbsp; Set GetSel = ThisDrawing.SelectionSets.Add(Name)<BR>End Function</P>
<P>Sub t()<BR>Dim ss As AcadSelectionSet<BR>Set ss = GetSel()</P>
<P>Dim ft(0) As Integer, fd(0)<BR>LayerName = "0"<BR>ft(0) = 8: fd(0) = LayerName</P>
<P>ss.Select acSelectionSetAll, , , ft, fd</P>
<P>End Sub</P>
<P>&nbsp;</P>

yycah 发表于 2005-10-19 12:46:00

<P>谢谢版主!我回家试一下!</P>

yycah 发表于 2005-10-23 14:51:00

<P>Function GetSel(Optional Name = "TLSSEL") As AcadSelectionSet<BR>On Error Resume Next<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.SelectionSets(Name).Delete<BR>&nbsp;&nbsp;&nbsp; Set GetSel = ThisDrawing.SelectionSets.Add(Name)<BR>End Function<BR>Sub jh()<BR>Dim p1(0 To 2) As Double<BR>Dim ss As AcadSelectionSet<BR>Set ss = GetSel()<BR>'ss.SelectOnScreen<BR>'For j = 0 To ss.Count - 1<BR>&nbsp;&nbsp; ' ms = ss.Item(j).ObjectID &amp; Chr(10) + ms<BR>'Next<BR>'MsgBox ms</P>
<P>Dim ft(0) As Integer, fd(0)<BR>LayerName = "c1"<BR>ft(0) = 8: fd(0) = LayerName<BR>ss.Select acSelectionSetAll, , , ft, fd<BR>&nbsp;&nbsp;&nbsp; For i = 0 To ss.Count - 1<BR>&nbsp;&nbsp;&nbsp; If i &gt; ss.Count - 1 Then GoTo pp:<BR>&nbsp;&nbsp;&nbsp; gs = 0<BR>&nbsp;&nbsp;&nbsp; MsgBox ss.Item(i).ObjectName &amp; Chr(10) &amp; ss.Item(i).ObjectID &amp; Chr(10) &amp; i<BR>&nbsp;&nbsp;&nbsp; ss.Item(i).GetBoundingBox mind, maxd<BR>&nbsp;&nbsp;&nbsp; a = maxd(0) - mind(0)<BR>&nbsp;&nbsp;&nbsp; b = maxd(1) - mind(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For k = 1 To ss.Count - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If k &gt; ss.Count - 1 Then GoTo kk:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ss.Item(k).GetBoundingBox mindt, maxdt<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at = maxdt(0) - mindt(0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bt = maxdt(1) - mindt(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If at = a And bt = b And ss.Item(k).ObjectID &lt;&gt; ss.Item(i).ObjectID Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'MsgBox ss.Item(k).ObjectID &amp; Chr(10) &amp; k<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ss.Item(k).Delete<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gs = gs + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ss = GetSel()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LayerName = "c1"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ft(0) = 8: fd(0) = LayerName<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ss.Select acSelectionSetAll, , , ft, fd<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k = k - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>kk: Dim sm As AcadMText<BR>&nbsp;&nbsp;&nbsp; pb = ThisDrawing.Utility.GetPoint(, "选择基点:" &amp; Chr(10))<BR>&nbsp;&nbsp;&nbsp; ss.Item(i).Move mind, pb<BR>&nbsp;&nbsp;&nbsp; ss.Item(i).GetBoundingBox minda, maxda<BR>&nbsp;&nbsp;&nbsp; p1(0) = minda(O): p1(1) = minda(1) - 5: p1(2) = minda(2)<BR>&nbsp;&nbsp;&nbsp; w = a / 5<BR>&nbsp;&nbsp;&nbsp; Set sm = ThisDrawing.ModelSpace.AddMText(p1, w, gs + 1)<BR>&nbsp;&nbsp;&nbsp; sm.Layer = "t1"<BR>Next<BR>pp:</P>
<P>End Sub</P>

<P>不行呀!救救呀!</P>

srshix 发表于 2005-11-10 20:11:00

请问怎样选择整个图层内的所有对象呢?

srshix 发表于 2005-11-10 20:14:00

<P>还有版主的代码有点看不懂:</P>
<P>&nbsp;&nbsp; ThisDrawing.SelectionSets(Name).Delete<BR>&nbsp;&nbsp;&nbsp; Set GetSel = ThisDrawing.SelectionSets.Add(Name)<BR>为什么要删除后添加呢</P>

雪山飞狐_lzh 发表于 2005-11-10 22:06:00

<P>你在For循环里为什么要改变ss的值?</P>
<P>你要达到什么效果?</P>
页: [1]
查看完整版本: 求助!怎样将某个图层的所有图形放到一个选择集中?