Everything Returns Arrays[]

Something I’m noticing now that I’m developing my scripts in c# more is that many of the “create” methods for geometry classes return arrays on objects instead of a single object. I have a couple of questions about this that would help me use the methods better.

  1. What is best practice for taking the output of a method and using it in another method? This is important for when the method uses a single object, not an array or list (eg. Brep.CreateFromSweep to be used as part of Intersection.BrepBrep)?

  2. What benefit is there to returning an array verses a single object? This is doubly true when you have methods that can only return a single object, (eg. Brep.CreateFromSweep).

If the method can return multiple objects, and CreateFromSweep can do this if there are tangency/curvature discontinuities in the rail or profiles, you get an array. Then, if you expect only one returned object, test for null-array (failure) and length of array (should be one) before extracting the first item from the array and continuing.

1 Like