Posts: 165
Registered: ‎06-16-2008
Message 1 of 3 (281 Views)

Get Point Along Curve

281 Views, 2 Replies
01-22-2013 01:03 AM

Hey All,


I am developing a tool that will allow a user to select a curve, and dump out the points at given intervals along said curve.


This works well for 2D objects.


If I have a line from 0,0,0 to 10,0,1


it outpus

0, 0, 0

0.9950, 0, 0.0995

1.9901, 0, 0.1990


What I want it to output is the point at the interval (2D plane, with the elevation)

0, 0, 0

1, 0, 0.1

2, 0, 0.2



Is there a way a function I can use that would allow this, or do I need to write my own function?


I hope that made sense.






Posts: 1,450
Registered: ‎04-09-2008
Message 2 of 3 (275 Views)

Re: Get Point Along Curve

01-22-2013 02:21 AM in reply to: BrentBurgess1980

BrentBurgess1980 wrote:

Is there a way a function I can use that would allow this, or do I need to write my own function?

You have to write own function.

Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 3 (241 Views)

Re: Get Point Along Curve

01-23-2013 01:13 AM in reply to: BrentBurgess1980

Hi Brent

You can use virtual plane to get the points, see quick example,

Im using existing line for test but you can create LineSegment3d

or CircularArc3d for your polyline segments instead, but way would be the same:

        public void testLineDivisions()
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            PromptEntityOptions peo = new PromptEntityOptions("\nSelect a Line: ");
            peo.SetRejectMessage("Only a Line !");
            peo.AddAllowedClass(typeof(Line), false);
            PromptEntityResult per = ed.GetEntity(peo);
            if (per.Status != PromptStatus.OK) return;
            ObjectId lid = per.ObjectId;

            PromptDoubleOptions pdo = new PromptDoubleOptions("\nEnter step: ");
            pdo.AllowNone = true;
            pdo.UseDefaultValue = true;
            pdo.DefaultValue = 1.0;

            PromptDoubleResult res;
            res = ed.GetDouble(pdo);
            if (res.Status != PromptStatus.OK) return;
            double step = res.Value;

            ed.WriteMessage("\nStep entered:\t{0}\n", step);
            Point3d pt;
            Point3d tmp;
            using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction())
                Entity ent = tr.GetObject(lid, OpenMode.ForWrite) as Entity;
                if (ent == null) return;
                Line ln = ent as Line;
                if (ln == null) return;
                Line3d lc = new Line3d(new Point3d(0, 0, 0), new Point3d(10, 0, 1));// current line
                Line3d lx = new Line3d(new Point3d(0, 0, 0), new Point3d(10, 0, 0));// line along x axis
                Plane plan = new Plane();
                int i = 0;
                for (double d = 0.1; d < 1.0; d += 0.1)
                    pt = lx.EvaluatePoint(d);
                    plan = new Plane(pt, Vector3d.XAxis);
                    tmp = plan.IntersectWith(lc)[0];// get intersection point between the line and virtual plane
                    ed.WriteMessage("\nPoint Number: {0}\tPoint: {1:f3}\n", i + 1, tmp);



Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.