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

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.

class PartProcessor : SolidProcessor
{
public PartProcessor(Machining_OperationType theOperation)
{
myOperation = theOperation;
}
public override void ProcessSolid(Solid theSolid)
{
// Find features
var aData = new Machining_Data();
var aParam = new Machining_FeatureRecognizerParameters();
aParam.SetOperation(myOperation);
var aRecognizer = new Machining_FeatureRecognizer(aParam);
aRecognizer.Perform(theSolid, aData);
// Run drilling analyzer for found features
var aDrillingParameters = new DFMMachining_DrillingAnalyzerParameters();
var aDrillingAnalyzer = new DFMMachining_Analyzer(aDrillingParameters);
var anIssueList = aDrillingAnalyzer.Perform(theSolid, aData);
// Run milling analyzer for found features
var aMillingParameters = new DFMMachining_MillingAnalyzerParameters();
var aMillingAnalyzer = new DFMMachining_Analyzer(aMillingParameters);
var aMillingIssueList = aMillingAnalyzer.Perform(theSolid, aData);
// Combine issue lists
CombineFeatureLists(anIssueList, aMillingIssueList);
var aTurningIssueList = new MTKBase_FeatureList();
if (myOperation == Machining_OperationType.Machining_OT_LatheMilling)
{
// Run turning analyzer for found features
var aTurninigParameters = new DFMMachining_TurningAnalyzerParameters();
var aTurningAnalyzer = new DFMMachining_Analyzer(aTurninigParameters);
aTurningIssueList = aTurningAnalyzer.Perform(theSolid, aData);
// Combine issue lists
CombineFeatureLists(anIssueList, aTurningIssueList);
}
PrintIssues(anIssueList);
}
private void CombineFeatureLists(MTKBase_FeatureList theFirst, MTKBase_FeatureList theSecond)
{
for (uint i = 0; i < theSecond.Size(); ++i) {
MTKBase_Feature aFeature = theSecond.Feature(i);
if (myOperation == Machining_OperationType.Machining_OT_LatheMilling
&& DFMMachining_MillingIssue.CompareType(aFeature)
&& !DFMMachining_DeepPocketIssue.CompareType(aFeature))
{
continue;
}
theFirst.Append(aFeature);
}
}
private Machining_OperationType myOperation = Machining_OperationType.Machining_OT_Undefined;
}
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 aVisitor (aPartProcessor);
aModel.Accept(aVisitor);

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.

for (uint i = 0; i < theIssueList.Size(); ++i)
{
MTKBase_Feature anIssue = theIssueList.Feature (i);
if (DFMMachining_SmallDiameterHoleIssue.CompareType(anIssue))
{
aManager.AddFeature("Small Diameter Hole Issue(s)", "Hole(s)", true, anIssue);
}
else if (DFMMachining_DeepHoleIssue.CompareType(anIssue))
{
aManager.AddFeature("Deep Hole Issue(s)", "Hole(s)", true, anIssue);
}
else if ...
}

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.

Action<MTKBase_Feature> PrintFeatureParameters = theIssue =>
{
if (DFMMachining_SmallDiameterHoleIssue.CompareType(theIssue))
{
DFMMachining_SmallDiameterHoleIssue aSDHIssue = DFMMachining_SmallDiameterHoleIssue.Cast(theIssue);
FeatureGroupManager.PrintFeatureParameter("expected min diameter", aSDHIssue.ExpectedMinDiameter(), "mm");
FeatureGroupManager.PrintFeatureParameter("actual diameter", aSDHIssue.ActualDiameter(), "mm");
}
else if (DFMMachining_DeepHoleIssue.CompareType(theIssue))
{
DFMMachining_DeepHoleIssue aDHIssue = DFMMachining_DeepHoleIssue.Cast(theIssue);
FeatureGroupManager.PrintFeatureParameter("expected max depth", aDHIssue.ExpectedMaxDepth(), "mm");
FeatureGroupManager.PrintFeatureParameter("actual depth", aDHIssue.ActualDepth(), "mm");
}
else ...
};
aManager.Print("issues", PrintFeatureParameters);

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