luckyliya 发表于 2006-3-20 13:14:00

(求助)请帮我看一下这段代码为什么不行?

<P>本人初学VBA,请各位多多指教,这段代码为什么不行</P>
<P>找到实体层中各直线的交点,并把它们打印出来.</P>
<P>&nbsp;Sub findpoint()<BR>Dim newlayer As AcadLayer<BR>Dim intpoints As Variant<BR>Set newlayer = ThisDrawing.Layers("实体层")<BR>ThisDrawing.ActiveLayer = newlayer<BR>For Each lineobj1 In ThisDrawing.ModelSpace<BR>&nbsp; For Each lineobj2 In ThisDrawing.ModelSpace<BR>&nbsp;&nbsp;&nbsp; If lineobj1.ObjectID &lt;&gt; lineobj2.ObjectID Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intpoints = lineobj1.IntersectWith(lineobj2.acExtendNone)<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp; Next<BR>Next<BR>Dim i As Integer, j As Integer, k As Integer<BR>Dim str As String</P>
<P>If VarType(intpoints) &lt;&gt; vbEmpty Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = LBound(intpoints) To UBound(intpoints)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str = "Intersection Point[" &amp; k &amp; "] is: " &amp; intpoints(j) &amp; "," &amp; intpoints(j + 1) &amp; "," &amp; intpoints(j + 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox str, , "IntersectWith Example"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str = ""<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j = j + 3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k = k + 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp; End If<BR>End Sub<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 谢谢大家了</P>

tnt1095 发表于 2006-3-20 14:21:00

<P>问题出在这里:</P>
<P>If lineobj1.ObjectID &lt;&gt; lineobj2.ObjectID Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intpoints = lineobj1.IntersectWith(lineobj2.acExtendNone)<BR>&nbsp;&nbsp;&nbsp; End If<BR>lineobj2.acExtendNone,该是“lineobj2,acExtendNone”而不是一个“.”</P>

luckyliya 发表于 2006-3-20 14:36:00

<P>太感谢你了,都是我马虎造成的,给大家添麻烦了</P>
页: [1]
查看完整版本: (求助)请帮我看一下这段代码为什么不行?