![]() |
This document is archived and information here might be outdated. Recommended version. |
Create a script SchematicAttribute on a given SchematicElementClass
/// <summary>
/// Create a script SchematicAttribute on a given SchematicElementClass
/// </summary>
/// <param name="schElementClass">The SchematicElementClass where the script attribute is created</param>
/// <param name="AttributeName">The ISchematicAttributeScript 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="sScript">The Script for the created schematic attribute</param>
/// <param name="ParameterNames">The ParameterNames for the created schematic attribute</param>
/// <returns>The created ESRI.ArcGIS.Schematic.ISchematicAttributeScript</returns>
/// <remarks>The UID.Value is a contant GUID value for the ISchematicAttributeScript type of schematic attribute</remarks>
public ESRI.ArcGIS.Schematic.ISchematicAttributeScript CreateAttributeScriptForElementClass(ESRI.ArcGIS.Schematic.ISchematicElementClass schElementClass, string AttributeName, ESRI.ArcGIS.Schematic.esriSchematicAttributeEvaluationMode EvalMode, ESRI.ArcGIS.Schematic.esriSchematicAttributeStorageMode StorageMode, string sScript, string[] ParameterNames)
{
ESRI.ArcGIS.Schematic.ISchematicAttribute schAttribute=null;
try
// create an ISchematicAttribute
{
ESRI.ArcGIS.esriSystem.UID pUid=new ESRI.ArcGIS.esriSystem.UID();
pUid.Value="{DF83E3AD-4448-483C-86C3-1E7E247B5D04}";
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 ISchematicAttributeScript and set its properties
ESRI.ArcGIS.Schematic.ISchematicAttributeScript schAttScript=(ESRI.ArcGIS.Schematic.ISchematicAttributeScript)schAttribute;
if (schAttScript != null)
{
schAttScript.Script=sScript;
schAttScript.ParameterNames=ParameterNames;
}
return schAttScript;
}
''' <summary>
''' Create a script SchematicAttribute on a given SchematicElementClass
''' </summary>
''' <param name="schElementClass">The SchematicElementClass where the script attribute is created</param>
''' <param name="AttributeName">The ISchematicAttributeScript 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="sScript">The Script for the created schematic attribute</param>
''' <param name="ParameterNames">The ParameterNames for the created schematic attribute</param>
''' <returns>The created ESRI.ArcGIS.Schematic.ISchematicAttributeScript</returns>
''' <remarks>The UID.Value is a contant GUID value for the ISchematicAttributeScript type of schematic attribute</remarks>
Public Function CreateAttributeScriptForElementClass(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 sScript As String, ByVal ParameterNames() As String) As ESRI.ArcGIS.Schematic.ISchematicAttributeScript
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="{DF83E3AD-4448-483C-86C3-1E7E247B5D04}"
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 ISchematicAttributeScript and set its properties
Dim schAttScript As ESRI.ArcGIS.Schematic.ISchematicAttributeScript=TryCast(schAttribute, ESRI.ArcGIS.Schematic.ISchematicAttributeScript)
If (schAttScript IsNot Nothing) Then
schAttScript.Script=sScript
schAttScript.ParameterNames=ParameterNames
End If
Return schAttScript
End Function