using System;
namespace drawings
{
class Program
{
static void ExploreSheet(Sheet theSheet)
{
Sheet.ViewIterator aViewIt = new Sheet.ViewIterator(theSheet);
uint aViewCounter = 0;
while (aViewIt.HasNext())
{
View aView = aViewIt.Next();
Console.WriteLine("---- View <" + aViewCounter + ">");
DrawingElementVisitor aVisitor = new DrawingElementVisitor();
aView.Accept(aVisitor);
aViewCounter++;
}
}
static void ExploreDrawing(Drawing theDrawing)
{
Drawing.SheetIterator aSheetIt = new Drawing.SheetIterator(theDrawing);
uint aSheetCounter = 0;
while(aSheetIt.HasNext())
{
Sheet aSheet = aSheetIt.Next();
Console.WriteLine("-- Sheet <" + aSheetCounter + ">");
ExploreSheet(aSheet);
aSheetCounter++;
}
}
static int Main(string[] args)
{
string aKey = MTKLicenseKey.Value();
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate Manufacturing Toolkit license.");
return 1;
}
if (args.Length != 1)
{
Console.WriteLine("Usage: " +
$"{System.Reflection.Assembly.GetExecutingAssembly().Location} <input_file>, where:");
Console.WriteLine($" <input_file> is a name of the file to be read");
Console.WriteLine($"");
return 1;
}
string aSource = args[0];
ModelReaderParameters aReaderParameters = new ModelReaderParameters();
aReaderParameters.SetReadDrawing(true);
ModelReader aReader = new ModelReader();
aReader.SetParameters(aReaderParameters);
Model aModel = new Model();
if (!aReader.Read(new UTF16String(aSource), aModel))
{
Console.WriteLine("Failed to read the file " + aSource);
return 1;
}
Drawing aDrawing = aModel.Drawing();
if (aDrawing.IsNull())
{
Console.WriteLine("The model doesn't contain a drawing");
return 1;
}
Console.WriteLine("Drawing \"" + aModel.Name() + "\":");
ExploreDrawing(aDrawing);
return 0;
}
}
class DrawingElementVisitor : ElementVoidVisitor
{
public override void Apply(CurveSet theElement)
{
Console.WriteLine("------- CurveSet <" + myCurveSetCounter + ">");
Console.WriteLine("------- number of curves: " + theElement.NumberOfCurves());
myCurveSetCounter++;
}
private uint myCurveSetCounter = 0;
}
}
Contains classes, types and enums related to drawings.
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.