liuyang4740 发表于 2008-6-5 10:17:00

求助:改变偏移直线的特性

求助高手:我用vba的.offset命令偏移形成了一条直线,现在想把偏移后生成的直线改变土层,该怎么实现呢? 如Set offline = objsel.Offset(10),其后用offline.layer="0",为何没有实现土层改变呢?

fjfhgdwfn 发表于 2008-6-5 11:44:00

发程序上来

liuyang4740 发表于 2008-6-5 13:07:00

<p>&nbsp;Dim SsetObj As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp; Dim SsetName As String<br/>&nbsp;&nbsp;&nbsp; Dim objsel As AcadEntity<br/>&nbsp;&nbsp;&nbsp; Dim y(1 To 3) As Double<br/>&nbsp;&nbsp;&nbsp; Dim y_st(1 To 3) As String<br/>&nbsp;&nbsp;&nbsp; Dim offline As AcadLine</p><p>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; SsetName = "au100"<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; For i = 0 To ThisDrawing.SelectionSets.Count - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set SsetObj = ThisDrawing.SelectionSets.Item(i)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If SsetObj.Name = "au100" Then SsetObj.Delete<br/>&nbsp;&nbsp;&nbsp; Next i<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set SsetObj = ThisDrawing.SelectionSets.Add(SsetName)<br/>&nbsp;&nbsp; '让用户在屏幕上选择要加入选择集的图元<br/>&nbsp;&nbsp;&nbsp; SsetObj.SelectOnScreen<br/>&nbsp;&nbsp;&nbsp;&nbsp; '遍历选择集合<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = 1<br/>&nbsp;&nbsp; For Each objsel In SsetObj<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set offline = objsel.Offset(10)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; offline.Layer = "0"</p><p>&nbsp;&nbsp; next</p><p>end sub</p>

fjfhgdwfn 发表于 2008-6-5 20:29:00

<p>Dim Offline As Variant&nbsp; </p><p></p><p>For Each objsel In SsetObj<br/>&nbsp;&nbsp; offline = objsel.Offset(10)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; offline(0).Layer = "0"</p><p>&nbsp;&nbsp; next</p><p>offline 是一个数组。</p><p></p><p>可以看offset的帮助。</p>

liuyang4740 发表于 2008-6-7 13:20:00

<p>多谢楼上的,我按照楼上的改了还是没有更改土层啊?</p>

fjfhgdwfn 发表于 2008-6-7 22:29:00

<p>&nbsp; On Error Resume Next<br/>先把这个去了。你肯定哪出错了。</p><p>我试了的。是可以的。</p>

sailorcwx 发表于 2008-6-8 12:33:00

<p>Dim offline As AcadLine改成Dim offline As Variant</p><p>offline.Layer = "0"改成offline(0).Layer = "0"</p><p></p>

liuyang4740 发表于 2008-6-8 18:52:00

<p>问题解决了,非常感谢楼上的!!!</p>
页: [1]
查看完整版本: 求助:改变偏移直线的特性