Create Diagram (Schematics)

License Level:BasicStandardAdvanced

Summary

Creates a schematic diagram.

Depending on the schematic builder, diagram creation can be based on feature layers, feature classes, object tables, a network analysis layer, or XML data.

Usage

Syntax

CreateDiagram_schematics (out_location, out_name, diagram_type, {in_data}, {builder_options})
ParameterExplanationData Type
out_location

Schematic dataset or schematic folder in which the diagram will be created.

CautionCaution:

This container must already exist.

Schematic Dataset;Schematic Folder
out_name

Name of the schematic diagram to be created.

String
diagram_type
[diagram_type,...]

Schematic diagram template of the schematic diagram to be created.

String
in_data
[in_data,...]
(Optional)

The input data to generate the diagram.

The Input Data parameter specifies the elements on which the diagram generation will be based. It must be specified for most of the predefined schematic builders:

  • For diagram templates that work with the Standard builder configured to operate from a geometric network or network dataset, the Input Data parameter must at least reference a feature layer, feature class, or object table.
  • For diagram templates that work with the Network Dataset builder, the Input Data parameter must reference a unique network analysis layer. If the related network analysis is not performed, Schematics tries to perform it before using the solved analysis layer as input.
  • For diagram templates related to the XML builder, the Input Data parameter is optional when the data for the diagram generation is provided by an external component. But when no external component is defined for the builder properties, the Input Data must reference an XML file. In both cases, the input XML data must be built according to the XMLBuilderDiagram XML Schema file.
  • For diagram templates that work with the Standard builder configured to operate from custom queries, no input data is required.
CautionCaution:

For diagram templates that work with the Standard builder when it is configured to operate from a geometric network or network dataset, XML builder, and Network Dataset builder, if no input data is specified, the diagram cannot be generated.

Table View;Data Element;Layer
builder_options
(Optional)

The schematic builder creation parameters. These parameters are required only for diagrams based on the Network Dataset builder to specify whether nodes will be merged.

  • MERGE_NODESSpecifies the network element junctions, which are taken several times along the resultant route of a route analysis to be represented by a single schematic feature node in the generated schematic diagram. It also allows you to merge midspanjunction elements when they are at the same position in a service area analysis.
  • NO_MERGE_NODESSpecifies that no schematic feature node will be merged (default).
String

Code Sample

CreateDiagram and Standard builder working on geometric network data - Example 1 (Stand-alone Python script)

Create sample schematic diagrams from GIS features organized into a geometric network.

How to run this Python script example:

  1. Start ArcCatalog or ArcMap with a new empty map.
  2. Copy and paste the following script in the Python window.
  3. Press ENTER.

# Name: CreateDiagramStd.py
# Description: Create schematic diagrams sample from GIS features organized into a geometric network
# Requirement: ArcGIS Schematics extension

# import system modules
import arcpy
msgNoLicenseAvailable = "ArcGIS Schematics extension license required"

try:
    # Checks out the ArcGIS Schematics extension license
    if arcpy.CheckExtension("Schematics") == "Available":
        arcpy.CheckOutExtension("Schematics")
    else:
        raise Exception(msgNoLicenseAvailable)

    # Sets Schematics general settings
    dataLocation="C:/ArcGIS/ArcTutor/Schematics/Schematics_In_ArcMap"
    gdbName="ElecDemo.gdb"
    out_schDataset="ElecDemo"
    out_diagAName="FeederDiagram"
    out_diagBName="ElectricMainNetworkDiagram"
    out_diagTempName="GeoSchematic"
    input_FC1="ElectricNetwork/Feeder"
    input_FC2="ElectricNetwork/PrimaryLine"
    input_LayerName="PrimaryLineLayer"
    input_Filter="PHASECODE=135"

    # Sets environment settings
    arcpy.env.overwriteOutput = True
    arcpy.env.workspace = dataLocation + "/" + gdbName

    # CreateDiagram from a feature class, Feeder
    arcpy.CreateDiagram_schematics(out_schDataset, out_diagAName, out_diagTempName, input_FC1)

    # CreateDiagram from a feature layer
    # 1) Creates a layer with the selection
    InputLayer = arcpy.MakeFeatureLayer_management(input_FC2, input_LayerName, input_Filter)
    # 2) Uses the layer as input of CreateDiagram
    arcpy.CreateDiagram_schematics(out_schDataset, out_diagBName, out_diagTempName, InputLayer)

    # Returns the ArcGIS Schematics extension license
    arcpy.CheckInExtension("Schematics")

    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)
CreateDiagram and Network Dataset builder - Example 2 (Stand-alone Python script)

Create sample schematic diagrams from a solved network analysis layer.

How to run this Python script example:

  1. Start ArcMap.
  2. Open the ParisTours.mxd file stored in C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\Network_Dataset.
  3. Click Geoprocessing > Geoprocessing Options.
  4. Uncheck Enable on the Background Processing section, and click OK.
  5. Copy and paste the following script in the Python window.
  6. Press ENTER.

# Name : CreateDiagramNDS.py
# Description : Create a schematic diagram from the network dataset builder
# Requirement: ArcGIS Schematics extension,ArcGIS Network Analyst extension 

# import system modules
import arcpy
msgNoLicenseSchematicsAvailable = "ArcGIS Schematics extension license required"
msgNoLicenseNetworkAnalystAvailable = "ArcGIS Network Analyst extension license required"

try:
    # Checks out the ArcGIS Schematics extension licence
    if arcpy.CheckExtension("Schematics") == "Available":
        arcpy.CheckOutExtension("Schematics")
    else:
        raise Exception(msgNoLicenseSchematicsAvailable)

    # Checks out the ArcGIS Network Analyst extension licence
    if arcpy.CheckExtension("Network") == "Available":
        arcpy.CheckOutExtension("Network")
    else:
        raise Exception(msgNoLicenseNetworkAnalystAvailable)

    # Sets general settings
    dataLocation="C:/ArcGIS/ArcTutor/Schematics/Schematics_Configuration/Network_Dataset"
    gdbName="NetworkAnalyst_Schematics.gdb"
    out_schDataset="NA_SchematicDataset"
    out_diagAName="DiagramTour_MERGED"
    out_diagBName="DiagramTour_NOTMERGED"
    out_diagTempName="NADiagrams"
    in_NALayerName="Routes/Tour1"
    option1="MERGE_NODES"
    option2="NO_MERGE_NODES"

    # Sets environnement settings
    arcpy.env.overwriteOutput = True
    arcpy.env.workspace = dataLocation + "/" + gdbName

    # CreateDiagram from a solved route network analysis layer
    # 1) Solves the route network analysis layer, Tour1
    arcpy.Solve_na(in_NALayerName)
    # 2) Creates diagrams from this solved route network analysis layer
    # a - A diagram where a single node is created to represent a GIS point crossed N times along this route (option1)
    arcpy.CreateDiagram_schematics(out_schDataset, out_diagAName, out_diagTempName, in_NALayerName, option1)
    # b - A diagram where N nodes are created to represent a GIS point crossed N times along this route (option2)
    arcpy.CreateDiagram_schematics(out_schDataset, out_diagBName, out_diagTempName, in_NALayerName, option2)

    # Returns the licences
    arcpy.CheckInExtension("Schematics")
    arcpy.CheckInExtension("Network")

    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)
CreateDiagram and XML builder - Example 3 (Stand-alone Python script)

Create a sample schematic diagram based on the XML builder.

How to run this Python script example:

  1. Start ArcCatalog.
  2. Create and configure the schematic dataset used during the sample script:
    • Navigate to the C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\XML_Data folder in the Catalog tree.
    • Right-click the GISDatabaseForXML geodatabase, point to New, then click Schematic Dataset.
    • Type XMLDataset for the newly created schematic dataset's name, and press ENTER.
    • Right-click the XMLDataset schematic dataset and click Edit.
    • Right-click the XMLDataset entry in the Dataset Editor tree and click New Schematic Diagram Template.
    • Type XMLDiagrams in the Name text box.
    • Choose XML Builder in the Schematic Builder section.
    • Click Schematic Builder Properties, and check Automatic schematic feature class creation.
    • Close the Builder Properties dialog box.
    • Click OK.
    • Click Save on the Schematic Dataset Editor toolbar, and close the Schematic Dataset Editor.
  3. Copy and paste the following script in the ArcCatalog or ArcMap Python window.
  4. Press ENTER.

# Name: CreateDiagramXML.py
# Description: Create a sample schematic diagram based on the XML builder
# Requirement: ArcGIS Schematics extension

# import system modules
import arcpy
msgNoLicenseAvailable = "ArcGIS Schematics extension license required"

try:
    # Checks out the ArcGIS Schematics extension license
    if arcpy.CheckExtension("Schematics") == "Available":
        arcpy.CheckOutExtension("Schematics")
    else:
        raise Exception(msgNoLicenseAvailable)

    # Sets Schematics general settings
    dataLocation="C:/ArcGIS/ArcTutor/Schematics/Schematics_Configuration/XML_Data"
    gdbName="GISDatabaseForXML.gdb"
    out_schDataset="XMLDataset"
    out_diagName="XMLDiagramSample"
    out_diagTempName="XMLDiagrams"
    input_XmlFile="SampleNetworkData.xml"

    # Sets environment settings
    arcpy.env.overwriteOutput = True
    arcpy.env.workspace = dataLocation + "/" + gdbName

    # CreateDiagram from a XML file, SampleNetworkData.xml file
    arcpy.CreateDiagram_schematics(out_schDataset, out_diagName, out_diagTempName, dataLocation + "/" + input_XmlFile)

    # Returns the ArcGIS Schematics extension license
    arcpy.CheckInExtension("Schematics")

    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)
CreateDiagram and Standard builder working from custom queries - Example 4 (Stand-alone Python script)

Create a sample schematic diagram from custom queries.

How to use this Python script example:

  1. Start ArcCatalog.
  2. This script works on a copy of the ElecDemo tutorial geodatabase to avoid overwriting the original inside plant diagram:
    • Navigate to the C:\ArcGIS\ArcTutor\Schematics\Schematics_In_ArcMap folder in the Catalog tree.
    • Copy and paste the ElecDemo geodatabase. The newly created ElecDemo_1 geodatabase is the one on which the script sample is going to process.
  3. Copy and paste the following script in the ArcCatalog or ArcMap Python window.
  4. Press ENTER.ArcGIS Schematics extension

# Name: CreateDiagramCustomQuery.py
# Description: Create a schematic diagram from custom queries
# Requirement: 

# import system modules
import arcpy
msgNoLicenseAvailable = "ArcGIS Schematics extension license required"

try:
    # Checks out the ArcGIS Schematics extension license
    if arcpy.CheckExtension("Schematics") == "Available":
        arcpy.CheckOutExtension("Schematics")
    else:
        raise Exception(msgNoLicenseAvailable)

    # Sets Schematics general settings
    dataLocation="C:/ArcGIS/ArcTutor/Schematics/Schematics_In_ArcMap"
    gdbName="ElecDemo_1.gdb"
    out_schDataset="ElecDemo"
    out_schFolder="Inside Plants"
    out_diagName="Substation 08"
    out_diagTempName="InsidePlants"

    # Sets environment settings
    arcpy.env.overwriteOutput = True
    arcpy.env.workspace = dataLocation + "/" + gdbName

    # CreateDiagram from a diagram template configured from custom queries
    arcpy.CreateDiagram_schematics(out_schDataset + "/" + out_schFolder, out_diagName, out_diagTempName)

    # Returns the ArcGIS Schematics extension license
    arcpy.CheckInExtension("Schematics")

    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Schematics
ArcGIS for Desktop Standard: Requires Schematics
ArcGIS for Desktop Advanced: Requires Schematics
3/4/2014