Hide menu
Loading...
Searching...
No Matches
Molding Feature Recognizer Example

Demonstrates how to perform recognition of molding features on a 3D model and print information about found features and their parameters in a console.

Overview

This example demonstrates how to perform recognition of molding features on a 3D model using molding feature recognition tool (Molding_FeatureRecognizer). For this purpose, used a console application that imports a model, traverses through unique ModelData.Part , creates and runs Molding_FeatureRecognizer, groups and prints information about found features and their parameters into console. Molding feature recognition will be performed for each unique ModelData.Part , but only for the scope of accepted geometries.


Application needs 1 input argument to run:

Usage: molding_feature_recognizer <input_file>, where:
<input_file> is a name of the file to be read


For more information about feature recognition visit Injection Molding page.

Implementation

PartProcessor class is inherited from SolidProcessor and overrides ProcessSolid method that are used to run Molding_FeatureRecognizer on given shapes. Then PrintFeatures method is used to print information about found features and their parameters in a console.
Visit Model Explore Helper Implementation page for more information about base SolidProcessor class implementation.

class PartProcessor : SolidProcessor
{
public override void ProcessSolid (Solid theSolid)
{
// Set up recognizer
var aRecognizerParameters = new Molding_FeatureRecognizerParameters();
aRecognizerParameters.SetMaxRibThickness(30.0);
aRecognizerParameters.SetMaxRibDraftAngle(0.2);
aRecognizerParameters.SetMaxRibTaperAngle(0.1);
var aRecognizer = new Molding_FeatureRecognizer (aRecognizerParameters);
var aFeatureList = aRecognizer.Perform (theSolid);
PrintFeatures (aFeatureList);
}
}

To traverse only unique parts of the imported model, the ModelData.ModelElementUniqueVisitor class is used.

var aPartProcessor = new PartProcessor(anOperation);
var aVisitor = new ModelData.ModelElementUniqueVisitor(aPartProcessor);
aModel.Accept(aVisitor);

After performing feature recognition, the object of FeatureGroupManager class is used to group and sort found molding features. For this purpose, there is a traverse through all found features and add each of them to FeatureGroupManager with a specified name.

for (uint i = 0; i < theFeatureList.Size(); i++)
{
MTKBase_Feature aFeature = theFeatureList.Feature(i);
if (Molding_ScrewBoss.CompareType (aFeature))
{
Molding_ScrewBoss aScrewBoss = Molding_ScrewBoss.Cast (aFeature);
aManager.AddFeature("Screw Boss(es)", "Screw Boss(es)", true, aScrewBoss);
}
else if (MTKBase_Boss.CompareType (aFeature))
{
MTKBase_Boss aBoss = MTKBase_Boss.Cast (aFeature);
aManager.AddFeature("Boss(es)", "Boss(es)", true, aBoss);
}
else if (Molding_Rib.CompareType (aFeature))
{
Molding_Rib aRib = Molding_Rib.Cast (aFeature);
aManager.AddFeature("Rib(s)", "Rib(s)", true, aRib);
}
}

After adding all found features to FeatureGroupManager, a Print method of the manager is used to print information about found features and their parameters in a console. PrintFeatureParameters is created to explore and print feature parameters. It uses as an input parameter of Print method.

Action<MTKBase_Feature> PrintFeatureParameters = theFeature =>
{
if (Molding_ScrewBoss.CompareType(theFeature))
{
Molding_ScrewBoss aScrewBoss = Molding_ScrewBoss.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("outer radius", aScrewBoss.OuterRadius(), "mm");
FeatureGroupManager.PrintFeatureParameter("inner radius", aScrewBoss.InnerRadius(), "mm");
FeatureGroupManager.PrintFeatureParameter("draft angle", ToDegrees (aScrewBoss.DraftAngle()), "deg");
}
else if (MTKBase_Boss.CompareType(theFeature))
{
MTKBase_Boss aBoss = MTKBase_Boss.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("length", aBoss.Length(), "mm");
FeatureGroupManager.PrintFeatureParameter("height", aBoss.Height(), "mm");
FeatureGroupManager.PrintFeatureParameter("width", aBoss.Width(), "mm");
}
else if (Molding_Rib.CompareType(theFeature))
{
Molding_Rib aRib = Molding_Rib.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("length", aRib.Length(), "mm");
FeatureGroupManager.PrintFeatureParameter("height", aRib.Height(), "mm");
FeatureGroupManager.PrintFeatureParameter("thickness", aRib.Thickness(), "mm");
FeatureGroupManager.PrintFeatureParameter("draft angle", ToDegrees (aRib.DraftAngle()), "deg");
}
};
aManager.Print("features", PrintFeatureParameters);

Visit Feature Group Helper Implementation page for more information about FeatureGroupManager class implementation.

Example output

Below is an example output for model from ./examples/models/Part3.stp.

Model Example output
Model: Part3.stp

Part #0 ["Part3"] - solid #0 has:
    Rib(s): 5
        1 Rib(s) with
          length: 33.2764 mm
          height: 15.5984 mm
          thickness: 15 mm
          draft angle: 0 deg
        3 Rib(s) with
          length: 40 mm
          height: 29 mm
          thickness: 3.91237 mm
          draft angle: 0 deg
        1 Rib(s) with
          length: 127.988 mm
          height: 18.7895 mm
          thickness: 15 mm
          draft angle: 0 deg
    Screw Boss(es): 3
        1 Screw Boss(es) with
          outer radius: 18.85 mm
          inner radius: 15 mm
          draft angle: 0 deg
        1 Screw Boss(es) with
          outer radius: 22 mm
          inner radius: 10 mm
          draft angle: 0 deg
        1 Screw Boss(es) with
          outer radius: 22.3392 mm
          inner radius: 20 mm
          draft angle: 11.3099 deg

    Total features: 8

Files