Schematic diagram generation using ArcObjects

3913
7
09-03-2014 08:02 AM
KevinLECOCQ
New Contributor III

Hi, I would like to generate a schematic diagram using ArcObjects (Java) but I didn't find any sample or documentation on how to do it, even in the .NET samples.

I only found this sample:

Generating Standard Builder diagrams by code

but it dates from ArcObjects 9.2 and is for VB.

I can't find any equivalent in java to this kind of instantiation:

Set pSchStandardBuilder = CreateObject("esriSchematic.SchematicStandardBuilder")

Does anyone knows how to use the Schematics ArcObjects API?

Thanks.

7 Replies
RickAnderson
Occasional Contributor III

There is a snippet in the api documentation...but...the link is broken

No nice way to do this other than copy/paste...here you go:

<?xml version="1.0" encoding="utf-8"?>

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

  <CodeSnippet Format="1.0.0">

    <Header>

      <Title>Generate A Diagram From A Map Selection</Title>

      <Description>Generate a diagram from features selected in a geographic map</Description>

      <Author>Esri</Author>

    </Header>

    <Snippet>

      <Code Language="VB"><![CDATA[

#Region"Generate A Diagram From A Map Selection"

' ArcGIS Snippet Title:

' Generate A Diagram From A Map Selection

'

' Long Description:

' Generate a diagram from features selected in a geographic map

'

' Add the following references to the project:

' ESRI.ArcGIS.Carto

' ESRI.ArcGIS.Schematic

'

' Intended ArcGIS Products for this snippet:

' ArcGIS Desktop (Standard, Advanced)

' ArcGIS Engine

'

' Applicable ArcGIS Product Versions:

' 10.0

' 10.1

'

' Required ArcGIS Extensions:

' ArcGIS Schematics

'

' Notes:

' This snippet is intended to be inserted at the base level of a Class.

' It is not intended to be nested within an existing Function or Sub.

'

''' <summary>

''' Generate a diagram from features selected in a geographic map

''' </summary>

''' <param name="pMap">Geographic map containing the input selected GIS features</param>

''' <param name="schemDiagClass">SchematicDiagramClass; that is, diagram template on which the generated diagram is based</param>

''' <param name="schemDiagramContainer">SchematicDiagramContainer where the generated diagram will be stored</param>

''' <param name="DiagramName">Name for the generated diagram</param>

''' <returns>The generated ESRI.ArcGIS.Schematic.ISchematicDiagram</returns>

Public Function GenerateDiagramFromMap(ByVal pMap As ESRI.ArcGIS.Carto.IMap, ByVal schemDiagClass As ESRI.ArcGIS.Schematic.ISchematicDiagramClass, ByVal schemDiagramContainer As ESRI.ArcGIS.Schematic.ISchematicDiagramContainer, ByVal DiagramName As String) As ESRI.ArcGIS.Schematic.ISchematicDiagram

  ' if DiagramName is empty exit

        If (DiagramName.Length = 0) Then Return Nothing

        ' cast SchematicDiagramClass into ISchematicBuilder

        Dim schBuilder As ESRI.ArcGIS.Schematic.ISchematicBuilder = TryCast(schemDiagClass, ESRI.ArcGIS.Schematic.ISchematicBuilder)

        ' create the ISchematicStandardBuilderContext

        Dim objectType As Type = Type.GetTypeFromProgID("esriSchematic.SchematicStandardBuilderContext")

        ' if objectType is nothing, the BuilderContext cannot be created, then exit

        If (objectType Is Nothing) Then Return Nothing

        Dim schBuilderCtxt As ESRI.ArcGIS.Schematic.ISchematicStandardBuilderContext

        schBuilderCtxt = TryCast(Activator.CreateInstance(objectType), ESRI.ArcGIS.Schematic.ISchematicStandardBuilderContext)

        ' get the selected features in the map

        Dim enumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature = TryCast(pMap.FeatureSelection, ESRI.ArcGIS.Geodatabase.IEnumFeature)

        ' initialize the ISchematicStandardBuilderContext with the selection set

        schBuilderCtxt.InitialObjects = New EnumSchematicObject(enumFeature)

        ' generate the schematic diagram

        Return schBuilder.GenerateDiagram(DiagramName, schemDiagramContainer, Nothing, TryCast(schBuilderCtxt, ESRI.ArcGIS.Schematic.ISchematicBuilderContext), Nothing)

End Function

Public Class EnumSchematicObject

        Implements ESRI.ArcGIS.Geodatabase.IEnumObject

        Private m_pIEnumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature

        Public Sub New(ByVal pEnumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature)

  m_pIEnumFeature = pEnumFeature

        End Sub

        Public Function [Next]() As ESRI.ArcGIS.Geodatabase.IObject Implements ESRI.ArcGIS.Geodatabase.IEnumObject.Next

  If (m_pIEnumFeature IsNot Nothing) Then

  Return TryCast(m_pIEnumFeature.Next(), ESRI.ArcGIS.Geodatabase.IObject)

  Else

  Return Nothing

  End If

        End Function

        Public Sub Reset() Implements ESRI.ArcGIS.Geodatabase.IEnumObject.Reset

  If (m_pIEnumFeature IsNot Nothing) Then m_pIEnumFeature.Reset()

        End Sub

End Class

#End Region]]></Code>

    </Snippet>

  </CodeSnippet>

  <ArcGISSnippet>

    <XMLFormat>9</XMLFormat>

    <SnippetVersion>1</SnippetVersion>

    <ParentGUID>1258e6f9-7d5f-4958-b398-2ac88ff5d2ae</ParentGUID>

    <Language>VB</Language>

    <GUID>356f3b73-8545-41d0-9db4-aa8f6ad79ee9</GUID>

    <Name>Generate A Diagram From A Map Selection</Name>

    <LongDescription>Generate a diagram from features selected in a geographic map</LongDescription>

    <Products>

      <Product ProductType="Standard">ArcGIS Desktop</Product>

      <Product ProductType="Advanced">ArcGIS Desktop</Product>

      <Product ProductType="Engine">ArcGIS Engine</Product>

    </Products>

    <Extensions>

      <Extension>ArcGIS Schematics</Extension>

    </Extensions>

    <ArcGISAuthor>Esri</ArcGISAuthor>

    <ProductVersions>

      <ProductVersion>10.0</ProductVersion>

      <ProductVersion>10.1</ProductVersion>

    </ProductVersions>

    <SnippetType>function-sub-method</SnippetType>

    <References>

      <Reference>ESRI.ArcGIS.Carto</Reference>

      <Reference>ESRI.ArcGIS.Schematic</Reference>

    </References>

    <InputParameters>

      <Input ParameterType="ByVal">ESRI.ArcGIS.Carto.IMap</Input>

      <Input ParameterType="ByVal">ESRI.ArcGIS.Schematic.ISchematicDiagramClass</Input>

      <Input ParameterType="ByVal">ESRI.ArcGIS.Schematic.ISchematicDiagramContainer</Input>

      <Input ParameterType="ByVal">String</Input>

      <Input ParameterType="ByVal">ESRI.ArcGIS.Geodatabase.IEnumFeature</Input>

    </InputParameters>

    <ReturnParameters>

      <Return ParameterType="ByVal">ESRI.ArcGIS.Schematic.ISchematicDiagram</Return>

      <Return ParameterType="ByVal">ESRI.ArcGIS.Geodatabase.IObject</Return>

    </ReturnParameters>

    <Members>

      <Member LinkToComponentHelp="True">ESRI.ArcGIS.Schematic.ISchematicDiagram</Member>

      <Member LinkToComponentHelp="True">ESRI.ArcGIS.Schematic.ISchematicBuilder</Member>

      <Member LinkToComponentHelp="True">ESRI.ArcGIS.Schematic.ISchematicStandardBuilderContext</Member>

      <Member LinkToComponentHelp="True">ESRI.ArcGIS.Schematic.ISchematicStandardBuilderContext.InitialObjects</Member>

      <Member LinkToComponentHelp="True">ESRI.ArcGIS.Schematic.ISchematicBuilder.GenerateDiagram</Member>

    </Members>

    <CodeBody><![CDATA[

  ''' <summary>

  ''' Generate a diagram from features selected in a geographic map

  ''' </summary>

  ''' <param name="pMap">Geographic map containing the input selected GIS features</param>

  ''' <param name="schemDiagClass">SchematicDiagramClass; that is, diagram template on which the generated diagram is based</param>

  ''' <param name="schemDiagramContainer">SchematicDiagramContainer where the generated diagram will be stored</param>

  ''' <param name="DiagramName">Name for the generated diagram</param>

  ''' <returns>The generated ESRI.ArcGIS.Schematic.ISchematicDiagram</returns>

  Public Function GenerateDiagramFromMap(ByVal pMap As ESRI.ArcGIS.Carto.IMap, ByVal schemDiagClass As ESRI.ArcGIS.Schematic.ISchematicDiagramClass, ByVal schemDiagramContainer As ESRI.ArcGIS.Schematic.ISchematicDiagramContainer, ByVal DiagramName As String) As ESRI.ArcGIS.Schematic.ISchematicDiagram

  ' if DiagramName is empty exit

  If (DiagramName.Length = 0) Then Return Nothing

  ' cast SchematicDiagramClass into ISchematicBuilder

  Dim schBuilder As ESRI.ArcGIS.Schematic.ISchematicBuilder = TryCast(schemDiagClass, ESRI.ArcGIS.Schematic.ISchematicBuilder)

  ' create the ISchematicStandardBuilderContext

  Dim objectType As Type = Type.GetTypeFromProgID("esriSchematic.SchematicStandardBuilderContext")

  ' if objectType is nothing, the BuilderContext cannot be created, then exit

  If (objectType Is Nothing) Then Return Nothing

  Dim schBuilderCtxt As ESRI.ArcGIS.Schematic.ISchematicStandardBuilderContext

  schBuilderCtxt = TryCast(Activator.CreateInstance(objectType), ESRI.ArcGIS.Schematic.ISchematicStandardBuilderContext)

  ' get the selected features in the map

  Dim enumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature = TryCast(pMap.FeatureSelection, ESRI.ArcGIS.Geodatabase.IEnumFeature)

  ' initialize the ISchematicStandardBuilderContext with the selection set

  schBuilderCtxt.InitialObjects = New EnumSchematicObject(enumFeature)

  ' generate the schematic diagram

  Return schBuilder.GenerateDiagram(DiagramName, schemDiagramContainer, Nothing, TryCast(schBuilderCtxt, ESRI.ArcGIS.Schematic.ISchematicBuilderContext), Nothing)

  End Function

  Public Class EnumSchematicObject

  Implements ESRI.ArcGIS.Geodatabase.IEnumObject

        Private m_pIEnumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature

        Public Sub New(ByVal pEnumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature)

  m_pIEnumFeature = pEnumFeature

        End Sub

        Public Function [Next]() As ESRI.ArcGIS.Geodatabase.IObject Implements ESRI.ArcGIS.Geodatabase.IEnumObject.Next

            If (m_pIEnumFeature IsNot Nothing) Then

                Return TryCast(m_pIEnumFeature.Next(), ESRI.ArcGIS.Geodatabase.IObject)

            Else

                Return Nothing

            End If

        End Function

        Public Sub Reset() Implements ESRI.ArcGIS.Geodatabase.IEnumObject.Reset

            If (m_pIEnumFeature IsNot Nothing) Then m_pIEnumFeature.Reset()

        End Sub

    End Class]]></CodeBody>

  </ArcGISSnippet>

</CodeSnippets>

0 Kudos
KevinLECOCQ
New Contributor III

Thanks for your reply.

I understand how this sample works, but I don't know how to rewrite this kind of instantiation in Java:

Dim objectType As Type = Type.GetTypeFromProgID("esriSchematic.SchematicStandardBuilderContext")

considering there isn't any SchematicStandardBuilderContext class in the ArcObjects class package.

Do you know what's the equivalent?

0 Kudos
Anne-YvonneBlin
New Contributor III

It appears that you figured out a real problem in our ArcObjects Java AP . We have some classes missing.

No solution at that time to create SchematicStandardBuilder and SchematicStandardBuilderContext objects from scratch using Java code...

0 Kudos
KevinLECOCQ
New Contributor III

Yes, I realize that too.

And it seems that there is not many developers using ArcObjects + Java + Schematics...

0 Kudos
KevinLECOCQ
New Contributor III

As a temporary solution, I will use C# instead of Java, only for the schematic diagram generation.

YuanLiu
Occasional Contributor

For people that still have the same problem, please refer to ISchematicStandardBuilderProxy(ISchematicStandardBuilderProxy (ArcObjects Java API) )

and ArcGIS development using the Java API (http://resources.arcgis.com/en/help/arcobjects-java/concepts/engine/index.html#//000100000608000000 )

Vara_PrasadM_S
Occasional Contributor II

Hi Team,

When I run the same code in a console application by checking out the Schematics Extension license, it is generating an empty diagram but working fine as an addin. 

Could someone please help me with this. Do we need to add the Schematic extension to the console application?

Thanks & Regards,

Vara Prasad

0 Kudos