|
初学BIM软件,大家有搞二次开发的多多交流
这个程序作用是加载后输入一个x,y坐标,程序自动将所有曲面该x,y坐标处的高程提取出来。
不知道如何添加附件。
[CommandMethod("GetElevation")]
public void GetElevation()
{
Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
CivilDocument doc=Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument;
double xCoordinate = 0.00;
double yCoordinate = 0.00;
PromptDoubleOptions xValue = new PromptDoubleOptions("输入X坐标");
PromptDoubleResult getXCoordinate = ed.GetDouble(xValue);
PromptDoubleOptions yValue = new PromptDoubleOptions("输入Y坐标");
PromptDoubleResult getYCoordinate = ed.GetDouble(yValue);
xCoordinate = Convert.ToDouble(getXCoordinate.ToString().Remove(0, 7).TrimEnd(')'));
yCoordinate = Convert.ToDouble(getYCoordinate.ToString().Remove(0, 7).TrimEnd(')'));
using (Transaction ts = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
ObjectIdCollection surfaceIds = doc.GetSurfaceIds();
foreach (ObjectId surfaceId in surfaceIds)
{
Autodesk.Civil.DatabaseServices.Entity oSurface = surfaceId.GetObject(OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Entity;
Autodesk.Civil.DatabaseServices.Surface surface = surfaceId.GetObject(OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;
double zCoordinate = surface.FindElevationAtXY(xCoordinate,yCoordinate);
ed.WriteMessage("\n曲面名称:{0}; \t坐标点XY处高程为:{1}", oSurface.Name, zCoordinate.ToString("#.0000"));
}
ts.Commit();
}
} |
|