This document is archived and information here might be outdated. Recommended version. |
Create a property SchematicAttribute on a given SchematicElementClass
/// <summary> /// Create a property SchematicAttribute on a given SchematicElementClass /// </summary> /// <param name="schElementClass">The SchematicElementClass where the property attribute is created</param> /// <param name="AttributeName">The ISchematicAttributeProperty 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="sFieldName">The FieldName for the created schematic attribute</param> /// <param name="sPropertyName">The PropertyName for the created schematic attribute</param> /// <returns>The created ESRI.ArcGIS.Schematic.ISchematicAttributeProperty</returns> /// <remarks>The UID.Value is a contant GUID value for the ISchematicAttributeProperty type of schematic attribute</remarks> public ESRI.ArcGIS.Schematic.ISchematicAttributeProperty CreateAttributePropertyForElementClass(ESRI.ArcGIS.Schematic.ISchematicElementClass schElementClass, string AttributeName, ESRI.ArcGIS.Schematic.esriSchematicAttributeEvaluationMode EvalMode, ESRI.ArcGIS.Schematic.esriSchematicAttributeStorageMode StorageMode, string sFieldName, string sPropertyName) { ESRI.ArcGIS.Schematic.ISchematicAttribute schAttribute=null; try // create an ISchematicAttribute { ESRI.ArcGIS.esriSystem.UID pUid=new ESRI.ArcGIS.esriSystem.UID(); pUid.Value="{E70BD51A-FCC4-4465-9ABC-BA17602F9E72}"; 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 ISchematicAttributeProperty and set its properties ESRI.ArcGIS.Schematic.ISchematicAttributeProperty schAttProperty=(ESRI.ArcGIS.Schematic.ISchematicAttributeProperty)schAttribute; if (schAttProperty != null) { schAttProperty.FieldName=sFieldName; schAttProperty.PropertyName=sPropertyName; } return schAttProperty; }
''' <summary> '''Create a property SchematicAttribute on a given SchematicElementClass ''' </summary> ''' <param name="schElementClass">The SchematicElementClass where the property attribute is created</param> ''' <param name="AttributeName">The ISchematicAttributeProperty 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="sFieldName">The FieldName for the created schematic attribute</param> ''' <param name="sPropertyName">The PropertyName for the created schematic attribute</param> ''' <returns>The created ESRI.ArcGIS.Schematic.ISchematicAttributeProperty</returns> ''' <remarks>The UID.Value is a contant GUID value for the ISchematicAttributeProperty type of schematic attribute</remarks> Public Function CreateAttributePropertyForElementClass(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 sFieldName As String, ByVal sPropertyName As String) As ESRI.ArcGIS.Schematic.ISchematicAttributeProperty 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="{E70BD51A-FCC4-4465-9ABC-BA17602F9E72}" 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 ISchematicAttributeProperty and set its properties Dim schAttProperty As ESRI.ArcGIS.Schematic.ISchematicAttributeProperty=TryCast(schAttribute, ESRI.ArcGIS.Schematic.ISchematicAttributeProperty) If (schAttProperty IsNot Nothing) Then schAttProperty.FieldName=sFieldName schAttProperty.PropertyName=sPropertyName End If Return schAttProperty End Function