sanjeev_ksinha

Delete Schematic Diagram Using Code.

Discussion created by sanjeev_ksinha on Oct 10, 2011
Latest reply on Oct 19, 2011 by sanjeev_ksinha
Hi,

I am trying to delete the Schematic Diagram using the below code. The codes runs fine without any error but diagram is not getting deleted from sde geodatabase. (I have used the ISchematicBuilderEdit.OnDeleteDiagram interface.)

I am using (ArcGis Sever V9.3.1)

private string DeleteSchematicDiagram(string diagramName,string folderName,string schematicDatasetName,IWorkSpace pwksSpace)
{
ISchematicWorkspaceFactory pSchWorkspaceFac = pServerContext1.CreateObject("esriSchematic.SchematicWorkspaceFactory") as ISchematicWorkspaceFactory;
            ISchematicWorkspace pSchWorkspace = pSchWorkspaceFac.Open(pwksSpace);
            ISchematicDataset pSchDataSet = pSchWorkspace.get_SchematicDatasetByName(schematicDatasetName);
            if (pSchDataSet != null)
            {
                ISchematicFolderContainer pSchematicFolderContainer = (ISchematicFolderContainer)pSchDataSet;
                ISchematicFolder pSchematicFolder = pSchematicFolderContainer.get_SchematicFolderByName(folderName);
                ISchematicDiagramContainer pSchematicDiagramContainer = pSchematicFolder as ISchematicDiagramContainer;
               IEnumSchematicDiagram pEnumScheDiag = pSchematicDiagramContainer.SchematicDiagrams;
               ISchematicDiagram pSchDiagram = null;
               for (int i = 0; i < pSchematicDiagramContainer.SchematicDiagrams.Count; i++)
               {
                   ISchematicDiagram finalSchemDiagram = pEnumScheDiag.Next();
                   if (finalSchemDiagram != null)
                   {
                       if (finalSchemDiagram.Name == diagramName)
                       {
                           pSchDiagram = finalSchemDiagram;
                           break;
                       }

                   }
               }//For loop

               if (pSchDiagram != null)
               {
                   ISchematicBuilder pSchStandardBuilder = pSchDiagram.SchematicDiagramClass.SchematicBuilder as ISchematicBuilder;
                   ISchematicBuilderEdit pSchematicBuilderEdit = pSchStandardBuilder as ISchematicBuilderEdit;
                   try
                   {
                       pSchematicBuilderEdit.OnDeleteDiagram(pSchDiagram);
                   }
                   catch (Exception exp)
                   {
                       return "ERROR^" + exp.Message;
                   }

               }


            }
            else
            {
                return "ERROR^Schematic dataset not found.";
            }
}

Thanks for any help......

Thanks & regards
Sanjeev kumar Sinha

Outcomes