Refer to the MTK Converter Example
MTKConverter_PartProcessor.cs
using System.Collections.Generic;
namespace mtkconverter
{
class MTKConverter_ProcessData
{
protected MTKConverter_ProcessData(
Part thePart)
{
myPart = thePart;
}
}
{
protected MTKConverter_PartProcessor()
{
myData = new List<MTKConverter_ProcessData>();
}
public List<MTKConverter_ProcessData> myData;
public override void Apply(
Part thePart)
{
bool aPartWasProcessed = false;
var aProcessData = CreateProcessData(thePart);
var aBodyList = thePart.
Bodies();
for (int i = 0; i < aBodyList.Count; ++i)
{
Body aBody = aBodyList[i];
foreach (var aShape in aShapeIt)
{
{
ProcessSolid(aProcessData,
Solid.
Cast(aShape));
aPartWasProcessed = true;
}
{
ProcessShell(aProcessData,
Shell.
Cast(aShape));
aPartWasProcessed = true;
}
}
}
if (aPartWasProcessed)
{
PostProcessPart(thePart);
myData.Add(aProcessData);
}
}
public abstract MTKConverter_ProcessData CreateProcessData(
Part thePart);
public abstract void ProcessSolid(MTKConverter_ProcessData theProcessData,
Solid theSolid);
public abstract void ProcessShell(MTKConverter_ProcessData theProcessData,
Shell theShell);
public abstract void PostProcessPart(
Part thePart);
}
abstract class MTKConverter_VoidPartProcessor : MTKConverter_PartProcessor
{
public MTKConverter_VoidPartProcessor() : base() { }
public override void ProcessSolid(MTKConverter_ProcessData theProcessData,
Solid theSolid) { }
public override void ProcessShell(MTKConverter_ProcessData theProcessData,
Shell theShell) { }
public override void PostProcessPart(
Part thePart) { }
}
}
Provides a base body class.
Definition Body.cs:19
Element visitor with empty implementation.
Definition ModelElementVoidVisitor.cs:20
Defines a leaf node in the scene graph hierarchy.
Definition Part.cs:23
Iterates over subshapes in a shape.
Definition ShapeIterator.cs:58
Defines a connected set of faces.
Definition Shell.cs:29
Defines a topological solid.
Definition Solid.cs:25
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
Definition AngleUnit.cs:12
ShapeType
Defines shape type.
Definition ShapeType.cs:17
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition BaseObject.cs:12
MTKConverter_MachiningProcessor.cs
namespace mtkconverter
{
class MTKConverter_MachiningData : MTKConverter_ProcessData
{
public MTKConverter_MachiningData(
Part thePart) : base(thePart)
{
}
}
class MTKConverter_MachiningProcessor : MTKConverter_VoidPartProcessor
{
{
myOperation = theOperation;
}
public override MTKConverter_ProcessData CreateProcessData(
Part thePart)
{
return new MTKConverter_MachiningData(thePart);
}
public override void ProcessSolid(MTKConverter_ProcessData theProcessData,
Solid theSolid)
{
var aMachiningData = theProcessData as MTKConverter_MachiningData;
aMachiningData.myOperation = myOperation;
anAnalyzer.
AddTool(aFeatureRecognizer);
{
return;
}
aMachiningData.myFeatureList.Append(aData.
FeatureList());
aMachiningData.myIssueList.Append(aDrillingAnalyzer.
Perform(theSolid, aData));
for (uint i = 0; i < aMillingIssueList.
Size(); ++i)
{
{
continue;
}
aMachiningData.myIssueList.Append(anIssue);
}
{
for (uint i = 0; i < aTurningIssueList.
Size(); ++i)
{
aMachiningData.myIssueList.Append(anIssue);
}
}
}
}
}
Provides an interface to run DFM Machining analysis.
Definition DFMMachining_Analyzer.cs:43
cadex.MTKBase_FeatureList Perform(cadex.ModelData.Solid theSolid, cadex.ProgressStatus theProgressStatus)
Runs analyzing process.
Definition DFMMachining_Analyzer.cs:105
Describes deep pocket issue found during cnc machining milling design analysis.
Definition DFMMachining_DeepPocketIssue.cs:39
static new bool CompareType(cadex.MTKBase_Feature theFeature)
Returns true if theFeature is a DFM deep pocket issue.
Definition DFMMachining_DeepPocketIssue.cs:154
Defines parameters used in cnc machining drilling design analysis.
Definition DFMMachining_DrillingAnalyzerParameters.cs:19
Defines parameters used in cnc machining milling design analysis.
Definition DFMMachining_MillingAnalyzerParameters.cs:19
Defines parameters used in cnc machining turning design analysis.
Definition DFMMachining_TurningAnalyzerParameters.cs:19
Describes a base class of MTK based features.
Definition MTKBase_Feature.cs:21
Defines a list of features.
Definition MTKBase_FeatureList.cs:20
uint Size()
Returns the number of elements in the list.
Definition MTKBase_FeatureList.cs:110
cadex.MTKBase_Feature Feature(uint theIndex)
Access specified element.
Definition MTKBase_FeatureList.cs:99
Provides an interface to run several analyzer tools for different types of machining processing.
Definition Machining_Analyzer.cs:21
cadex.Machining_Data Perform(cadex.ModelData.Solid theSolid, cadex.ProgressStatus theProgressStatus)
Runs the analyzing process.
Definition Machining_Analyzer.cs:81
void AddTool(cadex.Machining_AnalyzerTool theTool)
Adds additional tool to run during analyzing process.
Definition Machining_Analyzer.cs:108
Defines data used in Machining analysis.
Definition Machining_Data.cs:19
cadex.MTKBase_FeatureList FeatureList()
Definition Machining_Data.cs:79
bool IsEmpty()
Returns true if the data is empty.
Definition Machining_Data.cs:85
Provides an interface to recognizing machining features tool.
Definition Machining_FeatureRecognizer.cs:24
cadex.Machining_FeatureRecognizerParameters Parameters()
Definition Machining_FeatureRecognizer.cs:115
void SetOperation(cadex.Machining_OperationType theOperation)
Definition Machining_FeatureRecognizerParameters.cs:208
Machining_OperationType
Defines an operation type in machining.
Definition Machining_OperationType.cs:19
MTKConverter_SheetMetalProcessor.cs
using System;
using System.Collections.Generic;
namespace mtkconverter
{
class MTKConverter_UnfoldedPartData
{
public MTKConverter_UnfoldedPartData()
{
myFlatPatterns = new List<SheetMetal_FlatPattern>();
}
public bool IsInit() { return myFlatPatterns.Count > 0; }
public List<SheetMetal_FlatPattern> myFlatPatterns;
}
class MTKConverter_SheetMetalData : MTKConverter_ProcessData
{
public MTKConverter_SheetMetalData(
Part thePart) : base(thePart)
{
myUnfoldedPartData = new MTKConverter_UnfoldedPartData();
}
public bool myIsSheetMetalPart = false;
public MTKConverter_UnfoldedPartData myUnfoldedPartData;
}
class MTKConverter_SheetMetalProcessor : MTKConverter_VoidPartProcessor
{
public MTKConverter_SheetMetalProcessor(
Model theUnfoldedModel) : base()
{
myUnfoldedModel = theUnfoldedModel;
}
private Model myUnfoldedModel;
public override MTKConverter_ProcessData CreateProcessData(
Part thePart)
{
return new MTKConverter_SheetMetalData(thePart);
}
public override void ProcessSolid(MTKConverter_ProcessData theProcessData,
Solid theSolid)
{
Process(theProcessData, anSMData);
}
public override void ProcessShell(MTKConverter_ProcessData theProcessData,
Shell theShell)
{
Process(theProcessData, anSMData);
}
public override void PostProcessPart(
Part thePart)
{
if (myCurrentUnfoldedBody.
Shapes().Count == 0)
{
return;
}
anUnfoldedPart.
AddBody(myCurrentUnfoldedBody);
myUnfoldedModel.
AddRoot(anUnfoldedPart);
}
public void Process(MTKConverter_ProcessData theProcessData,
SheetMetal_Data theData)
{
{
return;
}
var anSMData = theProcessData as MTKConverter_SheetMetalData;
anSMData.myIsSheetMetalPart = true;
MTKConverter_UnfoldedPartData anUnfoldedData = anSMData.myUnfoldedPartData;
if (anUnfoldedShell != null)
{
myCurrentUnfoldedBody.
Append(anUnfoldedShell);
anUnfoldedData.myFlatPatterns.Add(aFlatPattern);
}
for (uint i = 0; i < anIssueList.
Size(); ++i)
{
if (anUnfoldedData.IsInit()
{
anUnfoldedData.myIssueList.Append(anIssue);
}
else
{
anSMData.myIssueList.Append(anIssue);
}
}
}
}
}
cadex.UTF16String Name()
Returns a name.
Definition ModelElement.cs:67
void SetUuid(System.Guid theUuid)
Sets an object uuid.
Definition ModelElement.cs:73
System.Guid Uuid()
Returns an object uuid.
Definition ModelElement.cs:86
Provides MTK data model.
Definition Model.cs:30
void AddRoot(cadex.ModelData.ModelElement theElement)
Adds a root element to the model.
Definition Model.cs:136
void AddBody(cadex.ModelData.Body theBody)
Adds a body.
Definition Part.cs:69
Provides a sheet body composed of faces and shells.
Definition SheetBody.cs:19
MTKConverter_Report.cs
using System.Collections.Generic;
using System.IO;
namespace mtkconverter
{
public struct Point
{
public Point(double theX, double theY, double theZ)
{
X = theX;
Y = theY;
Z = theZ;
}
public double X { get; }
public double Y { get; }
public double Z { get; }
public override string ToString() => $"({FormattedString(X)}, {FormattedString(Y)}, {FormattedString(Z)})";
private string FormattedString(double theValue)
{
System.Globalization.CultureInfo aCI = new System.Globalization.CultureInfo("en-US");
return string.Format(aCI, "{0:0.00}", theValue);
}
}
class MTKConverter_Report
{
public MTKConverter_Report()
{
myData = new List<MTKConverter_ProcessData>();
}
private List<MTKConverter_ProcessData> myData;
public void AddData(MTKConverter_ProcessData theData)
{
myData.Add(theData);
}
{
string aPath = thePath.
ToString();
if (File.Exists(aPath))
{
File.Delete(aPath);
}
try
{
using (StreamWriter aStream = File.CreateText(aPath))
{
JSONWriter aWriter = new JSONWriter(aStream);
aWriter.OpenSection();
aWriter.WriteData("version", "1");
if (myData.Count == 0)
{
aWriter.WriteData("error", "The model doesn't contain any parts.");
}
else
{
aWriter.OpenArraySection("parts");
foreach (MTKConverter_ProcessData aProcessData in myData)
{
aWriter.OpenSection();
WritePartProcessData(aWriter, aProcessData);
aWriter.CloseSection();
}
aWriter.CloseArraySection();
}
aWriter.CloseSection();
}
}
catch
{
return false;
}
return true;
}
private bool WriteFeatures(JSONWriter theWriter, string theGroupName, string theSubgroupName,
{
theWriter.OpenSection(theSubgroupName);
theWriter.WriteData("name", theGroupName);
if (theFeatures.
IsEmpty())
{
theWriter.WriteData("message", theMessageForEmptyList);
}
else
{
aParams.
SetStartIndentLevel(theWriter.NestingLevel());
var aFeaturesJSON = aJSONSerializer.
Serialize(theFeatures);
theWriter.WriteRawData(aFeaturesJSON);
}
theWriter.CloseSection();
return true;
}
{
switch (theOperation)
{
default:
break;
}
return "CNC Machining";
}
{
for (int i = 0, n = theBodies.Count; i < n; ++i)
{
Body aBody = theBodies[i];
if (aShapeIt.HasNext())
{
return true;
}
}
return false;
}
private void WriteThicknessNode(JSONWriter theWriter, string theParamName, double theParamValue,
PointPairType thePoints, string theNodeName)
{
theWriter.OpenSection(theNodeName);
theWriter.WriteData("name", theParamName);
theWriter.WriteData("units", "mm");
theWriter.WriteData("value", theParamValue);
theWriter.WriteData(
"firstPoint",
new Point(aFirstPoint.
X(), aFirstPoint.
Y(), aFirstPoint.
Z()));
theWriter.WriteData("secondPoint", new Point(aSecondPoint.X(), aSecondPoint.Y(), aSecondPoint.Z()));
theWriter.CloseSection();
}
private void WriteUnfoldedPartFeatures(JSONWriter theWriter, MTKConverter_UnfoldedPartData theData)
{
theWriter.OpenSection("featureRecognitionUnfolded");
theWriter.WriteData("name", "Feature Recognition");
if (theData.IsInit())
{
aParams.SetStartIndentLevel(4);
var aFeaturesJSON = aJSONSerializer.Serialize(theData.myFlatPatterns[0]);
theWriter.WriteRawData(aFeaturesJSON);
}
else
{
theWriter.WriteData("message", "Unfolded part wasn't generated.");
}
theWriter.CloseSection();
}
private void WritePartProcessData(JSONWriter theWriter, MTKConverter_ProcessData theProcessData)
{
bool aRes = false;
theWriter.WriteData("partId", theProcessData.myPart.Uuid());
string anErrorMsg = "An error occurred while processing the part.";
if (theProcessData is MTKConverter_MachiningData)
{
MTKConverter_MachiningData aMD = (MTKConverter_MachiningData)theProcessData;
theWriter.WriteData("process", MachiningProcessName(aMD.myOperation));
cadex.Collections.BodyList aBodies = aMD.myPart.Bodies();
if (!aMD.myFeatureList.IsEmpty())
{
WriteFeatures(theWriter, "Feature Recognition", "featureRecognition", aMD.myFeatureList, "");
WriteFeatures(theWriter, "Design for Manufacturing", "dfm", aMD.myIssueList,
"Part contains no DFM improvement suggestions.");
aRes = true;
}
else if (!HasShapes(aBodies,
ShapeType.Solid))
{
anErrorMsg = "The part can't be analyzed due to lack of: BRep representation or solids in BRep representation.";
}
}
else if (theProcessData is MTKConverter_MoldingData)
{
MTKConverter_MoldingData aMoldingData = (MTKConverter_MoldingData)theProcessData;
theWriter.WriteData("process", "Molding Analysis");
cadex.Collections.BodyList aBodies = aMoldingData.myPart.Bodies();
if (!aMoldingData.myFeatureList.IsEmpty())
{
WriteFeatures(theWriter, "Feature Recognition", "featureRecognition", aMoldingData.myFeatureList, "");
WriteFeatures(theWriter, "Design for Manufacturing", "dfm", aMoldingData.myIssueList,
"Part contains no DFM improvement suggestions.");
aRes = true;
}
else if (!HasShapes(aBodies,
ShapeType.Solid))
{
anErrorMsg = "The part can't be analyzed due to lack of: " +
"BRep representation, solids in BRep representation or Poly representations.";
}
}
else if (theProcessData is MTKConverter_SheetMetalData)
{
MTKConverter_SheetMetalData aSMD = (MTKConverter_SheetMetalData)theProcessData;
theWriter.WriteData("process", "Sheet Metal");
cadex.Collections.BodyList aBodies = aSMD.myPart.Bodies();
if (aSMD.myIsSheetMetalPart)
{
WriteFeatures(theWriter, "Feature Recognition", "featureRecognition", aSMD.myFeatureList,
"Part contains no features.");
WriteFeatures(theWriter, "Design for Manufacturing", "dfm", aSMD.myIssueList,
"Part contains no DFM improvement suggestions.");
MTKConverter_UnfoldedPartData anUnfoldedPartData = aSMD.myUnfoldedPartData;
WriteUnfoldedPartFeatures(theWriter, anUnfoldedPartData);
if (anUnfoldedPartData.IsInit())
{
WriteFeatures(theWriter, "Design for Manufacturing", "dfmUnfolded", anUnfoldedPartData.myIssueList,
"Unfolded part contains no DFM improvement suggestions.");
}
aRes = true;
}
{
anErrorMsg = "The part can't be analyzed due to lack of: BRep representation, solids and shells in BRep representation.";
}
else
{
anErrorMsg = "The part wasn't recognized as a sheet metal part.";
}
}
else if (theProcessData is MTKConverter_WallThicknessData)
{
MTKConverter_WallThicknessData aWTD = (MTKConverter_WallThicknessData)theProcessData;
theWriter.WriteData("process", "Wall Thickness Analysis");
cadex.Collections.BodyList aBodies = aWTD.myPart.Bodies();
if (aWTD.myIsInit)
{
WriteThicknessNode(theWriter, "Minimum Thickness", aWTD.myMinThickness, aWTD.myMinThicknessPoints, "minThickness");
WriteThicknessNode(theWriter, "Maximum Thickness", aWTD.myMaxThickness, aWTD.myMaxThicknessPoints, "maxThickness");
aRes = true;
}
else if (!HasShapes(aBodies,
ShapeType.Solid))
{
anErrorMsg = "The part can't be analyzed due to lack of: " +
"BRep representation, solids in BRep representation.";
}
}
else
{
anErrorMsg = "Unrecognized process";
}
if (!aRes)
{
theWriter.WriteData("error", anErrorMsg);
}
}
}
}
Definition BodyList.cs:15
Defines a 3D point.
Definition Point.cs:17
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.cs:17
Serializes MTK entities into a JSON report.
Definition JSONSerializer.cs:17
Configuration for JSON serialization.
Definition JSONSerializerParameters.cs:20
Definition ArrayDouble2.cs:12
Contains classes, types, enums, and functions related to geometric entities.
Definition Axis1d.cs:12
Contains utility classes that can be useful for debugging or configuring global settings.
Definition JSONSerializer.cs:12
MTKConverter_Application.cs
using System;
using System.Collections.Generic;
using System.IO;
namespace mtkconverter
{
enum MTKConverter_ReturnCode
{
MTKConverter_RC_OK = 0,
MTKConverter_RC_UnknownError = 1,
MTKConverter_RC_GeneralException = 2,
MTKConverter_RC_NoValidLicense = 3,
MTKConverter_RC_InvalidArgumentsNumber = 4,
MTKConverter_RC_InvalidArgument = 5,
MTKConverter_RC_UnsupportedVersion = 100,
MTKConverter_RC_UnexpectedFormat = 101,
MTKConverter_RC_UnsupportedFileVariant = 102,
MTKConverter_RC_ImportError = 103,
MTKConverter_RC_ProcessError = 200,
MTKConverter_RC_ExportError = 300,
}
enum MTKConverter_ProcessType
{
MTKConverter_PT_Undefined = -1,
MTKConverter_PT_WallThickness = 0,
MTKConverter_PT_MachiningMilling,
MTKConverter_PT_MachiningTurning,
MTKConverter_PT_Molding,
MTKConverter_PT_SheetMetal
}
enum Mode { NeutralMode, ImportMode, ProcessMode, ExportMode }
class MTKConverter_Application
{
public MTKConverter_Application()
{
}
public MTKConverter_ReturnCode Run(string[] args)
{
if (args.Length == 0 ||
(args[0] == "-?") || (args[0] == "/?") ||
(args[0] == "-h") || (args[0] == "--help"))
{
PrintUsage();
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
if (args.Length < 6)
{
Console.WriteLine("Invalid number of arguments. Please use \"-h\" or \"--help\" for usage information.");
return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgumentsNumber;
}
Mode aMode = Mode.NeutralMode;
MTKConverter_Report aReport = new MTKConverter_Report();
MTKConverter_ReturnCode aRes = MTKConverter_ReturnCode.MTKConverter_RC_OK;
bool aToGenerateScreenshot = true;
for (int i = 0; (i < args.Length) && (aRes == MTKConverter_ReturnCode.MTKConverter_RC_OK); ++i)
{
string anArgument = args[i];
if (anArgument == "--no-screenshot")
{
aToGenerateScreenshot = false;
}
else if (anArgument == "-i")
{
aMode = Mode.ImportMode;
}
else if (anArgument == "-p")
{
aMode = Mode.ProcessMode;
}
else if (anArgument == "-e")
{
aMode = Mode.ExportMode;
}
else
{
try
{
if (aMode == Mode.ImportMode)
{
aRes = Import(anArgument, aModel);
}
else if (aMode == Mode.ProcessMode)
{
aRes = Process(anArgument, aModel, aReport, aProcessModel);
}
else if (aMode == Mode.ExportMode)
{
aRes = Export(anArgument, aModel, aToGenerateScreenshot, aReport, aProcessModel);
}
else
{
Console.WriteLine($"ERROR!: Invalid argument {anArgument}. Exiting");
Console.WriteLine($"Type {System.Reflection.Assembly.GetExecutingAssembly().Location} -h for help.");
return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgument;
}
Console.WriteLine("Done.");
}
catch (Exception anE)
{
Console.WriteLine($"Failed.\nERROR: {anE.Message}");
return MTKConverter_ReturnCode.MTKConverter_RC_GeneralException;
}
}
}
return aRes;
}
public void PrintUsage()
{
Console.WriteLine("Usage:");
Console.WriteLine("MTKConverter -i <import_file> -p <process> --no-screenshot -e <export_folder>\n");
Console.WriteLine("Arguments:");
Console.WriteLine(" <import_file> - import file name");
Console.WriteLine(" <process> - manufacturing process or algorithm name");
Console.WriteLine(" <export_folder> - export folder name");
Console.WriteLine(" --no-screenshot - disable screenshot generation (optional)");
Console.WriteLine("Example:");
Console.WriteLine("MTKConverter -i C:\\models\\test.step -p machining_milling -e C:\\models\\test");
Console.WriteLine("\nRecognized processes:");
Console.WriteLine(" wall_thickness :\t Wall Thickness analysis");
Console.WriteLine(" machining_milling:\t CNC Machining Milling feature recognition and DFM analysis");
Console.WriteLine(" machining_turning:\t CNC Machining Lathe+Milling feature recognition and DFM analysis");
Console.WriteLine(" molding :\t Molding feature recognition and DFM analysis");
Console.WriteLine(" sheet_metal :\t Sheet Metal feature recognition, unfolding and DFM analysis");
}
private MTKConverter_ProcessType ProcessType(string theProcessName)
{
var aProcessDictionary = new Dictionary<string, MTKConverter_ProcessType>()
{
{ "wall_thickness", MTKConverter_ProcessType.MTKConverter_PT_WallThickness},
{ "machining_milling", MTKConverter_ProcessType.MTKConverter_PT_MachiningMilling},
{ "machining_turning", MTKConverter_ProcessType.MTKConverter_PT_MachiningTurning},
{ "molding", MTKConverter_ProcessType.MTKConverter_PT_Molding},
{ "sheet_metal", MTKConverter_ProcessType.MTKConverter_PT_SheetMetal}
};
MTKConverter_ProcessType aProcess = MTKConverter_ProcessType.MTKConverter_PT_Undefined;
bool aRes = aProcessDictionary.TryGetValue(theProcessName, out aProcess);
if (aRes)
{
return aProcess;
}
return MTKConverter_ProcessType.MTKConverter_PT_Undefined;
}
private MTKConverter_ReturnCode Import(
string theFilePath,
Model theModel)
{
Console.Write($"Importing {theFilePath}...");
if (!aReader.
Read(aFilePath, theModel))
{
Console.WriteLine($"\nERROR: Failed to import {theFilePath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ImportError;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
private bool CreateOriginModelThumbnail(
UTF16String theFilePath,
Model theModel)
{
aParameters.
SetImageHeight(800);
aParameters.
SetImageWidth(600);
aParameters.
SetViewCameraProjection(CameraProjectionType.Perspective);
aParameters.
SetViewCameraPosition(CameraPositionType.Default);
aParameters.
SetViewIsFitAll(
true);
aParameters.
SetViewAntialiasing(AntialiasingMode.High);
aWriter.
SetParameters(aParameters);
bool aRes = aWriter.
WriteFile(theModel, theFilePath);
return aRes;
}
private void ApplyProcessorToModel(
Model theModel, MTKConverter_Report theReport, MTKConverter_PartProcessor theProcessor)
{
foreach (MTKConverter_ProcessData i in theProcessor.myData)
{
theReport.AddData(i);
}
}
private MTKConverter_ReturnCode Process(
string theProcess,
Model theModel,
MTKConverter_Report theReport,
Model theProcessModel)
{
Console.Write($"Processing {theProcess}...");
MTKConverter_ProcessType aProcessType = ProcessType(theProcess);
switch (aProcessType)
{
case MTKConverter_ProcessType.MTKConverter_PT_WallThickness:
{
MTKConverter_WallThicknessProcessor aProcessor = new MTKConverter_WallThicknessProcessor(800);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_MachiningMilling:
{
MTKConverter_MachiningProcessor aProcessor =
new MTKConverter_MachiningProcessor(
Machining_OperationType.Machining_OT_Milling);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_MachiningTurning:
{
MTKConverter_MachiningProcessor aProcessor =
new MTKConverter_MachiningProcessor(
Machining_OperationType.Machining_OT_LatheMilling);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_Molding:
{
theProcessModel.
SetName(aProcessModelName);
MTKConverter_MoldingProcessor aProcessor = new MTKConverter_MoldingProcessor(theProcessModel);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_SheetMetal:
{
theProcessModel.
SetName(aProcessModelName);
MTKConverter_SheetMetalProcessor aProcessor = new MTKConverter_SheetMetalProcessor(theProcessModel);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_Undefined:
default: return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgument;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
private MTKConverter_ReturnCode Export(
string theFolderPath,
Model theModel,
bool theToGenerateScreenshot, MTKConverter_Report theReport,
Model theProcessModel)
{
Console.Write($"Exporting {theFolderPath}...");
{
Console.WriteLine($"\nERROR: Failed to export {aModelPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
if (theToGenerateScreenshot && !CreateOriginModelThumbnail(aThumbnailPath, theModel))
{
Console.WriteLine($"\nERROR: Failed to create thumbnail {aThumbnailPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
{
{
Console.WriteLine($"\nERROR: Failed to export {aProcessModelPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
}
Directory.CreateDirectory(theFolderPath);
if (!theReport.WriteToJSON(aJsonPath))
{
Console.WriteLine($"\nERROR: Failed to create JSON file {aJsonPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
}
}
Defines a visitor that visits each unique element only once.
Definition ModelElementUniqueVisitor.cs:25
void Accept(cadex.ModelData.ModelElementVisitor theVisitor)
Accepts a visitor.
Definition Model.cs:179
void AssignUuids()
Assigns uuid's (persistent id's) to scene graph elements and part representations (if not assigned ye...
Definition Model.cs:174
FileFormatType
Defines supported formats for export.
Definition Model.cs:235
void SetName(cadex.UTF16String theName)
Sets a model name.
Definition Model.cs:84
bool IsEmpty()
Returns true if the model is empty.
Definition Model.cs:103
cadex.UTF16String Name()
Returns a model name.
Definition Model.cs:93
Reads supported formats, see Import section.
Definition ModelReader.cs:17
bool Read(cadex.UTF16String theFilePath, cadex.ModelData.Model theModel)
Reads the file at the specified path into the specified model.
Definition ModelReader.cs:86
Defines color background style.
Definition ColorBackgroundStyle.cs:17
Defines an RGBA color.
Definition Color.cs:17
Writes an image file with graphical content of a model.
Definition ImageWriter.cs:17
Defines parameters of the ImageWriter.
Definition ImageWriterParameters.cs:17
Contains classes, types, enums, and functions related to image generation.
Definition AntialiasingMode.cs:12
Program.cs
using System;
namespace mtkconverter
{
class Program
{
static int Main(string[] args)
{
string aKey = MTKLicenseKey.Value();
{
Console.WriteLine("Failed to activate Manufacturing Toolkit license.");
return 1;
}
MTKConverter_Application anApp = new MTKConverter_Application();
return (int)anApp.Run(args);
}
}
}
Activates the license key.
Definition LicenseManager.cs:48