Maximum/Minimum Coordinates

Hello,

my task is to create 2d bounding box of a group of splines.
I have a group of multiple splines on a plane. Now i'm looking for method to create the smallest "2D-Bounding-Box" which means a rectangle.
Is there an easy way to find out the min/max x- and y-coordinates of my splinegroup or a function for the "2D-Bounding-Box"?
Otherwise i would have to go through all points of every spline an find out the min/max x-/y-coordinates.

Thanks for the help.
Johannes

You can use one of the "ask bounding box" functions:
UF_MODL_ask_bounding_box
UF_MODL_ask_bounding_box_aligned
UF_MODL_ask_bounding_box_exact

If you are measuring the spline with respect to the absolute coordinate system, use the "ask bounding box" function. If you need to measure w.r.t. a different coordinate system, use the "ask bounding box aligned" function.

You can find an example of the "ask bounding box" function here (in the BoundingBoxVolume function)
http://nxjournaling.com/content/sort-list-nx-objects

Cycling through the points of a spline may or may not work, depending on what you mean by "points". Using poles (control vertices) would work, but using defining points or knot points would not, because the spline might "overshoot" these points.

If you have SNAP, every object has a Box property, so the bounding box of mySpline is just mySpline.Box.

Thanks for the reply and yes i'm using SNAP.
The problem is that i have multiple splines and the box should include all of them.
I can use the functions for one spline but it doesn't work for an array of splines.
Is there a way to to do that?

I would suggest collecting the bounding box for each individual spline; then iterate through the collection to find the overall minimum X, Y, Z and the overall maximum X, Y, Z. This will give you the corner points of a box that contains all the splines.

Some pseudocode:

For each box in splineboxes
if box.X < minX then
minX = box.X
end if
'repeat for Y and Z

if box.X > maxX then
maxX = box.X
end if
'repeat for Y and Z
next

Dim overallMin as Point3d
overallMin.X = minX
overallMin.Y = minY
overallMin.Z = minZ
'similar for overallMax

Same idea as the answer above, but code that's ready to run:

Dim minX = System.Double.PositiveInfinity : Dim maxX = System.Double.NegativeInfinity
Dim minY = System.Double.PositiveInfinity : Dim maxY = System.Double.NegativeInfinity
Dim minZ = System.Double.PositiveInfinity : Dim maxZ = System.Double.NegativeInfinity

For Each s As Snap.NX.Spline In mySplines
minX = System.Math.Min(minX, s.Box.MinX)
minY = System.Math.Min(minY, s.Box.MinY)
minZ = System.Math.Min(minZ, s.Box.MinZ)

maxX = System.Math.Max(maxX, s.Box.MaxX)
maxY = System.Math.Max(maxY, s.Box.MaxY)
maxZ = System.Math.Max(maxZ, s.Box.MaxZ)
Next