public bool SelectReduction(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode node, ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature enumLink, ref ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink link) { // if enumLink is empty do nothing if (enumLink == null) { return(false); } if (enumLink.Count == 0) { return(false); } enumLink.Reset(); ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature schemAssociatedLink; schemAssociatedLink = enumLink.Next(); // for each link in enumLink while (schemAssociatedLink != null) { // get cables ESRI.ArcGIS.Geodatabase.IFeature cablesFeature; cablesFeature = schemAssociatedLink.SchematicElement as ESRI.ArcGIS.Geodatabase.IFeature; if (cablesFeature == null) { return(false); } // get cables class ESRI.ArcGIS.Geodatabase.IDataset cablesDataset; cablesDataset = (ESRI.ArcGIS.Geodatabase.IDataset)cablesFeature.Class; // if not the right class do nothing if (cablesDataset.Name.IndexOf("cables") == 0) { return(false); } // get workspace ESRI.ArcGIS.Geodatabase.IFeatureWorkspace cablesWorkspace; cablesWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)cablesDataset.Workspace; // open table cables_attributes ESRI.ArcGIS.Geodatabase.ITable cablesTable; cablesTable = cablesWorkspace.OpenTable("cables_attributes"); if (cablesTable == null) { return(false); } // get diameter value object cableDiameter = cablesTable.GetRow(cablesFeature.OID).get_Value(1); if (cableDiameter.ToString() != "8") { return(false); //if not 8 do nothing } schemAssociatedLink = enumLink.Next(); } return(true); // if this far }
//The SelectReduction procedure works with the input node schematic node candidate to the //reduction and with the input linkElements list of schematic link elements incident to //this schematic node. It must return True for the output reduce boolean parameter if //the node is reduced, false if the node is kept. When the output ppLink schematic link //is not nothing, it determines the target node that will be used to reconnect the links //incidents to the reduced node. In this sample procedure, the node candidate to the //reduction is analyzed. If records related to this node exist in the plants_equipments table, //the node is kept (output reduce parameter is False); else, it is reduced (output reduce //parameter is True). public bool SelectReduction(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode node, ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature enumLink, ref ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink link) { // if associated feature doesn't exist do nothing ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature schemAssociatedNode; schemAssociatedNode = node as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature; if (schemAssociatedNode == null) { return(false); } // if dataset is not plants do nothing ESRI.ArcGIS.Geodatabase.IDataset schemElementClass; schemElementClass = (ESRI.ArcGIS.Geodatabase.IDataset)schemAssociatedNode.SchematicElementClass; if (schemElementClass == null) { return(false); } if (schemElementClass.Name.IndexOf("plants") < 0) { return(false); } // get workspace ESRI.ArcGIS.Geodatabase.IFeatureWorkspace plantsWorkspace; plantsWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)schemElementClass.Workspace; // open table plants_equipments ESRI.ArcGIS.Geodatabase.ITable plantsEquipment; plantsEquipment = plantsWorkspace.OpenTable("plants_equipments"); if (plantsEquipment == null) { return(false); } // filter for the selected feature ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation schemAssociation; schemAssociation = schemAssociatedNode as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation; if (schemAssociation == null) { return(false); } ESRI.ArcGIS.Geodatabase.IQueryFilter plantsFilter; plantsFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass(); plantsFilter.WhereClause = ("PlantID = " + schemAssociation.ObjectID); ESRI.ArcGIS.Geodatabase.ICursor plantsCursor; plantsCursor = plantsEquipment.Search(plantsFilter, true); // if found equipment return false if (plantsCursor != null && plantsCursor.NextRow() != null) { return(false); } return(true); // if this far }