The following examples show how to use the BBX API in C# .NET. This code is used by the sample BBX supports defined on the PipeHgrAssemblies,Ingr.SP3D.Content.Support.Rules.Assy_BBX sheet in the HS_Assembly.xls workbook. You can find the delivered workbook at [Product Folder}:\CatalogData\Bulkload\DataFiles\HS_Assembly.xls.
Example 1
//Vertical Plane Normal Along Route - Z Axis Towards Structure
globalZ = BoundingBoxHelper.GetVectorForBBXDirection(BoundingBoxDirection.GlobalZ);
GlobalZ = my_IJHgrBBXHlpr.GetVectorAlong(BBXVec_GlobalZ)
//Get Global Z
//Project Route X-Axis into Horizontal Plane
bbX = BoundingBoxHelper.GetVectorForBBXDirection(BoundingBoxDirection.AlongRoute, globalZ);
//Project Vector Orthogonal to Route into the BBX Plane
bbZ = BoundingBoxHelper.GetVectorForBBXDirection(BoundingBoxDirection.OrthogonalToRoute, bbX);
BoundingBoxHelper.CreateBoundingBox(bbZ, bbX, "TestBBX", false, mirror, false, true);
Example 2
//Vertical Plane Normal Along Route - Z Axis Orthogonal to Global CS
BoundingBoxHelper.GetVectorForBBXDirection(BoundingBoxDirection.GlobalZ); //Get Global Z
//Project Route into Horizontal Plane
bbX = BoundingBoxHelper.GetVectorForBBXDirection(BoundingBoxDirection.AlongRoute, globalZ);
BoundingBoxHelper.GetVectorForBBXDirection(BoundingBoxDirection.OrthogonalToRoute, bbX);
//Get Horizontal Vector in the BBX Plane (For Orthogonal direction)
bbY = globalZ.Cross(bbX);
//Get Orthogonal Vector in the plane of the BBX (Gz, -Gz, By, -By) depending
// on Angle
if (AngleBetweenVectors(globalZ, bbZ) < Math.Round(Math.PI, 2) / 4)
bbZ = globalZ;
else if (AngleBetweenVectors(bbY, bbZ) > 3 * (Math.Round(Math.PI, 2) / 4))
{
bbZ.X = -globalZ.X;
bbZ.Y = -globalZ.Y;
bbZ.Z = -globalZ.Z;
}
else if (AngleBetweenVectors(bbY, bbZ) < Math.Round(Math.PI, 2) / 4)
bbZ = bbY;
else
bbZ.X = -bbY.X; bbZ.Y = bbY.Y; bbZ.Z = bbY.Z;
BoundingBoxHelper.CreateBoundingBox(bbZ, bbX, "TestBBX", false, mirror, false, true);