帮忙看看这个程序,好像是a数组和b数组的数据类型不对。我编的这个宏是想实现存放在input中的线(弧线,直线等) 按照一定的方向排列(原先的线是乱序排列的,创造线时顺序不一样)。具体思想是先找到每条线的中点,根据中点的坐标值进行冒泡排序,并且这些线也会重新排列。其中总是出现错误错误是
object doesn't support this property or method :“a” “b“
Sub stripelinearray()
Dim a(500) ' a(500) lines b(500) middle point c(500)array lines
Dim b(500)
Dim c(500)
Dim i, j
Dim temp
Dim temp1, temp2
Dim tab7(3)
'=====================================
'=====================================
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridBodies1 = part1.HybridBodies
Set OBlines = hybridBodies1.Item("input") 'input document
Set OBmiddle = hybridBodies1.Item("middle")
Set OBarranged = hybridBodies1.Item("arranged lines") 'output document
For i = 1 To OBlines.HybridShapes.Count
Set a(i) = OBlines.HybridShapes.Item(i) '====load curves
Set b(i) = OBmiddle.HybridShapes.Item(i) '====load curves' middle points
Set pointInit1 = b(i)
pointInit1.GetCoordinates (tab7)
c(i) = tab7(2) '====lines middle point's coordinate x value
'============make a relation between lines and point's x coordinate in structure
Next
For i = 0 To OBmiddle.HybridShapes.Count - 2
For j = i + 1 To OBmiddle.HybridShapes.Count - 1
If c(j - 1) < c(j) Then
temp = c(j - 1)
c(j - 1) = c(j) '====sort lines' direction by x value
c(j) = temp
temp1 = b(j - 1)
b(j - 1) = b(j) '====sort lines' direction by x value
b(j) = temp1
temp2 = a(j - 1)
a(j - 1) = a(j) '====sort lines' direction by x value
a(j) = temp2
End If
Next
Next
Set partDocument1 = CATIA.ActiveDocument
Set selection1 = partDocument1.Selection
selection1.Clear
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
For i = 1 To OBlines.HybridShapes.Count '==============COPY AND PASTE
Set hybridShapeCurveExpliciti = a(i - 1)
selection1.Add hybridShapeCurveExpliciti
Next
selection1.Copy
Set partDocument1 = CATIA.ActiveDocument
Set selection2 = partDocument1.Selection
selection2.Clear
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("arranged lines")