Create single line diagram using schematics

4043
3
12-24-2010 12:57 AM
NageshwarRao
New Contributor
Hi,

We need to create single line diagram for electric network which is in PGDB/SDE, especially for electric substations. Please let me know the procedure to generate single diagram for electric network...I have searched in the help, but could not find it. Please help.
-Avi
Tags (2)
0 Kudos
3 Replies
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
RickAnderson
Occasional Contributor III
Hi,

We need to create single line diagram for electric network which is in PGDB/SDE, especially for electric substations. Please let me know the procedure to generate single diagram for electric network...I have searched in the help, but could not find it. Please help.
-Avi


The answer to this depends on what version of software you are using and what your definition of a single line diagram is.  We see lots of requests for single line diagrams, but most requirements are not the same.  Usually you simply configure a diagram template that has a lot of node reduction rules to simplify the network and then run a smart tree algorithm to get the straight line look.  But, we would need much more information (an example would be best) of what you are trying to accomplish and what version you are using.
0 Kudos
sanjeevsinha
New Contributor II
Hi,

I am trying to create the schematic diagram of selected features on the map using the code. I am getting the below error when calling the GenerateDiagram of StandartBuilder.

But the same code in the Desktop is running fine.

ERROR:

Message      : Exception from HRESULT: 0x80040221
From           : ESRI.ArcGIS.Schematic
Stack Trace : at ESRI.ArcGIS.Schematic.ISchematicBuilder.GenerateDiagram(String diagramName, ISchematicDiagramContainer DiagramContainer, IPropertySet pPropertySet, ISchematicBuilderContext pContext, ITrackCancel cancelTracker)

I have checked the innerException and found below code:

_ComPlusExceptionCode: -532459699 and HResult error code : -2146233088


Thanks for any help.

Sanjeev sinha
0 Kudos