Multipatch To Collada (Conversion)

License Level:BasicStandardAdvanced

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

Syntax

MultipatchToCollada_conversion (in_features, output_folder, {prepend_source}, {field_name})
ParameterExplanationData 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
import exceptions, sys, traceback
from arcpy import env

# Script variables
inWorkspace = arcpy.GetParameterAsText(0)

try:
    # Set environment settings
    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)
        
except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
          .format(tbinfo, str(sys.exc_info()[1]))
    msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
10/24/2012