Multipatch To Collada (Conversion)

Summary

Converts one or more multipatch features into a collection of COLLADA (.dae) 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 file names. 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 the same directory as the COLLADA file. To minimize the total export file size, textures that are used in multiple COLLADA files—such as a repeated brick or window texture—are only exported once and then referenced by the applicable DAE files.

  • This tool automatically overwrites any existing COLLADA files with the same file name. 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 file name 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.

    Tip:

    When converting multipatches from a layer, the Multipatch to COLLADA tool will automatically embed any colors defined in the layer's renderer. For example, if the layer is rendering features based on a use-type attribute—such as red for commercial, blue for residential, and so on—then these colors will be included in the output COLLADA files. The displayed color is applied to both textured and untextured multipatch features, with the former requiring an update to the feature's underlying texture files. You can use a single display color of white to export textured multipatches with unaltered images.

Parameters

LabelExplanationData Type
Input Multipatch Features

The multipatch features to be exported.

Feature Layer
Output Collada Folder

The destination folder where the output COLLADA files and texture image files will be placed.

Folder
Prepend Source Name
(Optional)

Prepend the file names of the output COLLADA files with the name of the source feature layer.

  • Checked—Prepend the file names.
  • Unchecked—Do not prepend the file names. This is the default.

Boolean
Use Field Name
(Optional)

The feature attribute to use as the output COLLADA file name for each exported feature. If no field is specified, the feature's Object ID is used.

Field

arcpy.conversion.MultipatchToCollada(in_features, output_folder, {prepend_source}, {field_name})
NameExplanationData 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.

  • PREPEND_SOURCE_NAMEPrepend the file names.
  • PREPEND_NONEDo not prepend the file names. This is the default.
Boolean
field_name
(Optional)

The feature attribute to use as the output COLLADA file name for each exported feature. If no field is specified, the feature's Object ID is used.

Field

Code sample

MultipatchToCollada example 1 (Python window)

The following sample demonstrates the use of this tool in the Python window.

import arcpy
from arcpy import env

env.workspace = "C:/data"
arcpy.MultipatchToCollada_conversion("Sample.gdb/Buildings", "C:/COLLADA", 
                                   "PREPEND_SOURCE_NAME", "BldName")
MultipatchToCollada example 2 (stand-alone script)

The following sample demonstrates the use of this tool in a stand-alone Python script.

'''*********************************************************************
Name: Convert Multipatch To Collada
Description: Converts multipatch features in an input workspace 
             to a Collada model.
*********************************************************************'''
# Import system modules
import arcpy

# Script variables
inWorkspace = arcpy.GetParameterAsText(0)

# Set environment settings
arcpy.env.workspace = inWorkspace
# Create list of feature classes in workspace
fcList = arcpy.ListFeatureClasses()
# Determine if the list contained any feature classes
if fcList:
    # 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':
           # 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 = 'OID'
           #Execute MultipatchToCollada
           arcpy.MultipatchToCollada(fc, outDir, prepend, fldName)
else:
    print('There are no feature classes in {0}.'.format(inWorkspace))

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics