About the Implementing extended criteria for some predefined schematic rules Sample
[C#]
ExpandLinks.cs
using System; using System.Collections.Generic; using System.Runtime.InteropServices; using ESRI.ArcGIS.Schematic; using ESRI.ArcGIS.Geodatabase; namespace CustomExtCriteriaCS { [ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)] [Guid(ExpandLinks.GUID)] [ProgId(ExpandLinks.PROGID)] public class ExpandLinks : ISchematicExpandLinksByAttributeExtended { public const string GUID = "F942BDC2-2AD4-47c4-B96D-A8CA0002E9B3"; public const string PROGID = "CustomExtCriteriaCS.ExpandLinks"; #region Component Category Registration [ComRegisterFunction()] public static void Register(string CLSID) { ESRI.ArcGIS.ADF.CATIDs.SchematicRulesExtendedCriteria.Register(CLSID); } [ComUnregisterFunction()] public static void Unregister(string CLSID) { ESRI.ArcGIS.ADF.CATIDs.SchematicRulesExtendedCriteria.Unregister(CLSID); } #endregion #region ISchematicExpandLinksByAttributeExtended Membres public string Evaluate(ISchematicInMemoryFeature schematicFeature) { if (schematicFeature.SchematicElementClass.SchematicElementType != esriSchematicElementType.esriSchematicLinkType) return ""; ISchematicInMemoryFeatureLink schemLink; schemLink = (ISchematicInMemoryFeatureLink)schematicFeature; // Get From node ISchematicInMemoryFeatureNode schemFromNode; schemFromNode = schemLink.FromNode; // Get Associated feature ISchematicElementAssociatedObject scheAsso; scheAsso = (ISchematicElementAssociatedObject)schemFromNode.SchematicElement; IFeature esriFeature; esriFeature = (IFeature)scheAsso.AssociatedObject; // Get list of fields IFields esriFields; esriFields = esriFeature.Fields; int numField; // Find Field MaxOutLines numField = esriFields.FindFieldByAliasName("MaxOutLines"); if (numField <= 0) return ""; // Field not found // Return value of the field return esriFeature.get_Value(numField).ToString(); } public string Name { get { return "Use origin plant's MaxOutLines value (C#)"; } } #endregion } }
[Visual Basic .NET]
ExpandLinks.vb
Imports System Imports System.Collections.Generic Imports System.Runtime.InteropServices Imports ESRI.ArcGIS.Schematic Imports ESRI.ArcGIS.Geodatabase <ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)> _ <Guid(ExpandLinks.GUID)> _ <ProgId(ExpandLinks.PROGID)> _ Public Class ExpandLinks Implements ISchematicExpandLinksByAttributeExtended Public Const GUID As String = "D98900E4-B15D-4610-B42D-5D70E368FBC2" Public Const PROGID As String = "CustomExtCriteriaVB.ExpandLinks" #Region "Component Category Registration" <ComRegisterFunction()> _ Public Shared Sub Register(ByVal CLSID As String) ESRI.ArcGIS.ADF.CATIDs.SchematicRulesExtendedCriteria.Register(CLSID) End Sub <ComUnregisterFunction()> _ Public Shared Sub Unregister(ByVal CLSID As String) ESRI.ArcGIS.ADF.CATIDs.SchematicRulesExtendedCriteria.Unregister(CLSID) End Sub #End Region #Region "ISchematicExpandLinksByAttributeExtended Members" Public Function Evaluate(ByVal schematicFeature As ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature) As String _ Implements ESRI.ArcGIS.Schematic.ISchematicExpandLinksByAttributeExtended.Evaluate If (schematicFeature.SchematicElementClass.SchematicElementType <> esriSchematicElementType.esriSchematicLinkType) Then Return "" Dim schemLink As ISchematicInMemoryFeatureLink schemLink = CType(schematicFeature, ISchematicInMemoryFeatureLink) ' Get From node Dim schemFromNode As ISchematicInMemoryFeatureNode schemFromNode = schemLink.FromNode ' Get Associated feature Dim scheAsso As ISchematicElementAssociatedObject scheAsso = CType(schemFromNode.SchematicElement, ISchematicElementAssociatedObject) If scheAsso Is Nothing Then Return "" Dim esriFeature As IFeature esriFeature = CType(scheAsso.AssociatedObject, IFeature) ' Get list of fields Dim esriFields As IFields esriFields = esriFeature.Fields Dim numField As Integer ' Find Field MaxOutLines numField = esriFields.FindFieldByAliasName("MaxOutLines") If (numField <= 0) Then Return "" ' Field not found ' Return value of the field Return esriFeature.Value(numField).ToString() End Function Public ReadOnly Property Name() As String Implements ISchematicExpandLinksByAttributeExtended.Name Get Return "Use origin plant's MaxOutLines value (VBNet)" End Get End Property #End Region End Class