错误,无法将类型“Autodesk.AutoCAD.Geometry.Point3d”转换为“double[]“
代码如下: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;
double[] lineEndPoint = new Double;
lineStartPoint = (Double[])(returnLine.StartPoint);//错误行提示
lineEndPoint = (Double[])returnLine.EndPoint;//错误行提示
Application.ShowAlertDialog("直线的起点坐标为:" + lineStartPoint.ToString()
+ "," + lineStartPoint.ToString()
+ "," + lineStartPoint.ToString()
+ "\n" + "直线的终点坐标为:" + lineEndPoint.ToString()
+ "," + lineEndPoint.ToString()
+ "," + lineEndPoint.ToString());
}
ed.WriteMessage(i + ":" + entObject.ObjectId.ToString() + "," + entObject.GetType().Name);
}
}
}
}
谢谢了
本帖最后由 liuxu042 于 2012-2-8 15:39 编辑
坐标转为数组使用ToArray()如: Line myline = ent as Line;
double[] startPoint = myline.StartPoint.ToArray();
学了一招。
我以前都是x、y、z分别赋值的。 liuxu042 发表于 2012-2-8 08:42 static/image/common/back.gif
坐标转为数组使用ToArray()如: Line myline = ent as Line;
double[] startPoint = myline.StartPoint.To ...
谢谢了,昨天试了一晚上也没搞定,原来方法后面忘了加(),晕死。谢谢了。 好好加油,经验是慢慢积累起来的. lzx838 发表于 2012-2-8 09:20 static/image/common/back.gif
好好加油,经验是慢慢积累起来的.
谢谢了。
页:
[1]