Civil 3D 2013利用API把三角网曲面提取为栅格网

简介:


Civil 3D 2013中对曲面的.net API做了增强,可以让我们从三角网曲面中提取栅格网。先看看效果:

image

 

下面的代码演示了从一个三角网曲面中提取三维栅格网,这些栅格网是由红色是三维多段线polyline构成的。

//
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil;

// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(SurfaceApiInCivil3D2013.MyCommands))]

namespace SurfaceApiInCivil3D2013
{

    // This class is instantiated by AutoCAD for each document when
    // a command is called by the user the first time in the context
    // of a given document. In other words, non static data in this class
    // is implicitly per-document!
    public class MyCommands
    {
        static Document _doc = Application.DocumentManager.MdiActiveDocument;
        static Editor _editor = _doc.Editor;
        static Database db = _doc.Database;

        private ObjectId promptForTinSurface()
        {
            PromptEntityOptions options = new PromptEntityOptions(
                "\nSelect a TIN Surface: ");
            options.SetRejectMessage(
                "\nThe selected object is not a TIN Surface.");
            options.AddAllowedClass(typeof(TinSurface), true);

            PromptEntityResult result = _editor.GetEntity(options);
            if (result.Status == PromptStatus.OK)
            {
                // Everything is cool; we return the selected
                // surface ObjectId.
                return result.ObjectId;
            }
            return ObjectId.Null;   // Indicating error.
        }

        [CommandMethod("CDS_ExtractGrid")]
        public void CDS_ExtractGrid()
        {
            ObjectId surfaceId = promptForTinSurface();
            if (surfaceId == ObjectId.Null)
            {
                _editor.WriteMessage("\nNo TIN Surface selected.");
                return;
            }

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                TinSurface surface = surfaceId.GetObject(OpenMode.ForRead)
                    as TinSurface;
                ObjectIdCollection ids = surface.ExtractGridded(
                    SurfaceExtractionSettingsType.Model);

                foreach (ObjectId id in ids)
                {
                    Polyline3d polyline =
                        id.GetObject(OpenMode.ForWrite) as Polyline3d;
                    if (polyline != null)
                    {
                        using (polyline)
                        {
                            polyline.Color =
                                Autodesk.AutoCAD.Colors.Color.FromRgb(255, 0, 0);
                        }
                    }
                }
                tr.Commit();
            }
        }


    }

}
 
想了解更多Civil 3D 2013 API,请看Civilized Development博客中的21WOJP系列 (21 Week Of JayPeak), JayPeak是Civil 3D 2013的代码名。
作者: 峻祁连
邮箱:junqilian@163.com 
出处: http://junqilian.cnblogs.com 
转载请保留此信息。


本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2013/02/22/2922020.html ,如需转载请自行联系原作者
目录
打赏
0
0
0
0
23
分享
相关文章
|
10月前
|
【Unity 3D】常见API的讲解以及在C#脚本中的执行(附源码)
【Unity 3D】常见API的讲解以及在C#脚本中的执行(附源码)
218 1
Vue 集成腾讯地图基础api Demo集合(基础地图引入与展示模块,地址逆解析,3D/2D切换 ,位置服务,mark标记)
Vue 集成腾讯地图基础api Demo集合(基础地图引入与展示模块,地址逆解析,3D/2D切换 ,位置服务,mark标记)
1012 0
Vue 集成腾讯地图基础api  Demo集合(基础地图引入与展示模块,地址逆解析,3D/2D切换 ,位置服务,mark标记)
3D Real 开发者工具 API threed-real-sdk.js
GitHub:https://github.com/BaiFeng3DREAL/threed-real-viewer详情:https://www.3dreal.com 用途 3D Real 开发者工具,可以帮助您开发自己的三维产品展示页面,提供了高度自定义的接口。
ArcGIS API for JavaScript4.x 之加载2D、3D地图
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gisdoer/article/details/81545607 ArcGIS AP...
1546 0
[UWP-小白日记16]UWP中的3D变换API
原文:[UWP-小白日记16]UWP中的3D变换API 还没开始   好久没写博客了,再来开坑。 正文   Transform3D:“这个和CSS的3D好像的说”   PerspectiveTransform3D:这个用来指定容器是否具有3D空间,都是放在根容器下面的。
1252 0
速卖通商品详情接口(速卖通API系列)
速卖通(AliExpress)是阿里巴巴旗下的跨境电商平台,提供丰富的商品数据。通过速卖通开放平台(AliExpress Open API),开发者可获取商品详情、订单管理等数据。主要功能包括商品搜索、商品详情、订单管理和数据报告。商品详情接口aliexpress.affiliate.productdetail.get用于获取商品标题、价格、图片等详细信息。开发者需注册账号并创建应用以获取App Key和App Secret,使用PHP等语言调用API。该接口支持多种请求参数和返回字段,方便集成到各类电商应用中。
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
57 5
以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
淘宝拍立淘按图搜索API接口系列的应用与数据解析
淘宝拍立淘按图搜索API接口是阿里巴巴旗下淘宝平台提供的一项基于图像识别技术的创新服务。以下是对该接口系列的应用与数据解析的详细分析

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等