T-FLEX Parametric CAD. Fundamentals. 2D Design

T-FLEX Parametric CAD. Fundamentals. 2D Design T-FLEX Parametric CAD. Fundamentals. 2D Design

scp.s.scptuj.mb.edus.si
from scp.s.scptuj.mb.edus.si More from this publisher
30.07.2013 Views

Upon placing control elements on the form, one needs to define processing of the event of clicking the control element – the button. To do this, select that element on the form, switch to the «Properties» window and set the latter window into the event mode . In the right hand side column of the «Click» event, press , which will create the procedure «button1_Click». The same result could be achieved by double-clicking the control element – the button. In the coming up form code window, one needs to write the procedure «button1_Click». Macros The figure below depicts the form code window containing the function «button1_Click», in which the variables «X1», «Y1», «X2» and «Y2» are assigned values from control elements – the textBox1, textBox2, textBox3 and textBox4 input boxes, and «CreateLine» function (macro) is called. 753

Fundamentals. Two-Dimensional Design 754 After that, let's create a module, in which two functions are to be written. The function «ShowDialog» (a standard function of the development environment) will be displaying the screen form upon launching the macro. The previously defined function «CreateLine» creates 2D nodes, whose coordinates are the values specified by the user via the «FormLine» form dialog, and the segment between those nodes. The module’s source code is shown below. ‘Declaring references Imports System Imports TFlex Imports TFlex.Model Imports TFlex.Model.Model2D ‘Declaring namespace Namespace NewMacroNamespace ‘Declaring class Public Class NewMacroClass ‘The function, which will display the screen form «form» when executed Public Shared Sub ShowDialog() Dim form As LineForm form = new LineForm() form.ShowDialog() End Sub ‘The function with parameters (the macro), which creates a graphic line between two 2D nodes. ‘Coordinates of those nodes are input in the function as the dialog parameters Public Shared Sub CreateLine(ByVal NodeX1 As String, ByVal NodeY1 As String, ByVal NodeX2 As String, ByVal NodeY2 As String) Dim document As Document document = TFlex.Application.ActiveDocument

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

754<br />

After that, let's create a module, in which two functions are to be written. The function «ShowDialog» (a<br />

standard function of the development environment) will be displaying the<br />

screen form upon launching the macro. The previously defined function<br />

«CreateLine» creates <strong>2D</strong> nodes, whose coordinates are the values specified<br />

by the user via the «FormLine» form dialog, and the segment between those<br />

nodes. The module’s source code is shown below.<br />

‘Declaring references<br />

Imports System<br />

Imports TFlex<br />

Imports TFlex.Model<br />

Imports TFlex.Model.Model<strong>2D</strong><br />

‘Declaring namespace<br />

Namespace NewMacroNamespace<br />

‘Declaring class<br />

Public Class NewMacroClass<br />

‘The function, which will display the screen form «form» when executed<br />

Public Shared Sub ShowDialog()<br />

Dim form As LineForm<br />

form = new LineForm()<br />

form.ShowDialog()<br />

End Sub<br />

‘The function with parameters (the macro), which creates a graphic line between two <strong>2D</strong><br />

nodes.<br />

‘Coordinates of those nodes are input in the function as the dialog parameters<br />

Public Shared Sub CreateLine(ByVal NodeX1 As String, ByVal NodeY1 As String,<br />

ByVal NodeX2 As String, ByVal NodeY2 As String)<br />

Dim document As Document<br />

document = TFlex.Application.ActiveDocument

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

Saved successfully!

Ooh no, something went wrong!