get cell angle MVBA

MicroStation Connect update 16

MVBA

I am trying to get cell rotation in the active dgn. When I move through the file and gather data, if a cell has a rotation of 12.25, ee.Current.AsSharedCellElement.Rotation.RowZ.Z does not report it correctly or am I missing something? The value comes back as 1. Here is a snippet of the code I am exploring with:

Sub GetData()
    Dim myElem As element
    Dim ee As ElementEnumerator
    Dim myFilter As New ElementScanCriteria
    Dim myCollection As New Collection
    Dim RangeBox As Range3d

'set filter criteria - set what to look for
'This module is set to only look at cells excuding all other element types
    myFilter.ExcludeAllTypes
    myFilter.IncludeType msdElementTypeSharedCell  'Shared Cells
    myFilter.IncludeType msdElementTypeCellHeader   'Normal Cells
    
    'Start scanning file
    Set ee = ActiveModelReference.GraphicalElementCache.Scan(myFilter)
    Do While ee.MoveNext
        'Shared Cells
        If ee.Current.Type = msdElementTypeSharedCell Then
            RangeBox = ee.Current.AsSharedCellElement.Range
            CellName = ee.Current.AsSharedCellElement.Name
            'CellName = LCase(ee.Current.AsSharedCellElement.Name) 'CASE SENSITIVE
            CellType = ee.Current.AsSharedCellElement.Type
            CellScale = ee.Current.AsSharedCellElement.Scale.X & ", " & ee.Current.AsSharedCellElement.Scale.Y
            CellScaleX = ee.Current.AsSharedCellElement.Scale.X
            CellScaleY = ee.Current.AsSharedCellElement.Scale.Y
            CellScaleZ = ee.Current.AsSharedCellElement.Scale.Z
            CellOrigin = ee.Current.AsSharedCellElement.Origin.X & ", " & ee.Current.AsSharedCellElement.Origin.Y & ", " & ee.Current.AsSharedCellElement.Origin.Z
            CellOriginX = ee.Current.AsSharedCellElement.Origin.X
            CellOriginY = ee.Current.AsSharedCellElement.Origin.Y
            CellOriginZ = ee.Current.AsSharedCellElement.Origin.Z
            CellRotation = ee.Current.AsSharedCellElement.Rotation.RowZ.Z
        End If
    Loop
End Sub

Parents Reply Children
  • Hi Mark,

    I bypassed the entire matrix confusion

    It's good to know you find solution.

    But, vector algebra and matrix operations (rotation and transformation matrices) is core mandatory knowledge for any CAD and GIS development. In fact, many operations cannot be implemented using them.

    The matrix method requires knowledge on interpreting and then converting the data correctly.

    In fact, it is incorrect conclusion.

    Matrices can be used without interpreting values directly, and as I wrote in previous answer, it is even not recommended. VBA API offers plenty of methods that do it, so e.g. when you need to check whether element is rotated around Z only, and what angle is it, you need to call proper methods only, which does not require to know that rotation around Z is represented by what cells in matrix and whether it is sin() or cos() value.

    The PropertyHandler bypasses all of that.

    Yes, but the is pretty high cost you have to pay:

    It is much slower and also specific limitations exist (even though not effective in the discussed case). There is a reason why PropertyHandler is recommended as "last chance" approach, when required functionality does not exists in API (e.g. to read EC data and element attributes, not published in API).

    With regards,

      Jan