using System;
namespace drawings
{
class Program
{
static void ExploreSheet(
Sheet theSheet)
{
uint aViewCounter = 0;
while (aViewIt.HasNext())
{
View aView = aViewIt.Next();
Console.WriteLine("---- View <" + aViewCounter + ">");
DrawingElementVisitor aVisitor = new DrawingElementVisitor();
aViewCounter++;
}
}
static void ExploreDrawing(
Drawing 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();
{
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];
{
Console.WriteLine("Failed to read the file " + aSource);
return 1;
}
Drawing aDrawing = aModel.
Drawing();
{
Console.WriteLine("The model doesn't contain a drawing");
return 1;
}
Console.WriteLine(
"Drawing \"" + aModel.
Name() +
"\":");
ExploreDrawing(aDrawing);
return 0;
}
}
{
public override void Apply(
CurveSet theElement)
{
Console.WriteLine("------- CurveSet <" + myCurveSetCounter + ">");
Console.WriteLine(
"--------- number of curves: " + theElement.
NumberOfCurves());
myCurveSetCounter++;
}
public override void Apply(
Hatch theElement)
{
Console.WriteLine("------- Hatch <" + myHatchCounter + ">");
Console.WriteLine(
"--------- number of contours: " + theElement.
NumberOfContours());
uint aNumberOfCurves = 0;
{
aNumberOfCurves += theElement.
Contour(i).NumberOfCurves();
}
Console.WriteLine("--------- number of curves: " + aNumberOfCurves);
Console.WriteLine(
"--------- pattern: " + PatternToString (theElement.
Pattern()));
Console.WriteLine(
"--------- angle: " + theElement.
Angle());
Console.WriteLine(
"--------- scale: " + theElement.
Scale());
myHatchCounter++;
}
public override void Apply(
Text theElement)
{
Console.WriteLine("------- Text <" + myTextCounter + ">");
Console.WriteLine(
"--------- text: \"" + theElement.
GetText() +
"\"");
Console.WriteLine(
"--------- origin: " + PointToString(theElement.
TextOrigin()));
Console.WriteLine(
"--------- rotation: " + theElement.
TextProperties().Rotation());
Console.WriteLine(
"--------- font size: " + theElement.
FontSize());
myTextCounter++;
}
private String PointToString(
Point2d thePoint)
{
return "(" + thePoint.
X() +
"; " + thePoint.
Y() +
")";
}
{
switch (thePattern)
{
default: return "Other";
}
}
private uint myCurveSetCounter = 0;
private uint myHatchCounter = 0;
private uint myTextCounter = 0;
}
}
Describes drawing elements composed of 2D curves.
Definition CurveSet.cs:20
uint NumberOfCurves()
Returns the number of curves currently composing the element.
Definition CurveSet.cs:67
Iterator over sheets of a drawing.
Definition Drawing.cs:108
Represents a single 2D drawing of a model.
Definition Drawing.cs:33
Defines a visitor for drawing elements with empty implementation.
Definition ElementVoidVisitor.cs:20
Represents an area filled with a pattern.
Definition Hatch.cs:37
PatternType
Definition Hatch.cs:196
cadex.Drawing.Hatch.PatternType Pattern()
Returns the pattern of the hatch.
Definition Hatch.cs:133
double Scale()
Returns the scale of the hatch.
Definition Hatch.cs:144
double Angle()
Returns the angle of the hatch.
Definition Hatch.cs:155
uint NumberOfContours()
Returns the number of hatch contours.
Definition Hatch.cs:93
cadex.Drawing.PiecewiseContour Contour(uint theIndex)
Returns the contour.
Definition Hatch.cs:102
Iterates over views of a drawing sheet.
Definition Sheet.cs:177
Represents a single sheet of a model drawing.
Definition Sheet.cs:33
Defines a text for drawing.
Definition Text.cs:19
cadex.Geom.Point2d TextOrigin()
Returns a position of the text on the 2D plane.
Definition Text.cs:181
float FontSize()
Returns size of the font in points.
Definition Text.cs:193
cadex.UTF16String GetText()
Returns a text.
Definition Text.cs:168
cadex.Drawing.Text.Properties TextProperties()
Returns the properties of dimension text.
Definition Text.cs:205
Represents a view on a drawing sheet.
Definition View.cs:24
Defines a 3D point.
Definition Point2d.cs:17
Activates the license key.
Definition LicenseManager.cs:48
Provides MTK data model.
Definition Model.cs:30
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
void SetParameters(cadex.ModelData.ModelReaderParameters theParameters)
Sets reader parameters.
Definition ModelReader.cs:67
Defines parameters of the ModelReader.
Definition ModelReaderParameters.cs:19
void SetReadDrawing(bool theReadDrawing)
Sets whether a drawing should be read from the file.
Definition ModelReaderParameters.cs:98
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.cs:17
Contains classes, types and enums related to drawings.
Definition AngularDimension.cs:12
Contains classes, types, enums, and functions related to geometric entities.
Definition Axis1d.cs:12
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
Definition AngleUnit.cs:12
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition BaseObject.cs:12