Compressing design changes features definition?

Hello

I have strange behavior in Bentley Map SS2

I have changed gasMain example, to use different feature display name than name:


// Initialize "GasMain" root feature definition
xfmFeatureDef_new (&featureDef);xfmFeatureDef_setName (featureDef, L"GasMain");

xfmFeatureDef_setDescription (featureDef, L"Gas Main linear feature");

xfmFeatureDef_setDisplayName (featureDef, L"Gas Main dsp");

xfmFeatureDef_setCategoryName (featureDef, L"Gas");



And created features have attribute "Display name":

 

 <GasMain displayName = " Gas Main DSP "i =" 127b5e26-dbcd-41a3-a8f4-ae3a754472f4 ">

     <ID displayName="Id" type="STRING">1000</ID>
     ...
 </GasMain>
But after "compress design" operation it's changes:
 
<GasMain i="127b5e26-dbcd-41a3-a8f4-ae3a754472f4">
  <ID type="STRING">1000</ID>
  ...
     </GasMain>
   Why?
--- 
Regards
Daniel Gontarek
Parents
  • Daniel,

    Are you running the modified gasmain application in the geo_example_designer workspace? Attached is slightly modified gasmain.c source code that when tested in the Bentley Map V8i (SELECTseries 3) 08.11.09.107 commercial release seems to work as expected with the display name override persisted after a file compress.

    Could you please test the same modifications and let me know your findings?

    Regards,

    Jeff Bielefeld [Bentley]



  • Hello

    > Are you running the modified gasmain application in the geo_example_designer workspace?

    No, just in msgeo workspace. My goal is to create features and properties dynamically (based on own database model) - not using geospatial administrator.

    I tried Your code - the same effect after dgn compressing. In the geo_example_designer workspace this effect does not occur, but I think feature "GasMain" is defined in workspace.

    When I modified (in Your source)  feature name form "GasMain" to "MyGasMain" then problem occurs in geo_example_designer workspace as well (see attached file). 

    Regards.

    Daniel Gontarek

  • Daniel,

    I updated my local test case to work outside of the geo_example_designer workspace and have been able to replicate the reported behavior. I will file an issue to be resolved in the upcoming Bentley Map V8i (SELECTseries 4) release.

    Regards,

    Jeff Bielefeld [Bentley]



  • Hello again :)

    Now I'm trying this code on Bentley Map SS4 and the conclusion is as follows:
    1. In fact, now file compression do not change features definitions
    2. Unfortunately described behavior is after file closing and reopening (or restarting Bentley Map). Additionally I noticed, that INT or DOUBLE properties, are changed type to STRING :(

    Regards,

    Daniel Gontarek
  • Daniel,

    For 1 are you saying the previously reported issue involving file compress has been fixed? Also you should be aware that xfmFeatureDef_get/setKeepInSession functions are available which can be used to keep a feature definition in the session after feature instances of its definition are removed from the session. During compress, processing is similar to file close & file open processing so a dynamic feature definition would normally be removed from the session when its last instance is removed. During file open, the feature definition is inferred from the instance data and therefore loses a custom display name.

    For 2 unless you have an Bentley Geospatial Administrator defined schema or custom runtime code that defines your feature class definitions, including the data types of business properties Bentley Map will use STRING since the data type is not stored as part of the feature instance.

    I will investigate further if you could you provide a complete test case including source code that demonstrates what you are now observing?

    Regards,

    Jeff Bielefeld [Bentley]



  • Hello

    Unknown said:
    For 1 are you saying the previously reported issue involving file compress has been fixed?

    Yes, indeed.

    Unknown said:

     Also you should be aware that xfmFeatureDef_get/setKeepInSession functions are available which can be used to keep a feature definition in the session after feature instances of its definition are removed from the session. 

    Yes, I know that.

    I use:

    xfmFeatureDef_setKeepInSession(featureDef, TRUE);

    when create feature definition.

    Unknown said:

    During file open, the feature definition is inferred from the instance data and therefore loses a custom display name.

    ...

    unless you have an Bentley Geospatial Administrator defined schema or custom runtime code that defines your feature class definitions, including the data types of business properties Bentley Map will use STRING since the data type is not stored as part of the feature instance.

    That's too bad! Especially that property data type is not stored id DGN file.

    Unknown said:

    I will investigate further if you could you provide a complete test case including source code that demonstrates what you are now observing?

     

    OK, see attached file.

    /*----------------------------------------------------------------------+
    |                              
    |   C Library includes  
    |                              
    +----------------------------------------------------------------------*/
    #include <string.h>
    #include <stdlib.h>
    #include <assert.h>
    
    /*----------------------------------------------------------------------+
    |                              
    |   MicroStation MDL includes  
    |                              
    +----------------------------------------------------------------------*/
    #include <mdl.h>
    #include <dlogitem.h>
    #include <dlogids.h>
    #include <cmdlist.h>
    #include <dlmsys.fdf>
    #include <cexpr.h>
    #include <mstxtfil.h>
    #include <mselems.h>
    #include <msstrlst.h>
    #include <msstrngl.h>
    #include <colrname.h>
    #include <elementref.h>
    #include <tcb.h>
    #include <toolsubs.h>
    #include <msnativewindow.h>
    
    #include <mselemen.fdf>
    #include <mselmdsc.fdf>
    #include <mscexpr.fdf>
    #include <msrsrc.fdf>
    #include <mssystem.fdf>
    #include <msdialog.fdf>
    #include <ditemlib.fdf>
    #include <msdb.fdf>
    #include <msoutput.fdf>
    #include <mscnv.fdf>
    #include <mslocate.fdf>
    #include <msstate.fdf>
    #include <msmisc.fdf>
    #include <mscell.fdf>
    #include <leveltable.fdf>
    #include <msfile.fdf>
    #include <listmodel.fdf>
    #include <mscurrtr.fdf>
    #include <mswindow.fdf>
    #include <msscancrit.fdf>
    #include <msmodel.fdf>
    #include <mscntr.fdf>
    #include <msinput.fdf>
    #include <msraster.fdf>
    #include <mslinkge.fdf>
    #include <msview.fdf>
    #include <msselect.fdf>
    
    
    #include <xfmApi.fdf>
    #include <xfmFeatureMgr.fdf>
    #include <xfmLinearOp.fdf>
    #include <xfmCompCurveOp.fdf>
    #include <xfmMethodDef.fdf>
    #include <xfmOperationDef.fdf>
    #include <xfmSettings.fdf>
    #include <xfmInitialValueDef.fdf>
    #include <xfmInputValue.fdf>
    #include <xfmCompCurveParams.fdf>
    
    
    extern Tcb *tcb;
    Private RscFileHandle m_rFileH            = (RscFileHandle)NULL;         
    
    
    void createGasMainFeatureDef(void)
        {
        BoolInt        useDefaultFormView = FALSE;
        StatusInt      status;
        XfmFeatureDefP featureDef = NULL;
       // XfmFeatureDefP subFeatureDef = NULL;
        XfmFeatureDefP propertyDef = NULL;
        XfmSettingsP settings = NULL;
        XfmInitialValueDefP initialValueDef = NULL;
        XfmMethodGroupDefP methodGroup = NULL;
        XfmMethodDefP method = NULL;
        XfmOperationDefP operation = NULL;
    
        // Initialize "GasMain" root feature definition
        xfmFeatureDef_new (&featureDef);
        xfmFeatureDef_setName (featureDef, L"GM");
        xfmFeatureDef_setDescription (featureDef, L"Gas Main linear feature");
        xfmFeatureDef_setDisplayName (featureDef, L"Gas Main display name");
        xfmFeatureDef_setCategoryName (featureDef, L"Gas");
        xfmFeatureDef_setGisTypeName (featureDef, XFM_GISTYPENAME_LINEAR);
        xfmFeatureDef_setIsGeometryCollection (featureDef, FALSE);
        xfmFeatureDef_setGisTypeId (featureDef, XFMFEATUREGISTYPE_LineStringOrCurve);
        xfmFeatureDef_setMinOccurrences (featureDef, 1);
        xfmFeatureDef_setMaxOccurrences (featureDef, 1);
    
        // Add XfmPropertyDef's to root feature definition
        xfmFeatureDef_addProperty (&propertyDef, featureDef, L"ID", XFM_DATATYPE_STRING, 32);
        xfmPropertyDef_setDisplayName (propertyDef, L"Gas Main ID");
        xfmPropertyDef_setIsReadOnlyProperty (propertyDef, FALSE);
        xfmPropertyDef_setIsExternalProperty (propertyDef, FALSE);
        xfmPropertyDef_setLoadType (propertyDef, XFMPROPERTY_LOADTYPEID_Dgn);
        xfmPropertyDef_setPreferenceType (propertyDef, XFMPROPERTYPREFERENCETYPE_DesignFile);
        xfmPropertyDef_setFormatToDisplayTypeId (propertyDef, XFMFORMATVALUETYPE_String);
        xfmPropertyDef_setFormatToInternalTypeId (propertyDef, XFMFORMATVALUETYPE_String);
        //xfmInitialValueDef_create (&initialValueDef, XFMINITIALVALUEKEY_TYPEID_Placing, XFMINPUTVALUETYPE_Value, L"999");
        //xfmInitialValueDef_setSynchPreference (initialValueDef, TRUE);
        //xfmInitialValueDef_setIncrement (initialValueDef, XFMINCREMENTTYPEID_FirstNumeric, XFMINPUTVALUETYPE_Value, L"1");
        //xfmFeatureDef_addPropertyInitialValueRule (featureDef, propertyDef, XFM_INITIALVALUEKEY_Placing, initialValueDef);
        //xfmInitialValueDef_free (&initialValueDef);
        xfmPropertyDef_free (&propertyDef);
    
    
        xfmFeatureDef_addProperty (&propertyDef, featureDef, L"Size", XFM_DATATYPE_INT, 25);
        xfmPropertyDef_setDisplayName (propertyDef, L"Gas Main size");
        xfmPropertyDef_setIsReadOnlyProperty (propertyDef, FALSE);
        xfmPropertyDef_setIsExternalProperty (propertyDef, FALSE);
        xfmPropertyDef_setLoadType (propertyDef, XFMPROPERTY_LOADTYPEID_Dgn);
        xfmPropertyDef_setPreferenceType (propertyDef, XFMPROPERTYPREFERENCETYPE_Session);
        xfmPropertyDef_setFormatToDisplayTypeId (propertyDef, XFMFORMATVALUETYPE_Integer);
        xfmPropertyDef_setFormatToInternalTypeId (propertyDef, XFMFORMATVALUETYPE_Integer);
        xfmInitialValueDef_create (&initialValueDef, XFMINITIALVALUEKEY_TYPEID_Placing, XFMINPUTVALUETYPE_Value, L"2");
        xfmInitialValueDef_setSynchPreference (initialValueDef, TRUE);
        xfmFeatureDef_addPropertyInitialValueRule (featureDef, propertyDef, XFM_INITIALVALUEKEY_Placing, initialValueDef);
        xfmInitialValueDef_free (&initialValueDef);
        xfmPropertyDef_free (&propertyDef);
    
    
        // create XfmSettings for root feature definition
    	
        xfmSettings_create (&settings, XFMSETTINGS_TYPE_UNKNOWN /*XFMSETTINGS_TYPE_LINEAR*/);
        //xfmSettings_setColorNumber (settings, 1);
        //xfmSettings_setLevelName (settings, L"GasMain");
        //xfmSettings_setStyle (settings, 1);
        //xfmSettings_setWeight (settings, 1);
        //xfmSettings_setApplyDrawingScale (settings, TRUE);
        xfmFeatureDef_setSettings (featureDef, settings);
        xfmSettings_free (&settings);
    
    
        xfmFeatureDef_addGeometricProperties (featureDef);
       // xfmFeatureDef_addGeometricProperties (subFeatureDef);
    
        // Specify that this feature definition remains in the session list of FeatureDefs after feature instances of this definition are removed from the session
        xfmFeatureDef_setKeepInSession(featureDef, TRUE);
    
        // Add new feature definition to the session list of FeatureDefs so it is available for consumers
        status = xfmFeatureDefMgr_addRootFeatureDefToList (featureDef);
    
        // Add default command metadata including default Place & Edit methods with tool settings and dialog definitions.
        // I mainly want default Edit method plus the tool settings & dialog definitions created for me(but I could also create these myself).
        // Placement tool settings for a linear feature will contain CompCurve placement options. And my "PlaceGasMain" MDL operation will use a XfmCompCurveOpP.
        xfmFeatureDef_addDefaultCommandMetadata (featureDef);
    
        xfmFeatureDef_free (&featureDef);
    
    		xfmDialogMgr_refreshCommandManager();
    
        //xfmFeatureDef_free (&subFeatureDef);
        }
    
    
    int createXfmFeatureInstance(MSElementDescrP edP, char* objCode)
    {
        int i, size;
        MSWChar fcode[20];
        MSWChar pname[200];
        MSWChar pval[200];
        
        XfmFeatureDefP featureDef = NULL;
    	XfmPropertyDefP propertyDef = NULL;
    
        
    	//create xfm feature
        XfmFeatureP  feature=NULL;
        StatusInt   status;
    
        
        mdlCnv_convertMultibyteToUnicode(objCode, -1, fcode, 20);
    	xfmFeatureDef_create (&featureDef, fcode);
        
     
    
        status = xfmFeature_create(&feature,  fcode, NULL);
        if (SUCCESS != status)
            return status;
            
        //xfmFeature_setFeatureDef(feature, gasMainFeatureDef);
    
    //    xfmFeature_setFeatureAlias (feature, L"Gas Main 1");
    //    size = attrNames.size();
    //    for (i=0; i<size; i++)
    //    { 
    //        mdlCnv_convertMultibyteToUnicode(attrNames[i].c_str(), -1, pname, 200);
    //        mdlCnv_convertMultibyteToUnicode(attribs[attrNames[i]].c_str(), -1, pval, 200);
    //        status = xfmFeature_setNewProperty (feature,pname,pval);
    //        if (SUCCESS != status)
    //            return status;
    //
    //    }
         xfmFeature_initializeProperties (feature, L"placing");
    
         xfmFeatureDef_getPropertyDefByName(featureDef, &propertyDef, L"ID");
    	 xfmFeature_setPropertyByPropertyDef(feature, propertyDef, L"123abc", TRUE, TRUE, FALSE);
         xfmFeatureDef_getPropertyDefByName(featureDef, &propertyDef, L"Size");
    	 xfmFeature_setPropertyByPropertyDef(feature, propertyDef, L"25", TRUE, TRUE, FALSE);
    
         //xfmFeature_setProperty (feature, L"ID", L"123abc");
         //xfmFeature_setProperty (feature, L"Size", L"25");
    
                
        status = xfmFeature_setGeometry(feature, edP);
        if (SUCCESS != status)
        {
            printf("xfmFeature_setGeometry err:%d\n", status);
            return status;
        }
        
        
    //    status = xfmFeature_setGeometryType(feature,XFMFEATUREGEOMETRYTYPE_None);
    //    if (SUCCESS != status)
    //    {
    //        printf("xfmFeature_setGeometryType err:%d\n", status);
    //        return status;
    //    }    
    
        status = xfmFeature_write(feature, FALSE);
        if (SUCCESS != status)
        {
            printf("xfmFeature_write err:%d\n", status);
            return status;
        }
    
    
        status = xfmFeature_applyAttributeChanges(feature);
        if (SUCCESS != status)
            return status;
    
    	xfmFeature_applySchemaChanges(feature);
        xfmFeature_savePreferenceProperties (feature, XFM_INITIALVALUEKEY_Placing);
    
        status = xfmFeature_write(feature, FALSE);
        if (SUCCESS != status)
        {
            printf("xfmFeature_write err:%d\n", status);
            return status;
        }
    
        xfmFeature_free (&feature);
    
        return SUCCESS;
    
    }
    
    void testXfm()
    {
        DPoint3d pts[2];
        MSElementDescrP edP;
        MSElement el;
        //XfmFeatureP  feature=NULL;
        StatusInt   status;
        
        pts[0].x = 0; pts[0].y = 0; pts[0].z = 0;
        pts[1].x = 10; pts[1].y = 10; pts[1].z = 0;
    
        mdlLine_create(&el, NULL, pts);
        mdlElmdscr_new(&edP, NULL, &el);
        
        createXfmFeatureInstance(edP, "GM");
     
    }
    
    
    /*-------------------------------------------------------------------------------------*/
    /*-------------------------------------- M A I N --------------------------------------*/
    /*-------------------------------------------------------------------------------------*/
    
    DLLEXPORT int MdlMain(int argc,char *argv[])
    {
     static DialogHookInfo uHooks[] =
      {
       { 0, NULL }
      };
    
     //char *setP;
     int ret;
    
    
      mdlResource_openFile (&m_rFileH, NULL, 0);
    
      mdlDialog_hookPublish (sizeof (uHooks) / sizeof (DialogHookInfo), uHooks);
      //setP = mdlCExpression_initializeSet (VISIBILITY_DIALOG_BOX, 0, FALSE);
      //mdlDialog_publishComplexPtr (setP, "dlginfo", "m_dlgiP", &m_dlgiP);
            
    
       createGasMainFeatureDef();
       testXfm();
    
    
     return SUCCESS;
    }

  • Daniel,

    Attached is a modified version of your source in which I have used the XFM event system to define your feature class definitions during Bentley Map startup in such a way that the business property data types are as expected. For this to work you will need to add...

    MS_DGNAPPS < testxfm1

    ...to your workspace configuration to ensure your feature class definition is defined before Bentley Map infers the feature class based upon feature instances found in the design file.

    Please give this modified example a try with your existing design file data and let me know how it goes.

    testxfm1.zip

    Regards,

    Jeff Bielefeld [Bentley]



Reply
  • Daniel,

    Attached is a modified version of your source in which I have used the XFM event system to define your feature class definitions during Bentley Map startup in such a way that the business property data types are as expected. For this to work you will need to add...

    MS_DGNAPPS < testxfm1

    ...to your workspace configuration to ensure your feature class definition is defined before Bentley Map infers the feature class based upon feature instances found in the design file.

    Please give this modified example a try with your existing design file data and let me know how it goes.

    testxfm1.zip

    Regards,

    Jeff Bielefeld [Bentley]



Children
No Data