Hide menu
Loading...
Searching...
No Matches
CNC Machining Feature Recognizer Example

Demonstrates how to perform recognition of machining 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 machining features on a 3D model using machining feature recognition tool (Machining_FeatureRecognizer). For this purpose, used a console application that imports a model, traverses through unique ModelData.Part , creates and runs Machining_FeatureRecognizer, groups and prints information about found features and their parameters into console. Machining feature recognition will be performed for each unique ModelData.Part , but only for the scope of accepted geometries.


Application needs 2 input arguments to run:

Usage: machining_feature_recognizer <input_file> <operation>, where:
<input_file> is a name of the file to be read
<operation> is a name of desired machining operation
Supported operations:
milling: CNC Machining Milling feature recognition
turning: CNC Machining Lathe+Milling feature recognition


For more information about feature recognition visit CNC Machining page.

Implementation

PartProcessor class is inherited from SolidProcessor and overrides ProcessSolid method that are used to run Machining_FeatureRecognizer on given shape. The Machining_FeatureRecognizerParameters.SetOperation() method of the tool parameters is used to set the type of operation (Milling or LatheMilling). The operation type will be taking into account during recognition process and the recognition result will be different depending on it. 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.

using cadex;
class PartProcessor : SolidProcessor
{
public PartProcessor (Machining_OperationType theOperation)
{
myOperation = theOperation;
}
public override void ProcessSolid(Solid theSolid)
{
aParam.SetOperation(myOperation);
var aRecognizer = new Machining_FeatureRecognizer(aParam);
var aFeatureList = aRecognizer.Perform(theSolid);
PrintFeatures(aFeatureList);
}
private Machining_OperationType myOperation = Machining_OperationType.Machining_OT_Undefined;
}
Provides an interface to recognizing machining features tool.
Definition Machining_FeatureRecognizer.cs:24
Defines parameters used by Machining_FeatureRecognizer.
Definition Machining_FeatureRecognizerParameters.cs:39
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition BaseObject.cs:12
Machining_OperationType
Defines an operation type in machining.
Definition Machining_OperationType.cs:19

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 machining 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);
{
Machining_TurningFace aTurningFace = Machining_TurningFace.Cast(aFeature);
aManager.AddFeature(FaceTypeToString(aTurningFace.Type()), "Turning Face(s)", true, aFeature);
}
else if (Machining_Face.CompareType(aFeature))
{
Machining_Face aFace = Machining_Face.Cast(aFeature);
aManager.AddFeature(FaceTypeToString(aFace.Type()), "", false, aFeature);
}
else if ...
}
Describes a base class of MTK based features.
Definition MTKBase_Feature.cs:21
Describes a face produced by a specified machining operation.
Definition Machining_Face.cs:124
cadex.Machining_FaceType Type()
Definition Machining_Face.cs:199
static new bool CompareType(cadex.MTKBase_Feature theFeature)
Returnstrue if theFeature is a machining face.
Definition Machining_Face.cs:213
Describes a face with radius produced by a specified machining operation. Cutting material from workp...
Definition Machining_TurningFace.cs:29
static new bool CompareType(cadex.MTKBase_Feature theFeature)
Returns true if theFeature is a machining turning face.
Definition Machining_TurningFace.cs:93

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 =>
{
{
Machining_TurningFace aTurningFace = Machining_TurningFace.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("radius", aTurningFace.Radius(), "mm");
}
else if (Machining_Face.CompareType(theFeature))
{
//no parameters
}
else if ...
};
aManager.Print("features", PrintFeatureParameters);
double Radius()
Definition Machining_TurningFace.cs:79

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

Example output

The first is an example output for model from ./examples/models/Fresamento_CAM1_v3.stp and operation set to Milling. and the second one is an output for model from ./examples/models/senthi.step and operation set to Lathe+Milling.

Model Example output
Model: Fresamento_CAM1_v3

Part #0 ["Fresamento_CAM1"] - solid #0 has:
    Concave Fillet Edge Milling Face(s): 14
        14 Turning Face(s) with
          radius: 5 mm
    Convex Profile Edge Milling Face(s): 7
        4 Turning Face(s) with
          radius: 10 mm
        3 Turning Face(s) with
          radius: 15 mm
    ...

    Total features: 44
Model: senthi

Part #0 ["drawing no 1"] - solid #0 has:
    Turn Diameter Face(s): 7
        1 Turning Face(s) with
          radius: 50 mm
        1 Turning Face(s) with
          radius: 75 mm
        1 Turning Face(s) with
          radius: 80 mm
        1 Turning Face(s) with
          radius: 86 mm
        1 Turning Face(s) with
          radius: 90 mm
        1 Turning Face(s) with
          radius: 96.4288 mm
        1 Turning Face(s) with
          radius: 155 mm
    ...

    Total features: 17

Files