Multipatch To Collada (Conversion)
Summary
Converts one or more multipatch features into a collection of COLLADA files and referenced texture image files in an output folder. The inputs can be a layer or a feature class.
Usage
-
COLLADA files are an XML representation of a 3D object that can reference additional image files that act as textures draped onto the 3D geometry. This means that exporting a multipatch feature to COLLADA can result in the creation of several files—a .dae file containing the XML representation of the 3D object and one or more image files (for example, a .jpg or .png file) that contain the textures.
This tool creates one COLLADA representation for each multipatch feature that it exports. The tool uses a field value from each feature—by default this is the Object ID—to define the output filenames. This allows easier identification of which feature was exported to which COLLADA file and also provides the methodology for defining unique names when exporting multiple features to the same directory. Texture files are stored in an images subdirectory, below the COLLADA file.
This tool automatically overwrites any existing COLLADA files with the same filename. When this happens, a warning message is given stating which files were overwritten with a new file during the export process. A GP message is also generated for any features that fail to export—for example, if the output location is read-only, or the disk is full.
To ensure a new COLLADA file is created for all the exported multipatch features, set the destination directory to an empty or new folder and choose a filename field that is unique for each feature. Exporting two features with the same attribute value will result in the second exported feature overwriting the COLLADA file of the first.
When iteratively updating a multipatch feature by exporting it to COLLADA and making changes outside of ArcGIS, export the feature to the same location each time. This will keep a single file on disk for that feature, representing the most up-to-date state of the 3D object.
If the exported multipatch is in a projected coordinate system, such as a building stored in a UTM zone, then a KML file containing the coordinates as WGS84 will also be created in the output folder. Note that this process will not use a datum transformation, which may result in positional discrepancies when viewing the KML.
Syntax
Parameter | Explanation | Data Type |
in_features |
The multipatch features to be exported. | Feature Layer |
output_folder |
The destination folder where the output COLLADA files and texture image files will be placed. | Folder |
prepend_source (Optional) | Prepend the file names of the output COLLADA files with the name of the source feature layer.
| Boolean |
field_name |
The feature attribute to use as the output COLLADA filename for each exported feature. If no field is specified, the feature's Object ID is used. | String |
Code Sample
The following Python window script demonstrates how to use the MultipatchToCollada function in immediate mode.
import arcpy from arcpy import env env.workspace = "C:/data" arcpy.MultipatchToCollada_conversion("Buildings","C:/COLLADA", PREPEND_SOURCE_NAME, "BldName")
The following stand-alone script demonstrates how to use the MultipatchToCollada function.
# Name: MultipatchToCollada_Example2.py # Description: The following stand-alone script demonstrates how to use the # MultipatchToCollada tool to convert all multipatch shapefiles # in a target workspace. # Requirements: 3D Analyst extension # Author: ESRI # Import system modules import arcpy from arcpy import env # Obtain a license for the 3D Analyst extension arcpy.CheckOutExtension("3D") # Set environment settings env.workspace = "C:/data" try: # Create list of feature classes in workspace fcList = arcpy.ListFeatureClasses() # Determine if the list contained any feature classes if len(fcList) > 0: # Iterate through each feature class for fc in fcList: # Describe the feature class desc = arcpy.Describe(fc) # Determine if feature class is a multipatch if desc.shapeType is "MultiPatch": # Set Local Variables ## Ensure unique name for output folder outDir = arcpy.CreateUniqueName("collada_dir") ## Specify that collada file is prefixed by source name prepend = "PREPEND_SOURCE_NAME" ## Specify the feature attribute used to name Collada files fldName = "Name" #Execute MultipatchToCollada arcpy.MultipatchToCollada(fc, outDir, prepend, fldName) del outDir, prepend, fldName else: print "There are no multipatch shapefiles in " + env.workspace + "." else: print "There are no feature classes in " + env.workspace + "." except Exception as e: # Returns any other error messages print arcpy.GetMessages(2) del arcpy