[CE VBA] Select shared cells on level


this is sample of code that I use in v8i for selecting shared cell elements on specified level. I'm trying to migrate code to CE but it seems that all shared cells from all levels are found. Workaround is to test level of every shared cell in file.
Is this some change in VBA or is this a bug? Also, I'm using Map PowerView so I'm not sure if same happens in Microstation.

Sub test()


        Dim ee As ElementEnumerator

        Dim esk As New ElementScanCriteria
        Set esk = New ElementScanCriteria
        esk.IncludeType msdElementTypeSharedCell
        esk.IncludeLevel ActiveDesignFile.Levels.Item("8_tocke")
        Set ee = ActiveModelReference.Scan(esk)

        Dim num As Long
        num = 0

        While ee.MoveNext
            If ee.Current.IsSharedCellElement Then
                num = num + 1
                Debug.Print ee.Current.AsSharedCellElement.level.Name
                ActiveModelReference.SelectElement ee.Current
            End If
        MsgBox num

End Sub

Parents Reply
  • The details tab shows the overrides.

    If you use the "Change Attributes" tool on a shared cell instance it will set the appropriate override flags.

    If I remember correctly, back in V7 when there were only 63 levels, a "level mask" was stored on the shared cell instance so that the scanner could efficiently check level criteria.

    Since the number of levels is no longer fixed, there is no longer a level mask stored on the element. As such shared cells are no longer rejected on level criteria by the scanner (unless I assume, but did not test, the level override is set).

    Shared cells have a further complication called "relative levels" where the effective level of the sc def components is determined by using the component's level id as an offset from the instance's level; this really only applies/works for shared cells that came from V7 where levels are 0-63.

    Since a shared cell can display components on different levels, it's not clear to me what "select shared cells on a particular level" means. If you have hundreds of instances of a particular shared cell, you certainly don't want to be reading the sc definition hundreds of times (once for each instance) in order to check the component levels.