using System;
using System.Collections.Generic;
namespace unfolder
{
class Program
{
static int Main(string[] args)
{
string aKey = MTKLicenseKey.Value();
{
Console.WriteLine("Failed to activate Manufacturing Toolkit license.");
return 1;
}
if (args.Length != 2)
{
Console.WriteLine("Usage: " +
$"{System.Reflection.Assembly.GetExecutingAssembly().Location} <input_file> <output_folder>, where:");
Console.WriteLine($" <input_file> is a name of the file to be read");
Console.WriteLine($" <output_folder> is a name of the folder where DXF files with drawing to be written");
return 1;
}
string aSource = args[0];
string aDrawingPath = args[1];
{
Console.WriteLine($"Failed to read the file {aSource}");
return 1;
}
Console.WriteLine($"Model: {aModel.Name()}\n");
var aPartProcessor = new PartProcessor(aDrawingPath);
return 0;
}
{
public PartProcessor(string theDrawingFolderPath)
{
myDrawingFolderPath = theDrawingFolderPath;
}
public override void Apply(
Part thePart)
{
string aPartName = thePart.
Name().
IsEmpty() ?
"noname" : thePart.
Name().
ToString();
var aBodyVec = thePart.
Bodies();
if (aBodyVec.Count != 0)
{
for (int i = 0; i < aBodyVec.Count; ++i)
{
Body aBody = aBodyVec[i];
foreach (var aShape in aShapeIt)
{
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - Solid #{i} has:\n");
ProcessSolid(
Solid.
Cast(aShape), aPartName, i);
}
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - Shell #{i} has:\n");
ProcessShell(
Shell.
Cast(aShape), aPartName, i);
}
}
}
}
++myPartIndex;
}
public void ProcessSolid(
Solid theSolid,
string thePartName,
int theShapeIndex)
{
PrintFlatPatternInfo(aFlatPattern);
UTF16String aDrawingFileName = DrawingFileName(thePartName, theShapeIndex,
"Solid");
WriteToDrawing(aFlatPattern, aDrawingFileName);
}
public void ProcessShell(
Shell theShell,
string thePartName,
int theShapeIndex)
{
PrintFlatPatternInfo(aFlatPattern);
UTF16String aDrawingFileName = DrawingFileName(thePartName, theShapeIndex,
"Shell");
WriteToDrawing(aFlatPattern, aDrawingFileName);
}
public UTF16String DrawingFileName(
string thePartName,
int theShapeIndex,
string theShapeName)
{
string aPartName = "Part " + myPartIndex.ToString() + " [" + thePartName + "]";
string aShapeName = theShapeName + " " + theShapeIndex.ToString();
UTF16String aFileName =
new UTF16String(myDrawingFolderPath +
"/" + aPartName +
" - " + aShapeName +
" - drawing.dxf");
return aFileName;
}
string myDrawingFolderPath;
private int myPartIndex = 0;
}
{
if (theFlatPattern == null)
{
Console.WriteLine($" Failed to create flat pattern.");
return;
}
Console.WriteLine($" Flat Pattern with:");
Console.WriteLine($" length: {theFlatPattern.Length()} mm");
Console.WriteLine($" width: {theFlatPattern.Width()} mm");
Console.WriteLine($" thickness: {theFlatPattern.Thickness()} mm");
Console.WriteLine($" perimeter: {theFlatPattern.Perimeter()} mm");
}
{
if (theFlatPattern == null)
{
Console.WriteLine($" Failed to create flat pattern.");
return;
}
aDrawingParams.
SetIsIgnoreBendingLines(
true);
var aDrawing = theFlatPattern.
ToDrawing(aDrawingParams);
var aDrawingModel =
new Model();
aDrawingModel.SetDrawing(aDrawing);
if (aWriter.Write(aDrawingModel, theFilePath))
{
Console.WriteLine($" A drawing of the flat pattern has been saved to {theFilePath.Data()}");
}
else
{
Console.WriteLine($" Failed to save drawing of the flat pattern to {theFilePath.Data()}");
}
}
}
}
Activates the license key.
Definition LicenseManager.cs:48
Provides a base body class.
Definition Body.cs:19
cadex.UTF16String Name()
Returns a name.
Definition ModelElement.cs:67
Defines a visitor that visits each unique element only once.
Definition ModelElementUniqueVisitor.cs:25
Element visitor with empty implementation.
Definition ModelElementVoidVisitor.cs:20
Provides MTK data model.
Definition Model.cs:30
void Accept(cadex.ModelData.ModelElementVisitor theVisitor)
Accepts a visitor.
Definition Model.cs:179
Reads supported formats, see Import section.
Definition ModelReader.cs:17
Writes supported formats, see Import and Export section.
Definition ModelWriter.cs:17
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 a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.cs:17
bool IsEmpty()
Returns true if the string is empty.
Definition UTF16String.cs:96
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