AB4D Forum

Full Version: MultipolylineVisual3D and LineSelectorData
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I am trying to use the LineSelectorData with a MultiPolylineVisual3D.  I have mainly copied the example in the powertoys examples (as suggested in a previous thread).  When I call the method GetClosestDistance I get an exception thrown:

"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"

The LineVisual3D property is definitely not null and is a MultiPolylineVisual3D which contains data which in this case is 1 list of points as I'm considering a simple case initially.

If i swap to a PolyLineVisual3D using the first list of points from the MultiPolylineVisual3D, its works.

Any ideas why?
I was able to reproduce the problem and can confirm that this is a bug in LineSelectorData - it does not work with MultiPolyLineVisual3D.

This has been fixed in the development version and will be available in the next version of Ab3d.PowerToys (v8.2 - cannot say when this will be released; not very soon). If you want the fixed code before the next release please send me a request by email or private message and I will send you the fixed source for LineSelectorData.

You can also use a simple workaround:
Instead of creating an instance of LineSelectorData with passing MultiPolyLineVisual3D as a parameter, you can use the constructor that takes Point3DCollection or List<Point3D>:

//var lineSelectorData = new LineSelectorData(multiPolyLineVisual3D);
var lineSelectorData = new LineSelectorData(multiPolyLineVisual3D.PositionsList[0], isLineStrip: true);
Note that in this case you will not be able to use the LineVisual3D property in LineSelectorData when checking which line is the closest.