Hide menu
Loading...
Searching...
No Matches
Sheet Metal Feature Recognizer Example

Demonstrates how to perform recognition of sheet metal 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 sheet metal features on a 3D model using sheet metal feature recognition tool (SheetMetal_FeatureRecognizer). For this purpose, used a console application that imports a model, traverses through unique ModelData.Part , creates and runs SheetMetal_FeatureRecognizer, groups and prints information about found features and their parameters into console. Sheet metal 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: sheet_metal_feature_recognizer <input_file>, where:
<input_file> is a name of the file to be read


For more information about feature recognition visit Sheet Metal page.

Implementation

PartProcessor class is inherited from ShapeProcessor and overrides ProcessSolid and ProcessShell methods that are used to run SheetMetal_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 ShapeProcessor class implementation.

class PartProcessor : ShapeProcessor
{
public PartProcessor()
{
myRecognizer = new SheetMetal_FeatureRecognizer();
}
public override void ProcessSolid(Solid theSolid)
{
var aFeatureList = myRecognizer.Perform(theSolid);
PrintFeatures(aFeatureList);
}
public override void ProcessShell(Shell theShell)
{
var aFeatureList = myRecognizer.Perform(theShell);
PrintFeatures(aFeatureList);
}
private SheetMetal_FeatureRecognizer myRecognizer;
}

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

var aPartProcessor = new PartProcessor();
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 sheet metal features. For this purpose, there is a traverse through all found features and add each of them to FeatureGroupManager with a specified name.

Action<MTKBase_FeatureList> GroupByParameters = null;
GroupByParameters = new Action<MTKBase_FeatureList>((theFeatures) =>
{
for (uint i = 0; i < theFeatures.Size(); ++i)
{
MTKBase_Feature aFeature = theFeatures.Feature(i);
if (SheetMetal_Bead.CompareType(aFeature))
{
aManager.AddFeature("Bead(s)", "Bead(s)", true, aFeature);
}
else if (SheetMetal_Cutout.CompareType(aFeature))
{
aManager.AddFeature("Cutout(s)", "Cutout(s)", true, aFeature);
}
else if ...
}
});
GroupByParameters(theFeatureList);

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 MTK feature parameters. It uses as an input parameter of Print method.

Action<MTKBase_Feature> PrintFeatureParameters = theFeature =>
{
if (SheetMetal_Bead.CompareType(theFeature))
{
SheetMetal_Bead aBead = SheetMetal_Bead.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("depth", aBead.Depth(), "mm");
}
else if (SheetMetal_Cutout.CompareType(theFeature))
{
SheetMetal_Cutout aCutout = SheetMetal_Cutout.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("perimeter", aCutout.Perimeter(), "mm");
}
else if ...
};
aManager.Print("features", PrintFeatureParameters);

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

Example output

Below is the example output for model from ./examples/models/Power_box_Chasis.stp.

Model Example output
Model: Power_box_Chasis

Part #0 ["power box sheetmetal"] - solid #0 has:
    Bend(s): 8
        2 Bend(s) with
          radius: 0.7366 mm
          angle: 90 deg
          length: 1.15705 mm
          width: 60 mm
        2 Bend(s) with
          radius: 0.7366 mm
          angle: 90 deg
          length: 1.15705 mm
          width: 137.327 mm
        4 Bend(s) with
          radius: 0.7366 mm
          angle: 90 deg
          length: 1.15705 mm
          width: 148 mm
    ...

    Total features: 76

Files