Author Topic: Can anybody help me? What's wrong in AutoCAD2016?  (Read 1993 times)

0 Members and 1 Guest are viewing this topic.

xys1995

  • Mosquito
  • Posts: 17
Can anybody help me? What's wrong in AutoCAD2016?
« 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.

xys1995

  • Mosquito
  • Posts: 17
Re: Can anybody help me? What's wrong in AutoCAD2016?
« Reply #1 on: September 07, 2016, 10:12:43 PM »
And this Polyline Object is  non-database-resistent,It was splited by another polyline.

Code: [Select]
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];
        }

Gasty

  • Newt
  • Posts: 90
Re: Can anybody help me? What's wrong in AutoCAD2016?
« Reply #2 on: September 09, 2016, 04:12:31 PM »
Hi,

Can you post an example drawing?

Gaston Nunez


MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Can anybody help me? What's wrong in AutoCAD2016?
« Reply #3 on: September 09, 2016, 06:48:00 PM »
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.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.
- J.R.R. Tolkien

xys1995

  • Mosquito
  • Posts: 17
Re: Can anybody help me? What's wrong in AutoCAD2016?
« Reply #4 on: September 11, 2016, 11:06:29 PM »
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.