Archive | March 2011

Cell Rotation – MicroStation VBA

Want the rotation of a cell about the Z-axis? This is how I get it using the Bentley object model. 

Public Function getCellRotation(oCell As CellElement) As Double
    Dim rAngle As Double
    getCellRotation = 0
    If (Matrix3dIsXYRotation(oCell.Rotation, rAngle)) Then
        getCellRotation = Degrees(rAngle)
        Debug.Print Trim(Str(Format(Degrees(rAngle), "#0.0")))
    End If
End Function

Matrix3dIsXYRotation passes the rotation matrix to the method and then sends back the angle (in radians) back to rAngle. The method returns true when there is a rotation about Z. If the cell is skewed or mirrored the method will return false. Be careful not to assume that if the function returns false that there is 0 rotation. You can make this assumption if your application controls the orientation of the cell and you can then predict that cells won’t be skewed or mirrored.