My own add feature function

Hello,

I have defined, in Geospatial  Administrator, a linestring feature. But I want to create/draw it in a special way. I have written my own MDL command supporting drawing orthogonal buildings process. And now I'd like to combine standard feature creating tool with this command. In other words, the result I need is to have a command that creates a feature drawn using my MDL function. Where should I call this command?

Myzzard

Parents Reply Children
  • Hello Myzzard,

    Here is a code snippet that I added to the GasMain MDL example to automatically annotate the feature after placement if the AutoAttribute system property is TRUE.  This system property setting is available in the Feature pulldown menu.

    Public void placeGasMain_secondPoint

    (

    Dpoint3d *pntP,

    int view

    )

    {

    BoolInt autoAttribute = FALSE;

    generateGasMain (pntP, view);

     

    xfmFeature_write (gasMainFeature, FALSE);

    xfmFeature_savePreferenceProperties (gasMainFeature, L"placing");

    // If auto-attributing after placement is on then activate Annotate method (if it exists)

    xfmPropMgr_getPropertyBoolValue (&autoAttribute, L"SysProps/AutoAttribute", FALSE);

    if (autoAttribute)

    {

    BoolInt annotateMethodExists=FALSE;

    xfmCmdMgr_methodExists (&annotateMethodExists, L"GasMain", L"Annotate");

    if (!annotateMethodExists)

    {

    placeGasMain_done();

    return;

    }

    // --- set group to edit as required by annotate logic ---

    xfmFeature_setFeatureGroup (gasMainFeature, L"edit");

    // Since not opening edit box, initialize "editing" properties in case required for annotation

    xfmFeature_initializeProperties (gasMainFeature, L"editing");

    // --- set locatedFeatureRootName which is required by edit logic ---

    xfmCmdMgr_setProperty (L"locatedFeatureRootName", L"GasMain");

    xfmCmdMgr_setProperty (L"locatedFeatureGroupName", L"edit");

    // --- start up the feature's Annotate Method ---

    xfmCmdMgr_activateMethod (L"GasMain", L"Annotate");

    return;

    }

    placeGasMain_done();

    }

     

    Also of interest is this snippet from the XFM Standard Operations Library which will open the edit dialog box before annotation if system properties are set to do so.

    /*

    If "SysProps/AutoAttribute" == TRUE

    If "SysProps/OpenEditDialogDuringAutoAttribution" == FALSE

    start annotation placement (run "Annotate" method)

    Else

    open Edit box (run "Edit" method)

    Else

    restart current XFM command (placement)

    */

     

    xfmPropMgr_getPropertyBoolValue (&autoAttribute, L"SysProps/AutoAttribute", FALSE);

    if (autoAttribute)

    {

    MSWChar* featureName=NULL;

    MSWChar* featureAlias=NULL;

    xfmCmdMgr_getProperty (&featureName, L"placementFeature");

    xfmCmdMgr_getProperty (&featureAlias, L"placementAlias");

    BoolInt annotateMethodExists=FALSE;

    xfmCmdMgr_methodExists (&annotateMethodExists, featureName, L"Annotate");

    BoolInt openEditBox = TRUE;

    xfmPropMgr_getPropertyBoolValue (&openEditBox, L"SysProps/OpenEditDialogDuringAutoAttribution", FALSE);

    if (openEditBox)

    {

    // --- check for Edit and Annotate Methods for current feature ---

    BoolInt editMethodExists=FALSE;

    xfmCmdMgr_methodExists (&editMethodExists, featureName, L"Edit");

    if (annotateMethodExists && editMethodExists)

    {

    XfmFeatureP editFeature=NULL;

    if (SUCCESS == xfmFeatureMgr_loadFeatureFromList (&editFeature, placementGroup, featureAlias))

    {

    // --- set group to edit as required by edit logic ---

    xfmFeature_setFeatureGroup (editFeature, L"edit");

    // --- set locatedFeatureRootName which is required by edit logic ---

    xfmCmdMgr_setProperty (L"locatedFeatureRootName", featureAlias);

    xfmCmdMgr_setProperty (L"locatedFeatureGroupName", L"edit");

    // --- start up the feature's Edit Method ---

    xfmCmdMgr_activateMethod (featureName, L"Edit");

    if (NULL != featureOps)

    dlmSystem_mdlFree (featureOps);

    if (NULL != placementGroup)

    dlmSystem_mdlFree (placementGroup);

    if (NULL != featureName)

    dlmSystem_mdlFree (featureName);

    if (NULL != featureAlias)

    dlmSystem_mdlFree (featureAlias);

    if (NULL != editFeature)

    xfmFeature_free (&editFeature);

    return;

    }

    if (NULL != editFeature)

    xfmFeature_free (&editFeature);

    }

    }

    else

    {

    if (annotateMethodExists)

    {

    XfmFeatureP editFeature=NULL;

    if (SUCCESS == xfmFeatureMgr_loadFeatureFromList (&editFeature, placementGroup, featureAlias))

    {

    // --- set group to edit as required by annotate logic ---

    xfmFeature_setFeatureGroup (editFeature, L"edit");

    // Since not opening edit box, initialize "editing" properties in case required for annotation

    xfmFeature_initializeProperties (editFeature, L"editing");

    // --- set locatedFeatureRootName which is required by edit logic ---

    xfmCmdMgr_setProperty (L"locatedFeatureRootName", featureAlias);

    xfmCmdMgr_setProperty (L"locatedFeatureGroupName", L"edit");

    // --- start up the feature's Annotate Method ---

    xfmCmdMgr_activateMethod (featureName, L"Annotate");

    if (NULL != featureOps)

    dlmSystem_mdlFree (featureOps);

    if (NULL != placementGroup)

    dlmSystem_mdlFree (placementGroup);

    if (NULL != featureName)

    dlmSystem_mdlFree (featureName);

    if (NULL != featureAlias)

    dlmSystem_mdlFree (featureAlias);

    if (NULL != editFeature)

    xfmFeature_free (&editFeature);

    return;

    }

    if (NULL != editFeature)

    xfmFeature_free (&editFeature);

    }

    }

    if (NULL != featureName)

    dlmSystem_mdlFree (featureName);

    if (NULL != featureAlias)

    dlmSystem_mdlFree (featureAlias);

    }

     

    Regards,

    Chris


    This is a test