microstation sdk v8.11 - navigating programmatically through surface type 18

Dear all, good day.

I have a cell containing an element of type Surface(18).

I cannot understand how to navigate through its subelements.

Here it is visual basic code:

Public Sub NavigateThroughSurface(
   ByVal oApplication As Bentley.Interop.MicroStationDGN.Application
      Dim oEnumerator As Bentley.Interop.MicroStationDGN.ElementEnumerator = oApplication.ActiveModelReference.Scan      

      While oEnumerator.MoveNext
            Dim oElement = oEnumerator.Current
            If Not oElement.IsCellElement Then Continue While

            Dim oCellElement As Bentley.Interop.MicroStationDGN.CellElement = oElement.AsCellElement
            Dim lSubElementEnumerator As Bentley.Interop.MicroStationDGN.ElementEnumerator = oCellElement.GetSubElements
            While lSubElementEnumerator.MoveNext
                  Dim oSubElement = lSubElementEnumerator.Current
                  If oSubElement.Type = Bentley.Interop.MicroStationDGN.MsdElementType.Surface Then
                        'I do not find any "oSubElement.AsSurface" function...
                        'I have already done several tries, but without success:

                        '!!!!following statement throws exception:
                        Dim oBsplineSurfaceElement As Bentley.Interop.MicroStationDGN.BsplineSurfaceElement = oSubElement.AsBsplineSurfaceElement

                        '!!!!following statement throws exception too:
                        Dim lSolids As Bentley.Interop.MicroStationDGN.ElementEnumerator = oApplication.SmartSolid.ConvertToSmartSolidElement(oSubElement)

                        '?????????So how I can point to the surface itself and navigate through its subelements?????????
                  End If
            End While
      End While
End Sub

Thanks in advance.



Parents Reply
  • This code throws following error


    I simplified your DGN model (removed the cell) and VBA code...

    Option Explicit
    Public Sub Main()
        Dim id As DLong
        id = DLongFromLong(4090)
        Dim oHead As Element
        Set oHead = ActiveModelReference.GetElementByID(id)
        Debug.Assert Not oHead Is Nothing
        Analyse oHead
    End Sub
    Public Sub Analyse(ByVal oHead As Element)
        Dim oSolidComponents As ElementEnumerator
        ' Next line throws 'unknown error'
        Set oSolidComponents = SmartSolid.ConvertToSmartSolidElement(oHead)
        Debug.Assert Not oSolidComponents Is Nothing
        Do While oSolidComponents.MoveNext
            Debug.Print "Found component type " & _
    End Sub

    The code fails to convert the Type 18 to a SmartSolid in the line below my comment.

    The DGN file and the VBA code provide evidence for a Trouble Report (TR) or Service Request (SR) you can file with Bentley Systems.  Or possibly  or can help?

    Regards, Jon Summers
    LA Solutions

No Data