Author Topic: SplitCurves In Order  (Read 1714 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
SplitCurves In Order
« on: November 05, 2016, 04:06:58 PM »
Need a little help.  I need to use splitcurves to break lines, polylines, and arcs but I need the breaks to occur in order from start of line to end of line. The routine I have now randomly breaks them creating segments longer than they should be.  It's hard for me to explain but hopefully the attached picture will help.

Any idea how I can break my polyline segments in order from start to end at my point locations?

Code - C#: [Select]
  1.     Entity myent = (Entity)myid.GetObject(OpenMode.ForWrite);
  2.  
  3.                             Curve curve = myent as Curve;
  4.  
  5.                             Point3dCollection newpointcoll = new Point3dCollection();
  6.                             foreach (Point3d mypnt in breakpoints)
  7.                             {
  8.                                 Point3d nearpoint = curve.GetClosestPointTo(mypnt, false);
  9.                                 if (nearpoint.DistanceTo(mypnt) < 0.01)
  10.                                 {
  11.                                     newpointcoll.Add(nearpoint);
  12.                                 }
  13.                             }
  14.                             newCurves = curve.GetSplitCurves(newpointcoll);

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: SplitCurves In Order
« Reply #1 on: November 05, 2016, 10:41:23 PM »
Nevermind. I think I have my head wrapped around it now.  Nothing like a good vr break.  I should be able to get the parameters of the points, sort then in order, then get the point locations again based on those parameters.  Wish me luck :)

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: SplitCurves In Order
« Reply #2 on: November 05, 2016, 10:45:14 PM »
That did the trick :)

Code - C#: [Select]
  1.                      List<double> lst = new List<double>();
  2.                             DoubleCollection paramcollection = new DoubleCollection();
  3.                             foreach (Point3d pnt in newpointcoll)
  4.                                 lst.Add(curve.GetParameterAtPoint(pnt));
  5.                             lst.Sort();
  6.                             foreach (double param in lst)
  7.                                 paramcollection.Add(param);
  8.                             newCurves = curve.GetSplitCurves(paramcollection);

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: SplitCurves In Order
« Reply #3 on: November 06, 2016, 01:10:03 AM »
good to see the thought process and the resulting code !

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: SplitCurves In Order
« Reply #4 on: November 07, 2016, 12:09:53 AM »
:)