Create Diagram (Schematics)
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
-
If the output schematic diagram name already exists, it may be deleted before being re-created. To avoid this deletion, you can uncheck the Overwrite the outputs of geoprocessing operations box from the Geoprocessing Options dialog box.
-
Depending on the schematic builder related to the diagram template specified for the diagram to be created, the Input Data parameter is required or not:
- For a diagram template based on the Standard builder when it is configured to operate from a geometric network or a network dataset, the parameter is mandatory. The specified input tables may be feature layers, feature classes, or object tables.
- For a diagram template based on the Network Dataset builder, a unique network analysis layer must be specified for the Input Data parameter.
- For a diagram template based on the XML builder, a unique XML file must be specified for the Input Data parameter.
- For a diagram template based on the Standard builder when it is configured to operate from custom queries, no input data is expected.
Syntax
Parameter | Explanation | Data Type |
out_location |
Schematic dataset or schematic folder in which the diagram will be created. Caution: 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:
Caution: 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.
| String |
Code Sample
Create sample schematic diagrams from GIS features organized into a geometric network.
How to run this Python script example:
- Start ArcCatalog or ArcMap with a new empty map.
- Copy and paste the following script in the Python window.
- 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 environment settings
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\ArcGIS\ArcTutor\Schematics\Schematics_In_ArcMap\ElecDemo.gdb"
# CreateDiagram from a feature class, Feeder
arcpy.CreateDiagram_schematics("ElecDemo", "FeederDiagram", "GeoSchematic", "ElectricNetwork\Feeder")
# CreateDiagram from a feature layer
# 1) Creates a layer with the selection
InputLayer = arcpy.MakeFeatureLayer_management("ElectricNetwork\PrimaryLine","PrimaryLineLayer", "PHASECODE =135")
# 2) Uses the layer as input of CreateDiagram
arcpy.CreateDiagram_schematics("ElecDemo", "ElectricMainNetworkDiagram", "GeoSchematic", 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)
Create sample schematic diagrams from a solved network analysis layer.
How to run this Python script example:
- Start ArcMap.
- Open the ParisTours.mxd file stored in C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\Network_Dataset.
- Click Geoprocessing > Geoprocessing Options.
- Uncheck Enable on the Background Processing section, and click OK.
- Copy and paste the following script in the Python window.
- 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 environnement settings
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\Network_Dataset\NetworkAnalyst_Schematics.gdb"
# CreateDiagram from a solved route network analysis layer
# 1) Solves the route network analysis layer, Tour1
arcpy.Solve_na("Routes\Tour1")
# 2) Creates diagrams from this solved route network analysis layer
# a - DiagramTour_MERGED diagram, where a single schematic feature node is created to represent a network junction which is crossed N times along the resultant route (MERGE_NODES option)
arcpy.CreateDiagram_schematics("NA_SchematicDataset", "DiagramTour_MERGED", "NADiagrams", "Routes\Tour1", "MERGE_NODES")
# b - DiagramTour_NOTMERGED diagram, where N schematic nodes are created to represent a network junction which is crossed N times along the resultant route (NOT_MERGE_NODES option)
arcpy.CreateDiagram_schematics("NA_SchematicDataset", "DiagramTour_NOTMERGED", "NADiagrams", "Routes\Tour1", "NO_MERGE_NODES")
# 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)
Create a sample schematic diagram based on the XML builder.
How to run this Python script example:
- Start ArcCatalog.
- 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.
- Copy and paste the following script in the ArcCatalog or ArcMap Python window.
- 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 environment settings
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\XML_Data\GISDatabaseForXML.gdb"
# CreateDiagram from a XML file, SampleNetworkData.xml file
arcpy.CreateDiagram_schematics("XMLDataset", "XMLDiagramSample", "XMLDiagrams", "C:\ArcGIS\ArcTutor\Schematics\Schematics_Configuration\XML_Data\SampleNetworkData.xml")
# 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)
Create a sample schematic diagram from custom queries.
How to use this Python script example:
- Start ArcCatalog.
- 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.
- Copy and paste the following script in the ArcCatalog or ArcMap Python window.
- Press ENTER.
# Name: CreateDiagramCustomQuery.py
# Description: Create a schematic diagram from custom queries
# 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 environment settings
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\ArcGIS\ArcTutor\Schematics\Schematics_In_ArcMap\ElecDemo_1.gdb"
# CreateDiagram from a diagram template, InsidePlants, which is configured to generate diagrams from custom queries
arcpy.CreateDiagram_schematics("ElecDemo\Inside Plants", "Substation 08", "InsidePlants")
# 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)