How to use SolidUtil APIs

Introduction

SolidUtil and allied classes provide support for the creation, querying, and modification of BREP.

MicroStation SDK has file MstnExamples/Elements/ManagedToolsExample/SolidUtilClassExamples.cs; which demonstrates the capabilities.

This suits of APIs are typically used when merely the final state of geometry is important without knowing its history tree. In case of knowing history one should go for Parametric Feature APIs (a.k.a. SmartFeature namespace) than this SolidUtil.

What does the example demonstrate?

'SolidUtil Tool' showscase functionalities of SolidUtil, Modify and Convert1 .NET classes.

To run the Example

1.Create Parametric Solid e.g. Extrude with 1 meter height as per following image

2. Load the 'SolidUtil Tool' application using either

a. Key-In: mdl load examplesolids or

b. Utilities -> MDL Applications -> Browse ...select: exampleSolids.ma

3. Launch 'TOOLSEXAMPLE SOLIDUTIL TOOL' Key-In

4. Observe 'SolidUtil Tool' dialog

5. Select a top face of the extrude as shown in following image and enter a data point.

6. The program offsets the face by 10 units as displayed in following image 

Code Walkthrough

  1. Query selected face/s by tool
                List<SubEntity> faceList = new List<SubEntity>();
                SubEntity[] faces = faceList.ToArray();
                GetAcceptedSubEntities(ref faces);
    
                if ( faces == null || faces.Length < 1 )
                    return status;
  2. Retrieve Parasolid entity using face
                System.IntPtr geomPtr = GetIElementGraphicsPtr (faces[0]);
                SolidKernelEntity target = TryGetAsBRep (geomPtr);
                if ( target == null)
                    return status;
  3. Offset face using SolidUtil API
                List<double> distanceList = new List<double>();
                distanceList.Add(10000.00);
    
                Modify.StepFacesOption addStep = Modify.StepFacesOption.All;
    
                if ( BentleyStatus.Success == Modify.OffsetFaces(ref target, faces, distanceList.ToArray(), faces.Length, addStep) )
                    {
                    ......
                    }
  4. Convert the solid body into an element and then add to the model
                    Element ehOut;
                    DgnModelRef modelRef = Session.Instance.GetActiveDgnModelRef();
                    if ( BentleyStatus.Success == Convert1.BodyToElement(out ehOut, target, eeh, modelRef) )
                        {
                        ehOut.AddToModel();
                        eeh.DeleteFromModel();
                        }