30.07.2013 Views

T-FLEX Parametric CAD. Fundamentals. 2D Design

T-FLEX Parametric CAD. Fundamentals. 2D Design

T-FLEX Parametric CAD. Fundamentals. 2D Design

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Fundamentals</strong>. Two-Dimensional <strong>Design</strong><br />

Module Code Window<br />

746<br />

The code window of the created module appears after defining project properties and creating the module in<br />

the Macro editor.<br />

The module’s code window appears as a text editor. The window displays the automatically created program<br />

template with declared references, namespace, class and procedure.<br />

To create a simple macro, you can write just one procedure. Follows below is a macro source code written in<br />

the C# programming language. This macro creates a construction entity – circle and a text string snapped to a<br />

node and wrapped on the circle.<br />

// Declaring references<br />

using System;<br />

using TFlex;<br />

using TFlex.Model;<br />

using TFlex.Model.Model<strong>2D</strong>;<br />

// Declaring class<br />

public class NewMacroClass<br />

{<br />

// Declaring procedure (macro name)<br />

public static void CreateText()<br />

{<br />

//Creating document object – the currently active document<br />

Document document = TFlex.Application.ActiveDocument;<br />

// Opening block of document changes<br />

document.BeginChanges("Creating text");<br />

// Creating text object– string text<br />

LineText text = new LineText(document);<br />

// Creating free nodes in the document, with the coordinates (150,100) and (150,140)<br />

FreeNode node1 = new FreeNode(document,150,100);<br />

FreeNode node2 = new FreeNode(document,150,140);<br />

// Creating circle by the center and a point to pass through<br />

CircleConstruction circle = new CircleConstruction(document);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!