This document is archived and information here might be outdated.  Recommended version.


Create A SchematicAttributeQuery On A Schematic Element Class Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Create A SchematicAttributeQuery On A Schematic Element Class Snippet

Create a query SchematicAttribute on a given SchematicElementClass

[C#]
        /// <summary>
        /// Create a query SchematicAttribute on a given SchematicElementClass
        /// </summary>
        /// <param name="schElementClass">The SchematicElementClass where the query attribute is created</param>
        /// <param name="AttributeName">The ISchematicAttributeQuery name</param>
        /// <param name="EvalMode">The EvaluationMode for the created schematic attribute</param>
        /// <param name="StorageMode">The StorageMode for the created schematic attribute</param>
        /// <param name="ParameterNames">The SchematicQueryParameters for the created schematic attribute</param>
        /// <param name="SchematicDataSource">The SchematicDatasource for the created schematic attribute</param>
        /// <param name="sFieldName">The FieldName for the created schematic attribute</param>
        /// <param name="sQueryString">The QueryString for the created schematic attribute</param>
        /// <returns>The created ESRI.ArcGIS.Schematic.ISchematicAttributeQuery</returns>
        /// <remarks>The UID.Value is a contant GUID value for the ISchematicAttributeQuery type of schematic attribute</remarks>
        public ESRI.ArcGIS.Schematic.ISchematicAttributeQuery CreateAttributeQueryForElementClass(ESRI.ArcGIS.Schematic.ISchematicElementClass schElementClass, string AttributeName, ESRI.ArcGIS.Schematic.esriSchematicAttributeEvaluationMode EvalMode, ESRI.ArcGIS.Schematic.esriSchematicAttributeStorageMode StorageMode, ESRI.ArcGIS.Schematic.IEnumSchematicQueryParameter ParameterNames, ESRI.ArcGIS.Schematic.ISchematicDataSource SchematicDataSource, string sFieldName, string sQueryString)
        {

                ESRI.ArcGIS.Schematic.ISchematicAttribute schAttribute=null;
                try
                // create an ISchematicAttribute
                {
                        ESRI.ArcGIS.esriSystem.UID pUid=new ESRI.ArcGIS.esriSystem.UID();
                        pUid.Value="{9EB161BE-31BB-43E6-93ED-12BC62E6369D}";
                        schAttribute=schElementClass.CreateSchematicAttribute(AttributeName, pUid);
                }
                catch
                {
                        return null;
                }
                ESRI.ArcGIS.Schematic.ISchematicAttributeManagement schAttributeMngt=(ESRI.ArcGIS.Schematic.ISchematicAttributeManagement)schAttribute;
                try
                {
                        // the StorageMode must be set before the EvaluationMode 
                        // consistenty is checked when the EvaluationMode is set
                        schAttributeMngt.StorageMode=StorageMode;
                        schAttributeMngt.EvaluationMode=EvalMode;
                }
                catch
                {
                        // an error is returned if the StorageMode and EvaluationMode are not consistent
                }

                // cast SchematicAttribute into ISchematicAttributeQuery and set its properties
                ESRI.ArcGIS.Schematic.ISchematicAttributeQuery schAttQuery=(ESRI.ArcGIS.Schematic.ISchematicAttributeQuery)schAttribute;
                if (schAttQuery != null)
                {
                        schAttQuery.FieldName=sFieldName;
                        schAttQuery.QueryString=sQueryString;
                        schAttQuery.SchematicDataSource=SchematicDataSource;
                        schAttQuery.SchematicQueryParameters=ParameterNames;
                }

                return schAttQuery;
        }
[Visual Basic .NET]
  ''' <summary>
    ''' Create a query SchematicAttribute on a given SchematicElementClass
        ''' </summary>
    ''' <param name="schElementClass">The SchematicElementClass where the query attribute is created</param>
    ''' <param name="AttributeName">The ISchematicAttributeQuery name</param>
    ''' <param name="EvalMode">The EvaluationMode for the created schematic attribute</param>
    ''' <param name="StorageMode">The StorageMode for the created schematic attribute</param>
    ''' <param name="ParameterNames">The SchematicQueryParameters for the created schematic attribute</param>
    ''' <param name="SchematicDataSource">The SchematicDatasource for the created schematic attribute</param>
    ''' <param name="sFieldName">The FieldName for the created schematic attribute</param>
    ''' <param name="sQueryString">The QueryString for the created schematic attribute</param>
    ''' <returns>The created ESRI.ArcGIS.Schematic.ISchematicAttributeQuery</returns>
    ''' <remarks>The UID.Value is a contant GUID value for the ISchematicAttributeQuery type of schematic attribute</remarks>
        Public Function CreateAttributeQueryForElementClass(ByVal schElementClass As ESRI.ArcGIS.Schematic.ISchematicElementClass, ByVal AttributeName As String, ByVal EvalMode As ESRI.ArcGIS.Schematic.esriSchematicAttributeEvaluationMode, ByVal StorageMode As ESRI.ArcGIS.Schematic.esriSchematicAttributeStorageMode, ByVal ParameterNames As ESRI.ArcGIS.Schematic.IEnumSchematicQueryParameter, ByVal SchematicDataSource As ESRI.ArcGIS.Schematic.ISchematicDataSource, ByVal sFieldName As String, ByVal sQueryString As String) As ESRI.ArcGIS.Schematic.ISchematicAttributeQuery

                Dim schAttribute As ESRI.ArcGIS.Schematic.ISchematicAttribute=Nothing
        Try
            ' create an ISchematicAttribute
            Dim pUid As ESRI.ArcGIS.esriSystem.UID=New ESRI.ArcGIS.esriSystem.UID()
            pUid.Value="{9EB161BE-31BB-43E6-93ED-12BC62E6369D}"
            schAttribute=schElementClass.CreateSchematicAttribute(AttributeName, pUid)
        Catch
            Return Nothing
        End Try

                Dim schAttributeMngt As ESRI.ArcGIS.Schematic.ISchematicAttributeManagement=TryCast(schAttribute, ESRI.ArcGIS.Schematic.ISchematicAttributeManagement)
                Try
            ' the StorageMode must be set before the EvaluationMode 
            ' consistenty is checked when the EvaluationMode is set 
            schAttributeMngt.StorageMode=StorageMode
                        schAttributeMngt.EvaluationMode=EvalMode
                Catch
            ' an error is returned if the StorageMode and EvaluationMode are not consistent
        End Try

        ' cast SchematicAttribute into ISchematicAttributeQuery and set its properties
        Dim schAttQuery As ESRI.ArcGIS.Schematic.ISchematicAttributeQuery=TryCast(schAttribute, ESRI.ArcGIS.Schematic.ISchematicAttributeQuery)
                If (schAttQuery IsNot Nothing) Then
                        schAttQuery.FieldName=sFieldName
                        schAttQuery.QueryString=sQueryString
                        schAttQuery.SchematicDataSource=SchematicDataSource
                        schAttQuery.SchematicQueryParameters=ParameterNames
                End If

                Return schAttQuery
        End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Schematic