求助!!
Sub SelectSp()<BR> On Error Resume Next<BR> Dim SSpline As AcadSelectionSet<BR> Dim SLine As AcadSelectionSet<BR> Dim fd(0) As Integer, ft(0)<BR> Dim Pline As AcadLine<BR> Dim s, t<BR> <BR> Dim pInsertPnt()<BR> Set SSpline = ThisDrawing.SelectionSets.Add("Spline")<BR> fd(0) = "Spline": ft(0) = 0<BR> SSpline.Select acSelectionSetAll, , , ft, fd<BR> Set SLine = ThisDrawing.SelectionSets.Add("Line")<BR> fd(0) = "Line": ft(0) = 0<BR> SLine.Select acSelectionSetAll, , , ft, fd<BR> For Each Pline In SLine<BR> For s = 0 To SSpline.Count - 1<BR> pInsertPnt = Pline.IntersectWith(SSpline(s), acExtendNone)<BR> Next s<BR> Next Pline<BR> Dim i As Integer, j As Integer, k As Integer<BR> Dim str As String<BR> If VarType(pInsertPnt) <> vbEmpty Then<BR> For i = LBound(pInsertPnt) To UBound(pInsertPnt)<BR> str = "Intersection Point[" & k & "] is: " & pInsertPnt(j) & "," & pInsertPnt(j + 1) & "," & pInsertPnt(j + 2)<BR> MsgBox str, , "IntersectWith Example"<BR> str = ""<BR> i = i + 2<BR> j = j + 3<BR> k = k + 1<BR> Next<BR> End If<BR>End Sub<BR> <BR><FONT color=#ff0000> 上图是运行上面一段代码后的结果,我想求直线与曲线的交点并输出。结果……</FONT>
<FONT color=#ff0000>请问大侠们用insertwith求得的交点是怎么储存在数组里的啊??帮助文档里的例子为什么是i=i+2,,j=j+3。我想把求得的交点按照x坐标进行排序再输出应该怎么办呢?</FONT> Intersection方法只能求对象与对象间的交点,而不是选择集与选择集间的交点。 本帖最后由 作者 于 2004-10-20 21:37:16 编辑
Sub SelectSp()
On Error Resume Next
Dim SSpline As AcadSelectionSet
Dim SLine As AcadSelectionSet
Dim ft(0) As Integer, fd(0)
Dim Pline As AcadLine
Dim s, t
Dim i As Integer, j As Integer, k As Integer
Dim str As String
Dim pInsertPnt
ThisDrawing.SelectionSets("Spline").Delete
ThisDrawing.SelectionSets("Line").Delete
Set SSpline = ThisDrawing.SelectionSets.Add("Spline")
ft(0) = 0: fd(0) = "Spline"
SSpline.Select acSelectionSetAll, , , ft, fd
Set SLine = ThisDrawing.SelectionSets.Add("Line")
ft(0) = 0: fd(0) = "Line"
SLine.Select acSelectionSetAll, , , ft, fd
For Each Pline In SLine
For s = 0 To SSpline.Count - 1
pInsertPnt = Pline.IntersectWith(SSpline(s), acExtendNone)
j = 0
For i = 0 To UBound(pInsertPnt)
str = "Intersection Point[" & k & "] is: " & pInsertPnt(j) & "," & pInsertPnt(j + 1) & "," & pInsertPnt(j + 2)
MsgBox str, , "IntersectWith Example"
str = ""
i = i + 2
j = j + 3
k = k + 1
Next
Next s
Next Pline
End Sub
谢谢两位老大的教导啦!
都是小弟我看明经出的《AutoCAD VBA 开发精彩实例教程》不够认真,这两天发现好多问题在书上都有例子了。十分感谢版主们热心回答我的问题!!!
呵呵,小弟我还有个问题.????
For i = 0 To UBound(pInsertPnt)<BR> str = "Intersection Point[" & k & "] is: " & pInsertPnt(j) & "," & pInsertPnt(j + 1) & "," & pInsertPnt(j + 2)<BR> MsgBox str, , "IntersectWith Example"<BR> str = ""<BR> i = i + 2
j = j + 3<BR> k = k + 1<BR> Next<BR>上面那段代码中为什么i = i + 2, i的取值范围不是由交点的个数决定的吗,每个交点由x y z三个坐标啊。还请可爱的版主同志回答一下小弟这个菜菜的问题,谢谢啦
页:
[1]