我想做的是 Autodesk Inventor。我正在编写一个程序,它遍历草图中的一堆线。它收集连接线组并将它们放在一个集合中。然后它使这些集合的集合被处理。
我试图通过将这些行添加到临时集合中,然后将此临时集合添加到循环集合中来做到这一点,这样我就不必为每个循环生成未知数量的集合。但是,一旦我使用 Clear 方法重置临时集合,它就会删除我刚刚推送到循环集合中的信息。有没有办法使循环集合中的信息独立于临时集合中的信息?
如您所见,问题是我永远不知道将连接多少条线路,因此我永远不知道会有多少子集合。
这是我的代码。
Dim oLoopColl As New Collection
Dim oSubColl As ObjectCollection
Set oSubColl = ThisApplication.TransientObjects.CreateObjectCollection
For j = 1 To oSLColl.Count
oSubColl.Add (oSLColl.Item(j))
'Check for last item to see if it is part of the first
If j = oSLColl.Count Then
If oSLColl.Item(j).EndSketchPoint Is oSLColl.Item(1).StartSketchPoint Then
MsgBox ("Last SL is part of first coll!")
oLoopColl.Item(1).Add (oSLColl.Item(j))
oSubColl.Clear
Else
Call oLoopColl.Add(oSubColl, CStr(j))
End If
Else
If Not oSLColl.Item(j).EndSketchPoint Is oSLColl.Item(j + 1).StartSketchPoint Then
Call oLoopColl.Add(oSubColl, CStr(j))
oSubColl.Clear
End If
End If
Next
oSubColl.Clear
Set oSubColl = Nothing