VBA - accessing linkages

Hi,

I've got a problem accessing by VBA user attributes stored in Linkages in a dgn file.

Could somebody please have a look on below code and advice. The TransferBlock procedure for sure works fine because I tried it in different macro which shows the id of selected element (not feature).

The macro itself is a modified one from Bentley Map V8i Development and Product Customization Guide.

I attach the .mvba file and sample dgn.

clsLoadProperties:

Implements ILocateOpEvents


Private Sub ILocateOpEvents_OnCleanup()

End Sub

Private Const lIDGL      As Long = 889      ' ID of mine attribute
Private Sub ILocateOpEvents_OnFinished(ByVal locateOP As xft.ILocateOp)
    Dim fe As FeatureEnumerator
    Dim oElement As element
    Dim IDglReturn As Long
    Dim tDBlock()   As DataBlock
   
    Set fe = locateOP.GetLocatedFeatures
   
    Dim oFeature As feature
       
    Do While fe.MoveNext
        Set oFeature = fe.Current
       
        tDBlock = oFeature.Geometry.GetUserAttributeData(lIDGL)
        TransferBlock tDBlock(0), 0, IDglReturn, False
       
        With oFeature
            .SetProperty "id_gl", IDglReturn
            .ApplyAttributeChanges
            .Write (False)
        End With
    Loop
   
End Sub
       
Private Sub ILocateOpEvents_OnRejected(ByVal RejectedReasonType As xft.LocateOpRejectedReasonType, RejectedReason As String)

End Sub

Private Sub ILocateOpEvents_OnTerminate()

End Sub

Private Sub ILocateOpEvents_OnValidate(ByVal RootFeature As xft.IFeature, ByVal element As element, Point As Point3d, ByVal View As View, Accepted As Boolean, RejectReason As String)

End Sub


Private Sub TransferBlock(dBlk As DataBlock, lOffset As Long, value As Long, _
                            copyToDataBlock As Boolean)
    With dBlk
        .Offset = lOffset
        .CopyLong value, copyToDataBlock
    End With
End Sub

budynki_shape2.dgn
Parents
  • After looking at the provided budynki_shape2.dgn file, it is at first not apparent which elements contain your user attribute data. Using pure MicroStation scanning and elements (e.g. no XFT constructs) it seemed that .GetUserAttributeData(lIDGL) always returned a zero sized array. Can you please provide the .mvba that you previously referred to (e.g. tried it in different macro which shows the id of selected element) for review.

    Also please be aware that your Budynki feature class is a collection so while the business properties are on the root feature, the geometries will be contained in sub-features so you will need to check the .SubFeatureCount property of the root feature, then call the .GetSubFeature(index) method to get the sub-feature instance.

    Regards,

    Jeff Bielefeld [Bentley]



  • Thanks Jeff,

    Please find the macro attached. It works on selected elements.

    BTW, I use Bentley PowerMap v8i and if I check element information I can see linkages and the one I'm interested in is Type 0x379.

    I'm going to try calling the subfeature method.

    idgl_read.mvba
  • I have managed to make in run. I just added to the code those lines:

           Set Subfeature = oFeature.GetSubFeature(0)

           Set oElement = Subfeature.Geometry

    Thanks for the suggestion.

Reply Children