Select to view content in your preferred language

Schematics digram On Server

1403
19
06-09-2010 09:46 PM
sandeepmidgule
New Contributor
Hii All,
  I just want to know how to generate schematic Diagram on ArcGis Server. i m doing electric tracing and also using ArcFM server..

Please Help Me,

Thanx In Advance
Sandeep K Midgule,
Tags (2)
0 Kudos
19 Replies
RickAnderson
Occasional Contributor III
There is a sample for generating diagrams on server that shows the basics.  The system has a geoprocessing tool for 'create diagram'.  So the user somehow selects data and then that data is passed into the Create Diagram tool.  This model is put in server as a service that the user runs.  Once the results are done, you can allow the user to see the resulting diagram.
0 Kudos
sandeepmidgule
New Contributor
Dear Rick,
       I want to generate schematic diagram through code without using GP. please help.
0 Kudos
RickAnderson
Occasional Contributor III
Sent you an e-mail.
0 Kudos
sandeepmidgule
New Contributor
heeeeeeeeee, we have solved the problem and we r very glad to tell that we can now generate schematic diagram on web without using GP tools... actually issue was with License file.
Thanx Rick for your wonderfull support from me and Rajesh.
          if want then please contact on : sandeep.midgule@gmail.com
0 Kudos
ashishtiwari
New Contributor
Dear Sandeep and Rick,I have to perform the same task as sandeep mentioned above that is to Generate schematic diagram through code ,which will take tracing results as input.Can you Please send me some code sample.Thanks in advance.My EmailID is ashishtwr123@gmail.com
0 Kudos
ShaikhRizuan
New Contributor III
Hi Rick/Sandeep

I have to do the same task....to show the Schematic diagram without using GP tool. I want to know which license problem did you had?. Can u send me some details about the approach how to achieve this task.

My EmailID is shaikhrizuan@gmail.com

Thanks

Shaikh Rizuan
0 Kudos
sandeepmidgule
New Contributor
Below is sample code which i have convert to c# which help us to generate Schematic Diagram On Web... for more help contact on sandeep.midgule@gmail.com

Option Explicit
Implements ICommand
Dim m_pApp As IApplication      'ArcMap application
Dim m_pBitmap As IPictureDisp   'Bitmap for the command
Dim m_pCursor As IPictureDisp   'Cursor for the command
Dim pMxDoc As IMxDocument       'ArcMap document
Dim pMap As IMap                ' Map

Private Sub Class_Initialize()
'Load the button image and cursor from the resource file.
Set m_pBitmap = LoadResPicture(101, 0)
End Sub
Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE
     ' Set the bitmap of the command. The m_pBitmap variable is set in Class_Initialize.
     ICommand_Bitmap = m_pBitmap
End Property
Private Property Get ICommand_Caption() As String
     ' String that appears when the command is used as a menu item.
     ICommand_Caption = "Generate Diagram From Selection"
End Property
Private Property Get ICommand_Category() As String
     ' Category of this command.
     ' This determines where the command appears in the Commands panel of the Customize dialog.
     ICommand_Category = "Custom Schematic Commands"
End Property
Private Property Get ICommand_Checked() As Boolean
End Property
Private Property Get ICommand_Enabled() As Boolean
Dim pSchematicLayer As ISchematicLayer
Dim pSchNgWrkMgr As ISchematicProjectMgr
Dim pEnumLayer As IEnumLayer
Dim pLayer As ILayer
Dim pEnumFeature As IEnumFeature
Dim pFeature As IFeature
     ' By default, the command is disabled
     ICommand_Enabled = False
     ' The command will be enabled only when a selection set is highlighted in the map
     Set pMxDoc = m_pApp.Document
     Set pMap = pMxDoc.FocusMap
     Set pEnumFeature = pMap.FeatureSelection
     Set pFeature = pEnumFeature.Next
     If Not pFeature Is Nothing Then
         ICommand_Enabled = True
     End If
End Property
Private Property Get ICommand_HelpContextID() As Long
End Property
Private Property Get ICommand_HelpFile() As String
End Property
Private Property Get ICommand_Message() As String
     'Message string that appears in the statusbar of the application when the mouse passes over the command.
     ICommand_Message = "Generate Diagram from Selection Set"
End Property
Private Property Get ICommand_Name() As String
     'Internal name of this command. By convention, this name string contains the category and caption of the command.
     ICommand_Name = "CustomSchematicCommands_GenerateDiagramFromSelection"
End Property
Private Sub ICommand_OnClick()
Dim pGxDialog As IGxDialog
Dim pFilterSchDatasets As IGxObjectFilter
Dim pFilterCol As IGxObjectFilterCollection
Dim pEnumGx As IEnumGxObject
Dim pGxDataset As IGxDataset
Dim pServerContext As IServerContext
Dim pSchematicDataset As ISchematicDataset
Dim pSchDiagramClass As ISchematicDiagramClass
Dim pSchDiagramClassContainer As ISchematicDiagramClassContainer
Dim pSchStandardBuilder As ISchematicStandardBuilder
Dim pSchBuilderCtxt As ISchematicBuilderContext
Dim pSchStandardBuilderCtxt As ISchematicStandardBuilderContext
Dim pSchBuilder As ISchematicBuilder
Dim pSchBuilderProps As ISchematicBuilderProps
Dim pPropertySet As IPropertySet
Dim pSchBuilderDesc As ISchematicBuilderDescription
Dim pEnumFeature As IEnumFeature
Dim pEnumObject As IEnumObject
Dim pFeature As IFeature
Dim pObject As IObject
Dim pUID As UID
Dim pSchematicEnumObject As EnumSchematicObject
Dim DiagramName As String
Dim pSchematicDiagram As ISchematicDiagram
Dim pSchematicLayer As ISchematicLayer
Dim pLayer As ILayer
    On Error Resume Next
    ' Getting the selected objects
    Set pMxDoc = m_pApp.Document
    Set pMap = pMxDoc.FocusMap
    Set pEnumFeature = pMap.FeatureSelection
    Set pSchematicEnumObject = New EnumSchematicObject
    pSchematicEnumObject.Initialize pEnumFeature
    ' Opening a GxDialog so the user selects the schematic dataset
    Set pFilterSchDatasets = New GxFilterSchematicDatasets
    Set pGxDialog = New GxDialog
    Set pFilterCol = pGxDialog
    pFilterCol.AddFilter pFilterSchDatasets, True
    pGxDialog.Title = "Select Schematic dataset"
    If Not pGxDialog.DoModalOpen(0, pEnumGx) Then
        Exit Sub
    End If
    ' Getting the selected schematic dataset
    Set pGxDataset = pEnumGx.Next
    Set pSchematicDataset = pGxDataset.Dataset
    ' Checking the diagram class existence in the selected schematic dataset
    Set pSchDiagramClassContainer = pSchematicDataset
    Set pSchDiagramClass = pSchDiagramClassContainer.SchematicDiagramClassByName(MyNewDiagramClassName)
    ' When the diagram class doesn't already exist, the CreateSchematicDiagramClass method is used to create it
    If pSchDiagramClass Is Nothing Then
        Set pSchDiagramClass = pSchematicDataset.CreateSchematicDiagramClass(MyNewDiagramClassName, Nothing, Nothing, Nothing, "")
        ' Then, a new instance of the SchematicStandardBuilder class is created
        Set pSchStandardBuilder = CreateObject("esriSchematic.SchematicStandardBuilder")
        ' The properties for this new builder are specified
        pSchStandardBuilder.AutoCreateElementClasses = True
        pSchStandardBuilder.InitializeLinksVertices = True
        pSchStandardBuilder.AddConnectedNodes = True
        Set pSchBuilder = pSchStandardBuilder
        Set pSchBuilderProps = pSchBuilder
        Set pSchBuilderDesc = pSchBuilder
        Set pPropertySet = pSchBuilderProps.PropertySet
        Set pUID = pSchBuilderDesc.ClassID
        ' The newly created builder is associated with the new diagram class
        pSchDiagramClass.AlterBuilder pUID, pPropertySet
    End If
    ' Getting the context that will be used to build the diagram
    Set pSchStandardBuilderCtxt = CreateObject("esriSchematic.SchematicStandardBuilderContext")
    Set pSchStandardBuilderCtxt.InitialObjects = pSchematicEnumObject
    ' Generating the diagram
    DiagramName = "Diagram_" & pSchDiagramClass.SchematicDiagrams.Count + 1
    Set pSchematicDiagram = pSchDiagramClass.SchematicBuilder.GenerateDiagram(DiagramName, , , pSchStandardBuilderCtxt)
    ' Displaying the diagram
    Set pSchematicLayer = New SchematicLayer
    Set pSchematicLayer.SchematicDiagram = pSchematicDiagram
    Set pLayer = pSchematicLayer
    pLayer.Name = DiagramName
    pMap.AddLayer pLayer
    Err.Clear
End Sub
Private Sub ICommand_OnCreate(ByVal hook As Object)
     Set m_pApp = hook
End Sub
Private Property Get ICommand_Tooltip() As String
     'String that appears in the screen tip.
     ICommand_Tooltip = "Generate Diagram From Selection"
End Property
0 Kudos
sameerpuppal
Occasional Contributor
Hi,

Rizuan did that help you?

regards,
Sameer
0 Kudos
sanjeevsinha
New Contributor II
Hi,

i am facing the problem while generating the schematic diagram using the code.

The code throwing the "Access denied error" when trying to set the ISchematicStandardBuilderContext.InitialObjects.

Below is the code i am using.

public void GenerateSchematicsDiag(IEnumFeature pEnumFeature, IServerContext pServerContext, out string erroMsg)
{

string DiagramName = "testingSanjeev";
string SchematicDataset = "SDE.Schematicdataset";
string FolderName = "SSNJ";
ESRI.ArcGIS.Carto.IMapServer mapServer = pServerContext.ServerObject as ESRI.ArcGIS.Carto.IMapServer;
ESRI.ArcGIS.Carto.IMapServerObjects mapServerObjects = (ESRI.ArcGIS.Carto.IMapServerObjects)mapServer;

ESRI.ArcGIS.Carto.IMap pMap = mapServerObjects.get_Map(mapServer.DefaultMapName);

ISchematicDataset pSchematicDataset = null;
ISchematicDiagramClass pSchDiagramClass = null;
ISchematicDiagramClassContainer pSchDiagramClassContainer = null;
ISchematicStandardBuilderContext pSchStandardBuilderCtxt = null;
ISchematicDiagram pSchematicDiagram = null;
ISchematicWorkspace pSchWorkspace = null;
ISchematicWorkspaceFactory pSchWorkspaceFac = null;
ISchematicDiagramContainer pSchematicDiagramContainer = null;
ISchematicFolderContainer pSchematicFolderContainer = null;
ISchematicFolder pSchematicFolder = null;
try
{
if (!(DiagramName == null))
{


IFeatureLayer substflayer = (IFeatureLayer)pMap.get_Layer(1);
IFeatureClass firstfclass = substflayer.FeatureClass;
IDataset dataset = (IDataset)firstfclass;
IWorkspace pWorkSpace = dataset.Workspace;


pSchWorkspaceFac = pServerContext.CreateObject("esriSchematic.SchematicWorkspaceFactory") as ISchematicWorkspaceFactory;
pSchWorkspace = pSchWorkspaceFac.Open(pWorkSpace);
pSchematicDataset = pSchWorkspace.get_SchematicDatasetByName(SchematicDataset);
pSchematicFolderContainer = (ISchematicFolderContainer)pSchematicDataset;
pSchematicFolder = pSchematicFolderContainer.get_SchematicFolderByName(FolderName);
if ((pSchematicFolder == null))
{
pSchematicFolder = pSchematicDataset.CreateSchematicFolder(FolderName);
}
pSchematicDiagramContainer = (ISchematicDiagramContainer)pSchematicFolderContainer.get_SchematicFolderByName(FolderName);

pSchStandardBuilderCtxt = pServerContext.CreateObject("esriSchematic.SchematicStandardBuilderContext") as ISchematicStandardBuilderContext;

pEnumFeature.Next();
EnumObjectConverter eocon = new EnumObjectConverter(pEnumFeature);
pSchStandardBuilderCtxt.InitialObjects = eocon as IEnumObject;
ISchematicBuilderContext ctx = pSchStandardBuilderCtxt as ISchematicBuilderContext;

IPropertySet set = pServerContext.CreateObject("esriSystem.PropertySet") as IPropertySet;
pSchDiagramClassContainer = (ISchematicDiagramClassContainer)pSchematicDataset;
string clsName = "FeederDiagram";
pSchDiagramClass = pSchDiagramClassContainer.get_SchematicDiagramClassByName(clsName);
if ((pSchDiagramClass == null))
{
return;
}

pSchematicDiagram = pSchDiagramClass.SchematicBuilder.GenerateDiagram(DiagramName, pSchematicDiagramContainer, set, ctx, null);

}
}
catch (Exception ex)
{
throw ex;
}

}

class EnumObjectConverter : IEnumObject
{
private IEnumFeature ef;

public EnumObjectConverter(IEnumFeature enumFea)
{
ef = enumFea;
ef.Reset();
}




IObject IEnumObject.Next()
{
if (ef != null)
return ef.Next() as IObject;
else
{
return null;
}
}

void IEnumObject.Reset()
{
ef.Reset();
}


}


Thanks for any help.

Sanjeev Sinha
0 Kudos