Dynamic where clause in Interoperability?

Is it possible to define the Where clause in Interoperability at run-time using VBA or mdl? I need to filter data on eq. job_id or user_id. I know that I can save orax files but this only works for setting that does not change over time.

Regards,

Krister

Parents
  • I can dig up some .NET code that has this in it. Not sure about MDL. Would that suffice ?

     

  • Anything is appreciated but in this project it's mainly  mdl and vba.

    /Krister

    Owner consultant at Surell Consulting AB

  • Hers is a function that does the querying of a feature with a where clause. Should be generic enough to use with any feature/where clause since these are passed as parameters. I hope this helps.

    using Bentley.Geospatial.Explorer;
    using Bentley.Geospatial.Utility;
    using Bentley.EngineeringContent.Storage;
    using Bentley.EngineeringContent.Storage.Xfm;
    using GDI = Bentley.Geospatial.DataInterchange;

    private static void ExecuteQueryOnOpenOracleSource(string featureName, string whereClause)
                {
                //get the open import criteria
                //you will need a reference to the GeoDataInterchange assembly, and a have line like this:
                //using Bentley.Geospatial.DataInterchange;

                Bentley.Geospatial.Utility.IImportCriteria criteria = GDI.GeoDataInterchangeAddIn.Instance.MasterFileImport;

                if (null == criteria)
                    return;

                //setup spatial criteria
                criteria.Geometry = null;

                //you can use the SpatialArea property with All, Fence, or View.
                //Don't use Selection, that's for export
                criteria.SpatialArea = SpatialArea.All;

                //get the storage import
                Bentley.Geospatial.Utility.IStorageImportCriteria storageImp = criteria.StorageImports[0] as Bentley.Geospatial.Utility.IStorageImportCriteria;

                if (null == storageImp)
                {
                    MessageBox.Show("No active Oracle Spatial connection");
                    return;
                }

                //deselect all features
                foreach (Bentley.Geospatial.Utility.IClassImportCriteria currentClassImp in storageImp.ClassImports.Values)
                    currentClassImp.Selected = false;

                //select the feature(s) you want to query
                Bentley.Geospatial.Utility.IClassImportCriteria classImp = storageImp.ClassImports[featureName] as Bentley.Geospatial.Utility.IClassImportCriteria;

                if (classImp != null)
                    classImp.Selected = true;

                //add a where clause for the selected features
                if (whereClause != null && whereClause.Length > 0)
                    classImp.WhereClause = whereClause;

                //execute the query
                Bentley.Geospatial.DataInterchange.GeoDataInterchangeAddIn.Instance.ImportOrExport(criteria, null, true, true);
                }

     

  • Thanks! (i think)

    This probably means that I finally have to dive into developing in VC. I guess I could pack this into an dll that could be called from VBA?

    If use VC Express, which version should I use and what would the best documentation to get me started? I'm use to developing mdl, C and vba but have never found the time to get me started on VC development.

    /Krister

    Owner consultant at Surell Consulting AB

  • Krister,

    I've posted a complete example here which includes a sample COM server written in C# which demonstrates one approach to calling the Bentley Map Interoperability managed API methods from VBA. The following sample VBA form should give you some idea of what is provided.

    Regards,

    Jeff Bielefeld [Bentley]



  • Hi Jeff,

    your example would be a great help for my project since I need a similar functionality. The only problem is that I can't access the file since it's password protected. I would kindly ask if it's possible that I get it? 

    Regards

Reply Children