TAG to XFM Feature prop. and SHP Export with attributes

Hi all,

 

Is there an easy way to convert dgn tag data to xfm feature properties asccosiated with a cell/sharded cell element and then doing an

export to a shp file. The tag data should get the attributes!

examaple dgn below

 

Test_rename_to_dgn.zip
  • Frank,

    Using VBA along with the Bentley Map XFT (XFM Feature Toolkit) library, you can convert tag data into XFM business properties. A pattern similar to the following could be applied.

    Function GetTagSet(strName As String) As TagSet
        Dim oTagSets As TagSets
       
        Set oTagSets = ActiveDesignFile.TagSets
        On Error Resume Next
        Set GetTagSet = oTagSets(strName)
        If GetTagSet Is Nothing Then Set GetTagSet = oTagSets.Add(strName)
    End Function
     
    Private Sub ILocateOpEvents_OnFinished(ByVal locateOp As xft.ILocateOp)
        Dim te As TagElement
        Dim oTagSet As TagSet
        Dim strTagSetName As String
        Dim strPropertyValue As String
       
        Dim oRegionElement As element
        Dim oFeature As feature
       
        Dim fe As FeatureEnumerator
        Set fe = locateOp.GetLocatedFeatures
           
        strTagSetName = "Counties"
        Set oTagSet = GetTagSet(strTagSetName)
       
        Do While fe.MoveNext
            Set oFeature = fe.Current
            Set oRegionElement = oFeature.GetRelatedRegionElement
           
            With oFeature
                If oRegionElement.HasAnyTags Then
                    Set te = oRegionElement.GetTag(oTagSet, "CountyName")
                    strPropertyValue = te.Value
                Else
                    strPropertyValue = "Unknown"
                End If
                .SetProperty "CountyName", strPropertyValue
                .ApplyAttributeChanges
                .Write (False)
            End With
        Loop
       
    End Sub

    For reference, attached is the tags2xfm.zip archive containing the above VBA code.

    After the tag data has been converted to XFM feature instances with corresponding business properties, the existing functionality of the Bentley Interoperability application can be used to export to SHP files.

    Regards,

    Jeff Bielefeld [Bentley]



    tags2xfm.zip
  • perfect Jeff, Thank you very much!

    Regards

    Frank

    since 1985: GIS, CAD, Engineering (Civil)  Senior Consultant : [Autodesk Civil 3D , Esri ArcGIS, VertiGIS: in previous days : Bentley MS V4 - V8i, GeoGraphics, Bentley Map V8i, InRoads,  HHK Geograf, IBr DAVID] :  Dev: [C, C++, .NET, Java, SQL, FORTRAN, UML]
    [direct quote by: http://en.wikipedia.org/wiki/Helmut_Schmidt]: "Wer Kritik übel nimmt, hat etwas zu verbergen"
    Wer Grammatik- und/oder Rechtschreibfehler findet, der darf sie behalten :-)

  • Hello.

    Is there a way to reverse this situation?

    My idea to to create tags based on xfm properties and attach to the element?

  • Hi Dawid,

    Unknown said:
    Is there a way to reverse this situation?

    I assume the solution is similar to the one provided by Jeff - small VBA application.

    Regards,

      Jan