ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

导入 3D 文件

  • 描述
  • 使用方法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

描述

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

使用方法

  • 通过在地理数据库中存储输出多面体保留 3D 模型的纹理。Shapefile 不支持保留纹理。

  • 如果生成的多面体要素的顶侧定向到侧面,可再次使用此工具通过启用 Y_Is_Up 参数来尝试调整方向。

  • GeoVRML 是唯一拥有已定义坐标系的格式。使用局部坐标系(XYZ 轴坐标中心定义在 0,0,0 处)可生成多种 3D 模型。可采用以下方法之一将此类要素配准到实际坐标:

    • 如果需要旋转和平移 3D 模型,可以考虑执行空间校正技术来正确定位要素。了解有关空间校正的详细信息。
    • 如果 3D 模型在给定坐标系中已正确定向,且仅需平移至正确位置,可考虑自定义坐标系属性来进行所需的平移。如果可以获得用来定义实际坐标中每个模型的质心位置的点要素,则可考虑使用导入 3D 文件工具直接输入这些点以校准模型。
  • 3D 文件中可能存在的点几何和线几何在输出多面体要素类中不会保留,因为多面体不支持它们。

    注:

    VRML 文件不支持的几何类型包括方框、圆锥、圆柱、拉伸、点集、球体和文本。

语法

arcpy.ddd.Import3DFiles(in_files, out_featureClass, {root_per_feature}, {spatial_reference}, {y_is_up}, file_suffix, {in_featureClass}, {symbol_field})
参数说明数据类型
in_files
[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

从输入文件夹导入的文件的文件扩展名。将至少一个文件夹指定为输入时,此参数为必填项。

  • * —所有受支持的文件。这是默认设置。
  • 3DS —3D Studio Max
  • WRL —VRML 或 GeoVRML
  • SKP —SketchUp
  • FLT —OpenFlight
  • DAE —Collada
String
in_featureClass
(可选)

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

Feature Layer
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)

环境

  • 当前工作空间
  • 输出坐标系
  • 输出 XY 属性域
  • 输出 Z 属性域
  • 自动提交
  • 输出配置关键字

许可信息

  • Basic: 需要 3D Analyst
  • Standard: 需要 3D Analyst
  • Advanced: 需要 3D Analyst

相关主题

  • 转换工具集概述
  • 有关使用 ArcGIS 3D Analyst 扩展模块进行地理处理的基础知识
  • 多面体 (Multipatch)
  • 根据模型创建带纹理的建筑物

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明