Hello Hello
I am trying to create a 3D array that holds first which drawing view, second which dimensional annotation and third the (x, y, z) - coordinates for that annotation. I have to loop together this somehow since it is supposed to work for different drawings. I usually make 2D arrays like this (look down below) when I want, for example, an array with all the dimensional annotations and their coordinates from a predetermined view.
2D Array
Set swView = vViews(1)
vDimensions = swView.GetAnnotations
nrDim = swView.GetAnnotationCount
ReDim allDimPos(0 To nrDim) As Variant
If Not IsEmpty(vDimensions) Then
For k = LBound(vDimensions) To UBound(vDimensions)
Set currDim = vDimensions(k)
DimPos = currDim.GetPosition
d = Array(DimPos(0), DimPos(1), DimPos(2))
allDimPos(k) = d
For e = 0 To 2
'Debug.Print allDimPos(k)(e)
Next
Next
End If
But now I also have to include the view. To make a long story short I want this so I can make small changes to the position when running through configurations. The AlignDimensions(swAlignDimensionType_e.swAlignDimensionType_AutoArrange, 0.01) command does not produce the exact result I want. It still gets a little bit weird when I change configurations. I already have a script that aligns them good enough as long as I can get this array to work
This is what I have so far:
3D Array
For i = 0 To UBound(vViews) 'maybe (1 To UBound(vViews))
Set swView = vViews(i)
vDimensions = swView.GetAnnotations
nrDim = swView.GetAnnotationCount
ReDim allDimPos(0 To nrView, 0 To nrDim) As Variant 'Maybe ReDim allDimPos(nrView, nrDim) As Variant
allDimPos(i) = vDimensions
For k = LBound(vDimensions) To UBound(vDimensions)
ReDim allDimPos(0 To nrView, 0 To nrDim, 0 To 2) As Variant ' Maybe ReDim allDimPos(nrView, nrDim, 2) As Variant
Set currDim = vDimensions(k)
DimPos = currDim.GetPosition
d = Array(DimPos(0), DimPos(1), DimPos(2))
allDimPos(i)(k) = d
For e = 0 To 2
Debug.Print allDimPos(i)(k)(e)
Next
Next
Next
Usually get "Out of range error" at allDimPos(i) = vDimensions
Any help is goood because I got tunnel vision now. Appreciate all the help I get and all the help I have gotten in the past
SolidworksApi/macros