- 积分
- 301
- 明经币
- 个
- 注册时间
- 2011-10-19
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
代码如下:
public static void SelectEntitiesWithProperties()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = HostApplicationServices.WorkingDatabase;
TypedValue[] tvs = new TypedValue[]
{
new TypedValue((int)DxfCode.Operator, "<or"),
new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.LayerName, "0"),
new TypedValue((int)DxfCode.Start, "LINE"),
new TypedValue((int)DxfCode.Operator, "and>"),
new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.Start, "CIRCLE"),
new TypedValue((int)DxfCode.Operator, ">="),
new TypedValue((int)DxfCode.Real, 10.0),// Circle Radius
new TypedValue((int)DxfCode.Operator, "and>"),
new TypedValue((int)DxfCode.Operator, "or>")
};
SelectionFilter sf = new SelectionFilter(tvs);
PromptSelectionResult psr = ed.SelectAll(sf);
if (psr.Status == PromptStatus.OK)
{
SelectionSet SS = psr.Value;
ObjectId[] idArray = SS.GetObjectIds();
using (Transaction trans = db.TransactionManager.StartTransaction())
{
for (int i = 0; i < idArray.Length; i++)
{
Entity entObject = trans.GetObject(idArray, OpenMode.ForWrite) as Entity;
entObject.Highlight();
if (entObject.GetType().Name == "line")
{
Line returnLine = (Line)entObject;
double[] lineStartPoint = new Double[2];
double[] lineEndPoint = new Double[2];
lineStartPoint = (Double[])(returnLine.StartPoint);//错误行提示
lineEndPoint = (Double[])returnLine.EndPoint;//错误行提示
Application.ShowAlertDialog("直线的起点坐标为:" + lineStartPoint[0].ToString()
+ "," + lineStartPoint[1].ToString()
+ "," + lineStartPoint[2].ToString()
+ "\n" + "直线的终点坐标为:" + lineEndPoint[0].ToString()
+ "," + lineEndPoint[1].ToString()
+ "," + lineEndPoint[2].ToString());
}
ed.WriteMessage(i + ":" + entObject.ObjectId.ToString() + "," + entObject.GetType().Name);
}
}
}
}
谢谢了
|
|