### Author Topic: How to divide by increment between paramaters  (Read 128 times)

0 Members and 1 Guest are viewing this topic.

#### estanima

• Guest
##### How to divide by increment between paramaters
« on: December 17, 2018, 02:15:26 PM »
Could use a hand with this.  I need to place circles on polyline segments at 5-ft increments between the vertices (parameters). Having a difficult time.  Additionally, the circles can't be within 5-ft of any parameter.  Here's a very bad start (basically junk) that doesn't do what I want. I keep fumbling around so thought I'd ask here for help (sorted is the number of parameters in the polyline):

Code: [Select]
` for (int i = 0; i < sorted.Count - 1; i++) //minus 1 so it doesn't fail on last parameter                        {                            Point3d parampoint = temppoly.GetPointAtParameter(i);                            Point3d afterpoint = temppoly.GetPointAtParameter(i + 1);                            double distance = parampoint.DistanceTo(afterpoint);                            if (distance > 5.1 && (distance + 5.1) < temppoly.GetDistanceAtParameter(i + 1))                            {                                Circle cr = new Circle(temppoly.GetPointAtDist(temppoly.GetDistanceAtParameter(i) + 5), Vector3d.ZAxis, 1.0);                                acBlkTblRec.AppendEntity(cr);                                MyTrans.AddNewlyCreatedDBObject(cr, true);                            }                        }`
« Last Edit: December 17, 2018, 02:19:19 PM by quadman »

#### Jeff_M

• King Gator
• Posts: 3932
• C3D user & customizer
##### Re: How to divide by increment between paramaters
« Reply #1 on: December 17, 2018, 03:13:20 PM »
Something like this should do it.
Code - C#: [Select]
`                    for (int i = 0; i < poly.EndParam; i++)                    {                        var len = 5.0;                        var startlen = poly.GetDistanceAtParameter(i);                        var endlen = poly.GetDistanceAtParameter(i + 1);                        while ((startlen += len) < (endlen - 5.0))                        {                            var pt = poly.GetPointAtDist(startlen);                            Circle cr = new Circle(pt, Vector3d.ZAxis, 1.0);                            acBlkTblRec.AppendEntity(cr);                            MyTrans.AddNewlyCreatedDBObject(cr, true);                        }                   } `

#### estanima

• Guest
##### Re: How to divide by increment between paramaters
« Reply #2 on: December 17, 2018, 04:29:46 PM »
`                    for (int i = 0; i < poly.EndParam; i++)                    {                        var len = 5.0;                        var startlen = poly.GetDistanceAtParameter(i);                        var endlen = poly.GetDistanceAtParameter(i + 1);                        while ((startlen += len) < (endlen - 5.0))                        {                            var pt = poly.GetPointAtDist(startlen);                            Circle cr = new Circle(pt, Vector3d.ZAxis, 1.0);                            acBlkTblRec.AppendEntity(cr);                            MyTrans.AddNewlyCreatedDBObject(cr, true);                        }                   } `