变为当前层失败,有没有方法
<P>请教大师:</P><P>本人编了一个将所选层变为当前层的Vba程式,</P>
<P>可是失败,请了解的朋友指点</P>
<P>Public Sub dq()<BR>Dim ssetobj1 As AcadSelectionSet<BR>Dim icount1 As Integer<BR>icount1 = ThisDrawing.SelectionSets.Count<BR>While (icount1 > 0)<BR> If ThisDrawing.SelectionSets.Item(icount1 - 1).Name = "yuan" Then<BR> ThisDrawing.SelectionSets.Item(icount1 - 1).Delete<BR> End If<BR> icount1 = icount1 - 1<BR> Wend<BR> Set ssetobj1 = ThisDrawing.SelectionSets.Add("yuan")<BR> ThisDrawing.Utility.Prompt "please select object"<BR> ssetobj1.SelectOnScreen<BR> Dim i1 As Integer<BR> Dim selobj1 As AcadEntity<BR> On Error Resume Next<BR> Set selobj1 = ssetobj1.Item(i1)<BR><BR> Dim str As String<BR> str = selobj1.Layer<BR> ThisDrawing.ActiveLayer = str<BR></P> <P>大哥,ThisDrawing.ActiveLayer是个对象,str是个字符串,看你最后的三行,应该改为:</P>
<P> Dim str As String<BR> str = selobj1.layer<BR> Dim layer As AcadLayer<BR> For Each layer In ThisDrawing.Layers<BR> If layer.Name = str Then ThisDrawing.ActiveLayer = layer<BR> Next</P>
<P> </P> ThisDrawing.ActiveLayer =ThisDrawing.Layers( str ) <A name=6949><FONT color=#990000><B>lzh741206</B></FONT></A>斑竹,你的经验很丰富啊,我总是想不起来用简单的方法。。。谢啦!以后改进! 谢谢各位大师,你们太利害了
页:
[1]