多面体转 Collada (转换)

许可等级:BasicStandardAdvanced

摘要

将一个或多个多面体要素转换为 COLLADA (.dae) 文件及其引用的纹理图像文件的集合并将此集合存储在输出文件夹中。输入可以是图层或要素类。

用法

语法

MultipatchToCollada_conversion (in_features, output_folder, {prepend_source}, {field_name})
参数说明数据类型
in_features

要导出的多面体要素。

Feature Layer
output_folder

放置输出 COLLADA 文件和纹理图像文件的目标文件夹。

Folder
prepend_source
(可选)

将源要素图层的名称添加为输出 COLLADA 文件的文件名的前缀。

  • PREPEND_SOURCE_NAME添加文件名前缀。
  • PREPEND_NONE不添加文件名前缀。这是默认设置。
Boolean
field_name
(可选)

用作每个导出的要素的输出 COLLADA 文件名的要素属性。如果未指定字段,则使用要素的“对象 ID”。

Field

代码实例

多面体转 COLLADA (MultipatchToCollada) 示例 1(Python 窗口)

下面的示例演示了如何在 Python 窗口中使用此工具:

import arcpy
from arcpy import env

env.workspace = "C:/data"
arcpy.MultipatchToCollada_conversion("Sample.gdb/Buildings", "C:/COLLADA", 
                                   "PREPEND_SOURCE_NAME", "BldName")
多面体转 COLLADA (MultipatchToCollada) 示例 2(独立脚本)

下面的示例演示了如何在独立 Python 脚本中使用此工具:

'''*********************************************************************
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)

环境

此工具不使用任何地理处理环境

相关主题

许可信息

ArcGIS for Desktop Basic: 是
ArcGIS for Desktop Standard: 是
ArcGIS for Desktop Advanced: 是
5/10/2014