- Function BlockRefMatrix(oBref As AcadBlockReference) As Variant
- Dim V, m(3, 3) As Double, M1, M2
- Dim j As Integer
- Dim x, y, Z, ins
- Dim Rot As Double
-
- Rot = oBref.Rotation
- Z = oBref.Normal
- V = GetOcsFromNormal(Z)
- x = V(0): y = V(1)
- ins = oBref.InsertionPoint
-
- M1 = RotZ(-Rot)
- For j = 0 To 2
- m(0, j) = x(j)
- m(1, j) = y(j)
- m(2, j) = Z(j)
- m(3, j) = ins(j)
- Next j
- m(3, 3) = 1
- If Rot = 0 Then
- BlockRefMatrix = m
- Else
- M2 = M4xM4(m, M1)
- BlockRefMatrix = M2
- End If
-
-
- End Function
- Function GetOcsFromNormal(N As Variant) As Variant
- 'Arbitrary Axis Algorithm in dxf help
- 'N is the normal vector.
- 'Wy is the world Y axis, which is always (0,1,0).
- 'Wz is the world Z axis, which is always (0,0,1).
- Dim Wy(2) As Double
- Dim Wz(2) As Double
- Dim Nx As Double, Ny As Double
- Dim Ax, Ay, Ocs(1) As Variant
-
- N = NormaliseVector(N)
- Wy(0) = 0: Wy(1) = 1: Wy(2) = 0
- Wz(0) = 0: Wz(1) = 0: Wz(2) = 1
- Nx = N(0): Ny = N(1)
- If (Abs(Nx) 3 Then
- For I = 0 To 3
- Debug.Print m(I, 0), m(I, 1), m(I, 2), m(I, 3), m(I, 4), m(I, 5), m(I, 6), m(I, 7)
- Next
- Else
- For I = 0 To 3
- Debug.Print m(I, 0), m(I, 1), m(I, 2), m(I, 3)
- Next
- End If
-
- End Sub