TheSwamp
Code Red => .NET => Topic started by: xys1995 on September 07, 2016, 10:04:37 PM
-
My program can run normally under ACAD2008,yestday I upgarde to ACAD2016,But something is wrong.
When I call the Polyline class function GetDistAtPoint,every vertex distance to the start point is 1.0.
-
And this Polyline Object is non-database-resistent,It was splited by another polyline.
public static Curve ParticalCopy(this Curve cv, Point3d pt1, Point3d pt2)
{
pt1 = cv.GetClosestPointTo(pt1, false);
pt2 = cv.GetClosestPointTo(pt2, false);
if (cv.GetDistAtPoint(pt1) > cv.GetDistAtPoint(pt2))
{
Point3d pt = pt1;
pt1 = pt2;
pt2 = pt;
}
DoubleCollection dbs = new DoubleCollection();
double param1 = cv.GetParameterAtPoint(pt1);
dbs.Add(param1);
double param2 = cv.GetParameterAtPoint(pt2);
dbs.Add(param2);
DBObjectCollection DBS = cv.GetSplitCurves(dbs);
IEnumerator enumDbOc = DBS.GetEnumerator();
ObjectId res = ObjectId.Null;
Tolerance t = new Tolerance(0.01, 0.01);
Curve[] cvs = new Curve[DBS.Count];
int i = 0;
while (enumDbOc.MoveNext())
{
Curve lineTemp = (Curve)enumDbOc.Current;
cvs[i] = lineTemp;
i++;
}
if (param1 == 0)
return cvs[0];
else if (cvs.Length >= 2)
return cvs[1];
else
return cvs[0];
}
-
Hi,
Can you post an example drawing?
Gaston Nunez
-
Have you tried adding it to the db then testing its methods?
AutoCAD is funny like that with complex objects such as polylines, they need to be added to the db proper before you can edit or use them. It doesn't make sense really and Bricscad doesn't require this but Maybe it has something to do with the removal of Fibres in these later releases?
If you don't want to keep it, just erase it or perhaps you can use the raw Geometry classes to do your calculations.
-
thanks all,I have found the reason,before run the code,call "ZOOMALL", and everything is OK.
so I think that at first the polyline is out of the screen.