Author Topic: How to divide by increment between paramaters  (Read 207 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);
                            }
                        }

Thanks everyone, appreciate your help.
« Last Edit: December 17, 2018, 02:19:19 PM by quadman »

Jeff_M

  • King Gator
  • Posts: 3934
  • 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]
  1.                    for (int i = 0; i < poly.EndParam; i++)
  2.                    {
  3.                        var len = 5.0;
  4.                        var startlen = poly.GetDistanceAtParameter(i);
  5.                        var endlen = poly.GetDistanceAtParameter(i + 1);
  6.                        while ((startlen += len) < (endlen - 5.0))
  7.                        {
  8.                            var pt = poly.GetPointAtDist(startlen);
  9.                            Circle cr = new Circle(pt, Vector3d.ZAxis, 1.0);
  10.                            acBlkTblRec.AppendEntity(cr);
  11.                            MyTrans.AddNewlyCreatedDBObject(cr, true);
  12.                        }
  13.                   }
  14.  

estanima

  • Guest
Re: How to divide by increment between paramaters
« Reply #2 on: December 17, 2018, 04:29:46 PM »
Flawless, thank you.  Seeing your code made it look so easy :(   :uglystupid2:
Something like this should do it.
Code - C#: [Select]
  1.                    for (int i = 0; i < poly.EndParam; i++)
  2.                    {
  3.                        var len = 5.0;
  4.                        var startlen = poly.GetDistanceAtParameter(i);
  5.                        var endlen = poly.GetDistanceAtParameter(i + 1);
  6.                        while ((startlen += len) < (endlen - 5.0))
  7.                        {
  8.                            var pt = poly.GetPointAtDist(startlen);
  9.                            Circle cr = new Circle(pt, Vector3d.ZAxis, 1.0);
  10.                            acBlkTblRec.AppendEntity(cr);
  11.                            MyTrans.AddNewlyCreatedDBObject(cr, true);
  12.                        }
  13.                   }
  14.