Convert Diagram To Features (Schematics)

Summary

This tool converts a schematic diagram to feature classes or shapefiles.

It allows exporting of several diagrams either in the same feature classes/shapefiles (one feature class/shapefile per schematic feature class) or in different feature classes/shapefiles per diagram (one feature class/shapefile per schematic feature class and per diagram).

NoteNote:

See the Script example section for a sample use of this tool that allows you to export all diagrams contained in a schematic dataset into features.

Usage

Syntax

ConvertDiagram_schematics (in_diagram, out_location, {reuse_fc}, {export_related_attributes}, {container_geometry}, {config_keyword})
ParameterExplanationData Type
in_diagram

The schematic diagram to be converted.

Schematic diagram
out_location

Workspace, feature dataset, or folder in which the schematic diagram will be converted. This container must already exist.

Workspace;Feature dataset;Folder
reuse_fc
(Optional)

Indicates whether the input schematic diagram will be exported in the same feature classes/shapefiles as the other diagrams based on the same diagram template.

  • REUSE_FCMust be used to export several diagrams implemented by the same diagram template in the same feature classes/shapefiles. Exports the specified diagram in feature classes/shapefiles contained in a feature dataset/folder whose name corresponds to the diagram template name, each feature class/shapefile name corresponding to the name of a schematic feature class associated with the diagram template. This is the default.
  • NO_REUSE_FCExports the diagram in new feature classes/shapefiles created in a feature dataset/folder whose name is the concatenation of the exported diagram's diagram template name and the diagram name, each feature class/shapefile name being the concatenation of the schematic feature class name and diagram name.
String
export_related_attributes
(Optional)

Indicates whether all the attributes stored in the feature classes/object tables associated with the schematic feature classes contained in the export diagram will be also exported.

  • NO_RELATED_ATTRIBUTESEach schematic feature contained in the input diagram is exported with only the attributes contained in its schematic feature class. This is the default.
  • EXPORT_RELATED_ATTRIBUTESEach schematic feature contained in the input diagram is exported with the attributes contained in its schematic feature class and all the attributes related to its associated real feature that are stored in the associated feature class/object table.
NoteNote:

If no associated feature class/table is specified for a schematic feature class, no feature attributes can be exported.

NoteNote:

When using the Reuse Existing Structure option and the structure already exists without the associated feature fields, enabling this option will have no effect.

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

Indicates the geometry type of the features that will be created for the exported schematic containers contained in the input diagram.

  • POLYGONEach container in the input diagram is exported as a polygon feature. This is the default.
  • POLYLINEEach container in the input diagram is exported as a polyline feature.
  • POINTEach container in the input diagram is exported as a point feature.
NoteNote:

When using the Reuse Existing Structure option and the structure already exists with POLYGON (POLYLINE or POINT) feature classes created for container schematic features, there is no way to change the feature class type to POLYLINE or POINT (POLYGON) for the next conversions.

String
config_keyword
(Optional)

The configuration keyword that determines the storage parameters of the table in a relational database management system (RDBMS)This is for ArcSDE only.

String

Code Sample

Sample script with the ConvertDiagram GP tool

The following script allows you to loop on all diagrams contained in a schematic container—that is, a schematic dataset or schematic folder—and converts them to features in an output location.

How to use this scripting example:

  1. Copy the following script in any text editor and save the text file with the .py extension.
  2. Start ArcCatalog and open the ArcToolbox window.
  3. Add a new script:
    • Type a name for it (ConvertDiagramsTool, for example).
    • For the Script File parameter, specify the .py file you have just created.
    • Then specify the five following parameters:
      1. Display Name: Input Schematic Container, Data Type: Schematic Dataset or Schematic Folder; Type Property=Required, Direction Property=Input
      2. Display Name: Output Location, Data Type: Workspace or Feature Dataset; Type Property=Required, Direction Property=Input
      3. Display Name: Recursive, Data Type: Boolean; Type Property=Required, Direction Property=Input, Default Value=True
      4. Display Name: Diagram Class Filter, Data Type: String; Type Property=Optional, Direction Property=Input
      5. Display Name: Derived Output Location, Data Type: Workspace or Feature Dataset; Type Property=Derived, Direction Property=Output, Obtained from=Output_Location

Required input parameters: An input schematic container (dataset or folder) + an output location (GDB, feature dataset, or folder for shapefiles)

Optional arguments: A recursive flag + adiagram class filter

Output derived location: A workspace or feature dataset

# Name: ConvertDiagrams.py
# Description: Convert schematic diagrams
# Author: ESRI

# import arcpy, sys, math
msgInputsErr = "Invalid arguments."
msgParseErr = "Cannot parse input arguments."
msgConvertErr = "Error during conversion."

msgNoLicenseAvailable = "Schematics license required"

# Search schematic diagrams recursively in the folders
# list 'pathList'  stores the result
	def RecursiveSearch(inCont, bRecursive):
		try:
			childs = inCont.Children
			dataset = childs.Next()
			while dataset:
				if dataset.DataType == "SchematicFolder" and bRecursive:
					RecursiveSearch(dataset, bRecursive)
				elif dataset.DataType == "SchematicDiagram":
					if diagramClassFilter == "" or diagramClassFilter == dataset.DiagramClassname:
						pathList.append(dataset.CatalogPath)
				dataset = childs.next()
		except:
			raise
	
try:
		if arcpy.CheckExtension("Schematics1") == "Available":
			arcpy.CheckOutExtension("Schematics")
		else:
			raise Exception(msgNoLicenseAvailable)
except Exception as exc:
		print exc
		raise

arcpy.OverWriteOutput = True

# Decode parameters
try:
	inputContainer = arcpy.GetParameterAsText(0) 
	outputLocation = arcpy.GetParameterAsText(1) 
	recursive = arcpy.GetParameterAsText(2)
	if recursive == "false":
		recursive = None
	diagramClassFilter = arcpy.GetParameterAsText(3)

	if inputContainer == "":
		raise Exception()

except:
	print msgParseErr
	arcpy.AddError(msgParseErr)
	raise

# Main 
try:
	pathList = []   # List for diagram names to convert
	arcpy.SetProgressorLabel("Searching diagrams to convert...")
	RecursiveSearch(arcpy.Describe(inputContainer), recursive)

	arcpy.SetProgressor("step", "Converting...", 0, len(pathList), 1)

	for path in pathList:
		# Execute convert	
		mes = "Converting Schematic Diagram : " + path
		# Set the progressor label
		arcpy.SetProgressorLabel(mes)
		arcpy.AddMessage(mes)
		arcpy.ConvertDiagram_schematics(path, outputLocation, "REUSE_FC", "NO_RELATED_ATTRIBUTES", "#")
		arcpy.SetProgressorPosition()

except:
	arcpy.AddError(msgConvertErr)
	raise

Environments

Related Topics

Licensing Information

ArcView: Requires Schematics
ArcEditor: Requires Schematics
ArcInfo: Requires Schematics

11/18/2010