Civil 3D 2013利用API把三角网曲面提取为栅格网
2013-02-22 11:43
288 查看
Civil3D2013中对曲面的.netAPI做了增强,可以让我们从三角网曲面中提取栅格网。先看看效果:
下面的代码演示了从一个三角网曲面中提取三维栅格网,这些栅格网是由红色是三维多段线polyline构成的。
.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}
下面的代码演示了从一个三角网曲面中提取三维栅格网,这些栅格网是由红色是三维多段线polyline构成的。
// usingSystem; usingAutodesk.AutoCAD.Runtime; usingAutodesk.AutoCAD.ApplicationServices; usingAutodesk.AutoCAD.DatabaseServices; usingAutodesk.AutoCAD.Geometry; usingAutodesk.AutoCAD.EditorInput; usingAutodesk.Civil.DatabaseServices; usingAutodesk.Civil; //Thislineisnotmandatory,butimprovesloadingperformances [assembly:CommandClass(typeof(SurfaceApiInCivil3D2013.MyCommands))] namespaceSurfaceApiInCivil3D2013 { //ThisclassisinstantiatedbyAutoCADforeachdocumentwhen //acommandiscalledbytheuserthefirsttimeinthecontext //ofagivendocument.Inotherwords,nonstaticdatainthisclass //isimplicitlyper-document! publicclassMyCommands { staticDocument_doc=Application.DocumentManager.MdiActiveDocument; staticEditor_editor=_doc.Editor; staticDatabasedb=_doc.Database; privateObjectIdpromptForTinSurface() { PromptEntityOptionsoptions=newPromptEntityOptions( "\nSelectaTINSurface:"); options.SetRejectMessage( "\nTheselectedobjectisnotaTINSurface."); options.AddAllowedClass(typeof(TinSurface),true); PromptEntityResultresult=_editor.GetEntity(options); if(result.Status==PromptStatus.OK) { //Everythingiscool;wereturntheselected //surfaceObjectId. returnresult.ObjectId; } returnObjectId.Null;//Indicatingerror. } [CommandMethod("CDS_ExtractGrid")] publicvoidCDS_ExtractGrid() { ObjectIdsurfaceId=promptForTinSurface(); if(surfaceId==ObjectId.Null) { _editor.WriteMessage("\nNoTINSurfaceselected."); return; } using(Transactiontr=db.TransactionManager.StartTransaction()) { TinSurfacesurface=surfaceId.GetObject(OpenMode.ForRead) asTinSurface; ObjectIdCollectionids=surface.ExtractGridded( SurfaceExtractionSettingsType.Model); foreach(ObjectIdidinids) { Polyline3dpolyline= id.GetObject(OpenMode.ForWrite)asPolyline3d; if(polyline!=null) { using(polyline) { polyline.Color= Autodesk.AutoCAD.Colors.Color.FromRgb(255,0,0); } } } tr.Commit(); } } } }
想了解更多Civil3D2013API,请看CivilizedDevelopment博客中的21WOJP系列(21WeekOfJayPeak),JayPeak是Civil3D2013的代码名。
.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}
相关文章推荐
- 利用Civil 3D API更改曲面的样式
- 获取Civil 3D 三角网曲面TinSurface中每个小三角形的法向量
- Civil 3D 2013新API -- 创建空间几何点(COGO Point)
- Civil 3D 2012基于.net 的曲面API Webcast 7月8号下午进行
- Civil 3D API二次开发学习指南
- Civil 3D 中使用COM API导入DEM数据创建曲面
- 利用J2ME开发移动3D游戏之3D图形API
- 《PCL点云库学习&VS2010(X64)》Part 21 VTK6.2+VS2013 利用PCL读取ply格式网格曲面
- 利用J2ME开发移动3D游戏之3D图形API
- 利用J2ME开发移动3D游戏之3D图形API
- Civil 3D 2013新功能及新API Webcast下载
- 利用J2ME开发移动3D游戏之3D图形API
- Map 3D 2013 新功能和新API WebCast视频下载
- 利用公共api提取任意网站favicon.ico图标
- AutoCAD® Civil 3D API需求意愿调查
- AutoCAD 2013 .net插件创建向导现在支持Map 3D,Civil 3D,AutoCAD Architecture 和AutoCAD MEP
- 利用J2ME开发移动3D游戏之3D图形API
- 7月9号周五Civil 3D 2011 API免费网络培训预告
- 利用Hu不变矩进行特征提取
- 利用 3D touch 的“Peek and Pop”实现视频预览