Switching feature instance between different feature classes?

Hi all,

The use case for my problem is that I have one feature instance (e.g. one Linestring in feature class - Roads) that I want to change to another feature class (e.g. Linestring in feature class - Rivers). Some business properties between classes are identical (names, types, etc.) and in process of changing classes identical properties must be preserved (written in the destination class).

The question is what is the general workflow to do that?

Many thanks in advance for any information, advice, discussion,  VBA, MDL,... Slight smile

Kind regards,

Mladen

OCM Ultimate 10.17.01.29

  • In the XFM schema, you can add a promote method to create a new feature from an existing feature. However the properties from the source feature are not taken to the new feature. In that case, some custom code is required. I will check for an example VBA. I assume the source feature does not have subfeatures.

  • Thanks Kees,

    You're right. In most cases, the source feature does not have a sub-feature.

    Not sure if I can promote an existing feature. As far as I remember, promote works only for simple CAD elements... or I'm wrong?

    Please check out the VBA examples.

    Thanks in advance and kind regards.

    Mladen

    --

    Mladen

  • This one is a bit brutish but should be valid. Kees may well have a more elegant suggestion. 
    For this I used the new Feature Definitions functionality to make a copy of the geo_example 'Road' feature, named 'Not_Road'. 
    *My geo_example 'Road' also has an extra property 'N40_float25'.
     Using a copy for the example ensures that the property definitions are exactly the same. 
    I then changed the names of the properties of 'Not_Road' to distinguish from the former, prefixed with 'NR_'

    a) Export (File... , or via Map Manager) the original feature(s) to DGN with 'Create Item Types' engaged.  Exporting to the same model of the same DGN was handy for me in this case... 




    This results in non-XFM elements with properties as Item Types on a new level 'Exported Default Road'. 
    The level will be a criteria for a later step and thus should probably only be populated by the elements to be processed.
    Here, 2 native Road features (red) become 2 DGN elements (green) which I have offset from the originals:




    b) From the Ribbon Search [F4] "Item Types..." 
    The Item Types dialog should reveal your desired XFM properties, but now as Item Type properties.
    Values for the individual properties can be reviewed via MS properties dialog.  



    Note the hierarchy shown in the dialog, and associated names for step e:

    Item Type Library name
    Item Type name
    Property name


    Item Type Property values can be checked with the MS Properties / selection tool.

    e.g. I can confirm that 'ROAD1' was the name given to its progenitor:
     




    c)  If not open, launch Map's Inference Rules via ribbon search:   Inference...

    * Inference Rules will be set and saved for the workset then therefore potentially available to others. 

    You may use the  'Generate...rules' tool, though consider that this can result in extraneous rules to then delete.  
    So instead for this example, use the green + sign, 'Add..(rule)'

    For this example, the exported elements are on thier own level, and so this is a natural criteria: 


    d) Once created, set the rule's Feature to your desired feature.  In my case, 'Not_Road' .
    note the 'autopromote' option for later use. 



    e)  With the rule selected, expand 'Assign Values' 
    Add new values for each desired property of the feature [Not_Road] to be populated.

    Use the syntax: 
    this.GetItem("Library:ItemType").Property

    i.e. 
    this.GetItem("MapExportedFeature:Road").Name


    You should end up with something like these... 




    f) Save the Inference Rules (diskette) : 
    * if any features have been modified in the Feature Definitions section, these will be saved as well, potentially back to the XFM Schema XML file. 



    g) (Map) Analyze the inferred feature(s) to check results...  



    If that's all palatable, you can decide from there how to do the promotion etc.   :-) 


  • Thanks Nelson,

    your workflow is interesting and I'll try to explore it more detail. Just one question, when you talk about Inference Rules does it mean you define rules for Dynamic Feature Scoring (DFS)? Small XML file that you can create and edit in order to promote CAD elements to a GIS feature.

    Also, I have one more question unrelated to this topic. You use syntax like "this.GetItem("MapExportedFeature:Road").Name" to get a value of the Name property in Road feature. I need documentation of similar methods and their parameters so I can do some other things. For example, I want to read the rotation of an element and write it to XFM property in degrees (integer). I can't find documentation anywhere. Could you please help me and point me in the right direction of where to look.

    Thanks for everything.

    Kind regards,

    Mladen

    --

    Mladen

  • The Dynamic Feature Scoring (DFS) do still work, but the  Feature Inference Rules (FIR)  tool has a nice interface .
    Documentation is still delivered separately, see the PDF file Inference Rules documentation.pdf in the folder C:\Program Files\Bentley\Map CONNECT Edition\MapAdvanced\Documentation\.

    To add the textstring and rotation to a property of a text feature you can use the following expressions
     this.GetElement().TextString and this.GetElement().RotationAngle