导入 3D 文件 (3D Analyst)

许可等级:BasicStandardAdvanced

摘要

将一个或多个 3D 模型导入到多面体要素类。

用法

语法

Import3DFiles_3d (in_files, out_featureClass, {root_per_feature}, {spatial_reference}, {y_is_up}, {file_suffix}, {in_featureClass}, {symbol_field})
参数说明数据类型
in_files

一个或多个 3D 模型或文件夹,支持的文件格式包括 3D Studio Max (*.3ds)、SketchUp (*.skp)、VRML 和 GeoVRML (*.wrl)、OpenFlight (*.flt) 和 COLLADA (*.dae)。

File; Folder
out_featureClass

从输入文件中创建的多面体。

Feature Class
root_per_feature
(可选)

指明是为每个文件生成一个要素还是为文件中的每个根结点生成一个要素。此选项仅适用于 VRML 模型。

  • ONE_ROOT_ONE_FEATURE生成的输出将为文件中的每个根结点包含一个要素。
  • ONE_FILE_ONE_FEATURE生成的输出将为每个文件包含一个要素。这是默认设置。
Boolean
spatial_reference
(可选)

输入数据的坐标系。对于大多数格式来说,这是未知的。只有 GeoVRML 格式存储其坐标系,其默认值将从列表中的第一个文件获得,除非在此处指定一个空间参考。

Spatial Reference
y_is_up
(可选)

标识定义输入文件垂直方向的轴。

  • Z_IS_UP指示 z 是向上的。这是默认设置。
  • Y_IS_UP指示 y 是向上的。
Boolean
file_suffix
(可选)

从输入文件夹导入的文件的后缀。将文件夹指定为输入时,此参数为必填项。

String
in_featureClass
(可选)

其坐标定义输入文件实际位置的点要素。每个输入文件将与基于符号字段中存储的文件名的对应点相匹配。应将坐标系参数定义为与点的空间参考相匹配。

Feature Class
symbol_field
(可选)

点要素中的字段,包含与各点相关联的 3D 文件的名称。

Field

代码实例

导入 3D 文件 (Import3DFiles) 示例 1(Python 窗口)

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

import arcpy
from arcpy import env

arcpy.CheckOutExtension("3D")
env.workspace = "C:/data"
arcpy.Import3DFiles_3d("AddisSheraton.skp", "Test.gdb/AddisSheraton", False, "", False)
导入 3D 文件 (Import3DFiles) 示例 2(独立脚本)

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

'''*********************************************************************
Name: Model Shadows For GeoVRML Models
Description: Creates a model of the shadows cast by GeoVRML models 
             imported to a multipatch feature class for a range of dates
             and times. A range of times from the start time and end 
             time can also be specified by setting the EnforceTimes 
             Boolean to True. This sample is designed to be used in a 
             script tool.
*********************************************************************'''
# Import system modules
import arcpy
from datetime import datetime, time, timedelta

#*************************  Script Variables  **************************
inFiles = arcpy.GetParameterAsText(0) # list of input features
spatialRef = arcpy.GetParameterAsText(1) # list of GeoVRML files
outFC = arcpy.GetParameterAsText(2) # multipatch from 3D files
inTimeZone = arcpy.GetParameterAsText(3) # time zone
startDate = arcpy.GetParameter(4) # starting date as datetime
endDate = arcpy.GetParameter(5) # ending date as datetime
dayInterval = arcpy.GetParameter(6) # day interval as long (0-365)
minInterval = arcpy.GetParameter(7) # minute interval as long (0-60)
enforceTime = arcpy.GetParameter(8) # minute interval as Boolean
outShadows = arcpy.GetParameterAsText(9) # output shadow models
outIntersection = arcpy.GetParameterAsText(10) # shadow & bldg intersection

# Function to find all possible date/time intervals for shadow modelling
def time_list():
    dt_result = [startDate]
    if dayInterval:
        if endDate: #Defines behavior when end date is supplied
            while startDate < endDate:
                startDate += timedelta(days=dayInterval)
                dt_result.append(startDate)
            dt_result.append(endDate)
        else: # Behavior when end date is not given
            daymonthyear = datetime.date(startDate)
            while startDate <= datetime(daymonthyear.year, 12, 31, 23, 59):
                startDate += timedelta(days=dayInterval)
                dt_result.append(startDate)
    return dt_result

try:
    arcpy.CheckOutExtension('3D')
    importFC = arcpy.CreateUniqueName('geovrml_import', 'in_memory')
    # Import GeoVRML files to in-memory feature
    arcpy.ddd.Import3DFiles(inFiles, importFC, 'ONE_FILE_ONE_FEATURE', 
                            spatialRef, 'Z_IS_UP', 'wrl')
    # Ensure that building models are closed
    arcpy.ddd.EncloseMultiPatch(importFC, outFC, 0.05)
    # Discard in-memory feature
    arcpy.management.Delete(importFC)
    dt_result = time_list()
    for dt in dt_result:
        if dt == dt_result[0]:
            shadows = outShadows
        else:
            shadows = arcpy.CreateUniqueName('shadow', 'in_memory')
        arcpy.ddd.SunShadowVolume(outFC, dt, shadows, 'ADJUST_FOR_DST', 
                                  inTimeZone, '', minInterval, 'MINUTES')
        if dt is not dt_result[0]:
            arcpy.management.Append(shadows, outShadows)
            arcpy.management.Delete(shadows)
    arcpy.ddd.Intersect3D(outFC, outIntersection, outShadows, 'SOLID')
    arcpy.CheckInExtension('3D')
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:需要 3D Analyst
ArcGIS for Desktop Standard:需要 3D Analyst
ArcGIS for Desktop Advanced:需要 3D Analyst
9/15/2013