Terry1021 发表于 2006-8-21 22:31:00

有关图层内元素复制的问题

<P>我想把图层中的元素复制到新建的 "Temp" 层上</P>
<P>但我的代码实现的效果却是把图层中的元素剪切到"Temp"层.</P>
<P>大家能帮我看看问题在哪儿吗?</P>
<P>Dim layerObj As AcadLayer<BR>&nbsp;&nbsp; Set layerObj = ThisDrawing.Layers.Add("Temp")<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; Dim pStr As String</P>
<P>&nbsp;&nbsp; Dim sset As AcadSelectionSet<BR>&nbsp;&nbsp; Set sset = ThisDrawing.SelectionSets.Add("SS1")</P>
<P>&nbsp;&nbsp; sset.SelectOnScreen</P>
<P>&nbsp;&nbsp; Dim entry As AcadEntity</P>
<P>&nbsp;&nbsp; For Each entry In sset<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.layer = "Temp"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry.Update<BR>&nbsp;&nbsp; Next</P>
<P>&nbsp;&nbsp; sset.Delete</P>

wyj7485 发表于 2006-8-22 08:57:00

<P>dim CopyObj as object</P>
<P>For Each entry In sset</P>
<P>set CopyObj&nbsp;=entry&nbsp;.copy<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CopyObj&nbsp;.layer = "Temp"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CopyObj&nbsp;.Update<BR>&nbsp;&nbsp; Next</P>

Terry1021 发表于 2006-8-22 19:06:00

<P>谢谢这位大哥</P>
<P>本人初学 VBA ,不胜感激</P>
页: [1]
查看完整版本: 有关图层内元素复制的问题