Hide menu
Loading...
Searching...
No Matches
CNC Machining DFM Analyzer Example

Demonstrates how to perform machining design analysis on a 3D model and print information about found issues and their parameters in a console.

Overview

In this example demonstrates how to perform machining design analysis on a 3D model using machining dfm analyzer tool (DFMMachining_Analyzer). For this purpose, used a console application that imports a STEP model, traverses through unique ModelData::Part , creates and runs DFMMachining_Analyzer, groups and prints information about found issues and their parameters into console. Machining design analysis 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_dfm_analyzer <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 machining design analysis visit CNC Machining Design for Manufacturing (DFM) page.

Implementation

PartProcessor class is inherited from SolidProcessor and overrides ProcessSolid method that are used to run design analysis on given shape. To reduce computation time, Machining_Data will be used as an input argument to perform design analysis. Machining data contains information about found features, therefore, the first step is to run Machining_FeatureRecognizer. 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.
Once feature recognition is done, design analysis is run for various sub-processes (drilling / milling / turning). CombineFeatureLists method is used to combine issues from design analysis of different sub-processes.
After design analysis is performed, PrintIssues 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 namespace cadex;
class PartProcessor : public SolidProcessor
{
public:
PartProcessor (Machining_OperationType theOperation) : myOperation (theOperation)
{}
void ProcessSolid (const ModelData::Solid& theSolid) override
{
// Find features
aRecognizer.Parameters().SetOperation (myOperation);
aRecognizer.Perform (theSolid, aData);
// Run drilling analyzer for found features
DFMMachining_Analyzer aDrillingAnalyzer (aDrillingParameters);
auto anIssueList = aDrillingAnalyzer.Perform (theSolid, aData);
// Run milling analyzer for found features
DFMMachining_Analyzer aMillingAnalyzer (aMillingParameters);
MTKBase_FeatureList aMillingIssueList = aMillingAnalyzer.Perform (theSolid, aData);
// Combine issue lists
CombineFeatureLists (anIssueList, aMillingIssueList);
MTKBase_FeatureList aTurningIssueList;
if (myOperation == Machining_OT_LatheMilling) {
// Run turning analyzer for found features
DFMMachining_Analyzer aTurningAnalyzer (aTurninigParameters);
aTurningIssueList = aTurningAnalyzer.Perform (theSolid, aData);
// Combine issue lists
CombineFeatureLists (anIssueList, aTurningIssueList);
}
PrintIssues (anIssueList);
}
private:
void CombineFeatureLists (MTKBase_FeatureList& theFirst, const MTKBase_FeatureList& theSecond)
{
for (size_t i = 0; i < theSecond.Size(); i++) {
const auto& aFeature = theSecond[i];
if (myOperation == Machining_OT_LatheMilling
&& aFeature.IsOfType<DFMMachining_MillingIssue>()
&& !aFeature.IsOfType<DFMMachining_DeepPocketIssue>()) {
continue;
}
theFirst.Append (aFeature);
}
}
};
Provides an interface to run DFM Machining analysis.
Definition DFMMachining_Analyzer.hxx:43
Describes deep pocket issue found during cnc machining milling design analysis.
Definition DFMMachining_DeepPocketIssue.hxx:30
Defines parameters used in cnc machining drilling design analysis.
Definition DFMMachining_DrillingAnalyzerParameters.hxx:31
Defines parameters used in cnc machining milling design analysis.
Definition DFMMachining_MillingAnalyzerParameters.hxx:36
Describes a base class for milling issues found during cnc machining milling design analysis.
Definition DFMMachining_MillingIssue.hxx:33
Defines parameters used in cnc machining turning design analysis.
Definition DFMMachining_TurningAnalyzerParameters.hxx:35
Defines a list of features.
Definition MTKBase_FeatureList.hxx:36
size_t Size() const
Returns the number of elements in the list.
Definition MTKBase_FeatureList.cxx:88
void Append(const MTKBase_Feature &theFeature)
Adds a feature to the list.
Definition MTKBase_FeatureList.cxx:56
Defines data used in Machining analysis.
Definition Machining_Data.hxx:36
Provides an interface to recognizing machining features tool.
Definition Machining_FeatureRecognizer.hxx:45
MTKBase_FeatureList Perform(const ModelData::Solid &theSolid, const cadex::ProgressStatus &theProgressStatus=cadex::ProgressStatus())
Runs features recognition process.
Definition Machining_FeatureRecognizer.cxx:301
const Machining_FeatureRecognizerParameters & Parameters() const
Returns parameters.
Definition Machining_FeatureRecognizer.cxx:320
void SetOperation(Machining_OperationType theOperation)
Definition Machining_FeatureRecognizerParameters.cxx:221
Defines a topological solid.
Definition Solid.hxx:32
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30
Machining_OperationType
Defines an operation type in machining.
Definition Machining_OperationType.hxx:28
@ Machining_OT_Undefined
Unknown operation type.
Definition Machining_OperationType.hxx:31

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

PartProcessor aPartProcessor;
ModelData::ModelElementUniqueVisitor aVisitor (aPartProcessor);
aModel.Accept (aVisitor);
Defines a visitor that visits each unique element only once.
Definition ModelElementVisitor.hxx:87

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

using namespace cadex;
for (size_t i = 0; i < theIssueList.Size(); ++i) {
const auto& anIssue = theIssueList[i];
if (anIssue.IsOfType<DFMMachining_SmallDiameterHoleIssue>()) {
aManager.AddFeature ("Small Diameter Hole Issue(s)", "Hole(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMMachining_DeepHoleIssue>()) {
aManager.AddFeature ("Deep Hole Issue(s)", "Hole(s)", true, anIssue);
} else if ...
}
Describes deep hole issues found during cnc machining drilling design analysis.
Definition DFMMachining_DeepHoleIssue.hxx:29
Describes small diameter hole issues found during cnc machining drilling design analysis.
Definition DFMMachining_SmallDiameterHoleIssue.hxx:29

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

using namespace cadex;
auto PrintFeatureParameters = [] (const MTKBase_Feature& theIssue)
{
if (theIssue.IsOfType<DFMMachining_SmallDiameterHoleIssue>()) {
const auto& aSDHIssue = static_cast<const DFMMachining_SmallDiameterHoleIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min diameter", aSDHIssue.ExpectedMinDiameter(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual diameter", aSDHIssue.ActualDiameter(), "mm");
} else if (theIssue.IsOfType<DFMMachining_DeepHoleIssue>()) {
const auto& aDHIssue = static_cast<const DFMMachining_DeepHoleIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max depth", aDHIssue.ExpectedMaxDepth(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual depth", aDHIssue.ActualDepth(), "mm");
} else if ...
};
aManager.Print ("issues", PrintFeatureParameters);
Describes a base class of MTK based features.
Definition MTKBase_Feature.hxx:33

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.stp

Part #0 ["Fresamento_CAM1"] - solid #0 has:
    Deep Hole Issue(s): 4
        4 Hole(s) with
          expected max depth: 29.841 mm
          actual depth: 31.3245 mm
    Non Standard Diameter Hole Issue(s): 4
        4 Hole(s) with
          nearest standard diameter: 9 mm
          actual diameter: 8.526 mm
    ...

    Total issues: 24
Model: senthi

Part #0 ["drawing no 1"] - solid #0 has:
    Non Standard Radius Milled Part Floor Fillet Issue(s): 2
        1 Floor Fillet(s) with
          nearest standard radius: 4 mm
          actual radius: 5 mm
        1 Floor Fillet(s) with
          nearest standard radius: 4 mm
          actual radius: 50 mm
    Non Perpendicular Milled Part Shape Issue(s): 1
        1 Shape(s) with
          actual angle: 141.936 deg
    Milled Part External Edge Fillet Issue(s): 1
    Inconsistent Radius Milled Part Floor Fillet Issue(s): 1
        1 Floor Fillet(s) with
          expected radius: 5 mm
          actual radius: 50 mm

    Total issues: 5

Files