构造线与直线和圆的交点问题
本帖最后由 正版马甲 于 2014-1-2 17:20 编辑请教各位大侠,构造线求交点的函数是什么?
为何我用的IntersectWith总是不对呢。
编译没有任何问题,连个警告都没有,但就是运行不通。
有没有其他的方法,只要能求出交点就好了。using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Colors;
using DotNetARX;
namespace CeShi
{
public class Class1
{
public static void AddXLines()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Point3d pt1 = new Point3d(100, 200, 0);
Point3d pt2 = Point3d.Origin;
Point3d pt3 = new Point3d(200, 500, 0);
Point3d pt4 = new Point3d(100, 100, 0);
Line csline1 = new Line(pt1, pt2);
Xline csline2 = new Xline();
csline2.BasePoint = pt3;
csline2.SecondPoint = pt4;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
db.AddToModelSpace(csline1);
db.AddToModelSpace(csline2);
trans.Commit();
}
Point3dCollection pt5 = null;
csline2.IntersectWith(csline1, Intersect.OnBothOperands, pt5, IntPtr.Zero, IntPtr.Zero);
ed.WriteMessage("csline1和csline2的交点是:{0}", pt5);
}
}
}
你把Using中的语句改为try...catch试试看,捕获异常看看是什么问题 这两条线本来就没交点
页:
[1]