Resumen
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.
Uso
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.
Sintaxis
CreateDiagram(out_location, out_name, diagram_type, {in_data}, {builder_options})
Parámetro | Explicación | Tipo de datos |
out_location | Schematic dataset or schematic folder in which the diagram will be created. | Schematic Dataset;Schematic Folder |
out_name | Name of the schematic diagram to be created. | String |
diagram_type | Schematic diagram template of the schematic diagram to be created. | String |
in_data [in_data,...] (Opcional) | 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:
| Table View;Data Element;Layer |
builder_options (Opcional) | 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 |
Muestra de código
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:
- 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: Extensión ArcGIS Schematics
# import system modules
import arcpy
msgNoLicenseAvailable = "Extensión ArcGIS Schematics license required"
try:
# Checks out the Extensión ArcGIS Schematics 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 Extensión ArcGIS Schematics 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:
- 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: Extensión ArcGIS Schematics,Extensión ArcGIS Network Analyst
# import system modules
import arcpy
msgNoLicenseSchematicsAvailable = "Extensión ArcGIS Schematics license required"
msgNoLicenseNetworkAnalystAvailable = "Extensión ArcGIS Network Analyst license required"
try:
# Checks out the Extensión ArcGIS Schematics licence
if arcpy.CheckExtension("Schematics") == "Available":
arcpy.CheckOutExtension("Schematics")
else:
raise Exception(msgNoLicenseSchematicsAvailable)
# Checks out the Extensión ArcGIS Network Analyst 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:
- 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: Extensión ArcGIS Schematics
# import system modules
import arcpy
msgNoLicenseAvailable = "Extensión ArcGIS Schematics license required"
try:
# Checks out the Extensión ArcGIS Schematics 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 Extensión ArcGIS Schematics 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:
- 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.Extensión ArcGIS Schematics
# Name: CreateDiagramCustomQuery.py
# Description: Create a schematic diagram from custom queries
# Requirement:
# import system modules
import arcpy
msgNoLicenseAvailable = "Extensión ArcGIS Schematics license required"
try:
# Checks out the Extensión ArcGIS Schematics 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 Extensión ArcGIS Schematics 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)
Entornos
Información sobre licencias
- Basic: Requiere Schematics
- Standard: Requiere Schematics
- Advanced: Requiere Schematics