直接来点源码:
public void CreateTinSurfaceArea()
{
try
{
string strErr = "";
ObjectId sId = PromptOptionsHelper.GetPromptEntOptions("请选择曲面", typeof(Autodesk.Civil.DatabaseServices.Surface));
if (sId == new ObjectId())
{
strErr = "用户取消操作!";
return;
}
using (Transaction ts = Autodesk.AutoCAD.ApplicationServices.Application
.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
//获取曲面对象
Autodesk.Civil.DatabaseServices.TinSurface surface = ts.GetObject(sId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.TinSurface;
TerrainSurfaceProperties aaa = surface.GetTerrainProperties();
//平面面积
double d2dAea = aaa.SurfaceArea2D;
//三维面积
double d3dAea = aaa.SurfaceArea3D;
}
}
catch (System.Exception ex)
{
EntBaseOperator.WriteLineInCommand(ex.ToString());
return;
}
}
d2dAea 和 d3dAea 可以用数据来验证,准确无误,大胆放心使用