Difference between revisions of "Bend Reduction Editor"
(→Creating New Variables) |
(→Bend Reduction Editor Screen) |
||
(38 intermediate revisions by one user not shown) | |||
Line 5: | Line 5: | ||
=== Bend Reduction Editor Screen === | === Bend Reduction Editor Screen === | ||
+ | |||
+ | This editor allows you to enter a formula that reduces the arc lengths of the bends in order to correctly predict an accurate [[cut-length]]. | ||
+ | <br><br> | ||
Predicting elongation in a tube shape requires complex mathematics that changes per customer application. Benderlink for SolidWorks now allows operators to program their Bend Reduction formula into the program. This is the Bend Reduction Function editor: | Predicting elongation in a tube shape requires complex mathematics that changes per customer application. Benderlink for SolidWorks now allows operators to program their Bend Reduction formula into the program. This is the Bend Reduction Function editor: | ||
Line 12: | Line 15: | ||
<br> | <br> | ||
<br> | <br> | ||
− | |||
+ | === Editor Controls === | ||
+ | The editor is very powerful because it allows you to enter action Pascal code to define the function that returns the adjusted arc lengths. The editor supports Ctrl-Y for deleting lines. Also Ctrl-C and Ctrl-X type features are supported. To insert a function from the box on the right, select the position in the editor, then double-click on the function in the list. | ||
+ | <br> | ||
+ | |||
+ | === File in Editor and Enable State === | ||
+ | |||
+ | Enable State: The check box allows you to control if the bend reduction formula is used to calculate a new reduced cut-length. | ||
+ | <br><br> | ||
+ | File in Editor: The code as it is saved in this editor will be automatically loaded each time Benderlink starts. The filename at the top indicates what "pas" file will be loaded each time. Different Pascal files can be saved to allow for quickly changing the formula. The last Pascal file is always the one used when the program is loaded again. | ||
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | [[image:Blinksw_fileineditor.jpg]] | ||
+ | <br> | ||
+ | <br> | ||
=== Sample Program === | === Sample Program === | ||
Line 30: | Line 47: | ||
</pre> | </pre> | ||
</font> | </font> | ||
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | === Creating New Variables === | ||
+ | |||
+ | Pascal is a strongly typed language that requires variables to be predefined in the "var" section like this: | ||
+ | |||
+ | <pre> | ||
+ | var | ||
+ | BendAllowance: real; | ||
+ | NewArc: real; | ||
+ | </pre> | ||
+ | Each variable is given a name like "BendAllowance" then its type is defined with a colon and the type. A few simple examples are: | ||
+ | <pre> | ||
+ | var | ||
+ | iValue: integer; | ||
+ | bValue: boolean; | ||
+ | rValue: real; | ||
+ | szVal: string | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | All of this is placed before the "begin" statement. | ||
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | |||
+ | === Begin and End === | ||
+ | |||
+ | Pascal starts and ends the actual formula section with the "begin" and "end" statements. They are required. Note that the "end;" statement has a semi-colon following. | ||
+ | <pre> | ||
+ | begin | ||
+ | |||
+ | end;</pre> | ||
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | === Assignment === | ||
+ | |||
+ | Assignment means "assigning a value to a variable." In Pascal, this is done using the ":=" symbol. The "=" alone is used for constants (which are not variable). So wherever you see the ":=" characters, you know that the code is assigning a value. BendAllowance is a "real" type variable and it is assigned the value of 0.64: | ||
+ | <pre> | ||
+ | BendAllowance := 0.64; | ||
+ | </pre> | ||
+ | |||
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | |||
+ | |||
+ | === End of Statement Semi-Colon === | ||
+ | |||
+ | Pascal uses the semi-colon to indicate the end of a statement. This allows for multi-line statements in Pascal. (BASIC uses the Carriage Return character to indicate the end of a line - so a statement can only be on a single line.) | ||
+ | <br><br> | ||
+ | Here are samples of how this works in Pascal. All of these have the same result because the semi-colon is used to indicate the end of the statement. | ||
+ | |||
+ | <pre> | ||
+ | BendAllowance := 0.64; | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | BendAllowance | ||
+ | := 0.64; | ||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | BendAllowance | ||
+ | := | ||
+ | 0.64; | ||
+ | </pre> | ||
<br> | <br> | ||
Line 38: | Line 124: | ||
The value returned is called the "result". At the bottom of the code (just before the "end;" line), the... | The value returned is called the "result". At the bottom of the code (just before the "end;" line), the... | ||
<pre>result := NewArc;</pre>...line of code assigns the value in the NewArc variable to each arc length in Benderlink during conversion. | <pre>result := NewArc;</pre>...line of code assigns the value in the NewArc variable to each arc length in Benderlink during conversion. | ||
+ | <br> | ||
+ | The function result type should be either "real", "double", or "extended" - which are all floating point types. | ||
<br> | <br> | ||
<br> | <br> | ||
Line 56: | Line 144: | ||
<br> | <br> | ||
− | |||
− | + | === Math Operators === | |
+ | Use the standard operators to form your formula: | ||
+ | |||
+ | # "+" and "-" are standard add and subtract | ||
+ | # "*" is multiplication | ||
+ | # "/" is floating point division | ||
+ | # "div" is integer division | ||
+ | # "(" and ")" control the order of operation | ||
+ | # "<" or ">" for "less than" and "greater than" conditional operations | ||
+ | # "<=" or ">=" for "less than or equal to" and "greater than or equal to" conditional operations | ||
+ | |||
+ | The main formula has a few of these operators: | ||
+ | <font size=1> | ||
+ | <pre> | ||
+ | NewArc := ((BendAllowance * blinksw(OD) + (PI/2 * (blinksw(CLR)-0.5 * blinksw(OD) ))) / 90) * blinksw(BENDANGLE); | ||
+ | </pre> | ||
+ | </font> | ||
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | === Conditional Operators === | ||
+ | |||
+ | It is also possible to use conditions like "If-Then" in Pascal. Here is an example: | ||
+ | |||
+ | This formula uses the If-Then condition to use different Bend Allowances depending on the bend angle. | ||
+ | <font size=1> | ||
<pre> | <pre> | ||
var | var | ||
BendAllowance: real; | BendAllowance: real; | ||
NewArc: real; | NewArc: real; | ||
+ | begin | ||
+ | BendAllowance1 := 0.64; | ||
+ | BendAllowance2 := 0.65; | ||
+ | |||
+ | If blinksw(BENDANGLE) > 90 then | ||
+ | begin | ||
+ | NewArc := ((BendAllowance2 * blinksw(OD) + (PI/2 * (blinksw(CLR)-0.5 * blinksw(OD) ))) / 90) * blinksw(BENDANGLE); | ||
+ | end else | ||
+ | begin | ||
+ | NewArc := ((BendAllowance1 * blinksw(OD) + (PI/2 * (blinksw(CLR)-0.5 * blinksw(OD) ))) / 90) * blinksw(BENDANGLE); | ||
+ | end; | ||
+ | |||
+ | result := NewArc; | ||
+ | end; | ||
</pre> | </pre> | ||
− | + | </font> | |
+ | <br> | ||
+ | <br> | ||
+ | |||
+ | === Notes In Code === | ||
+ | |||
+ | Pascal allows these methods for putting note lines into code: | ||
+ | |||
+ | Use two forward slashes makes a line into a note line: | ||
<pre> | <pre> | ||
− | + | // This is a note line | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
<br> | <br> | ||
<br> | <br> | ||
+ | Use curly brackets for multiple lines of notes: | ||
+ | <pre> | ||
+ | {This is a note line} | ||
+ | </pre> | ||
− | + | or | |
− | |||
<pre> | <pre> | ||
− | + | {This is note line 1 | |
− | + | This is note line 2 | |
− | + | This is note line 3} | |
+ | </pre> | ||
<br> | <br> | ||
<br> | <br> | ||
Line 168: | Line 299: | ||
Tanh() | Tanh() | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | |||
+ | ==Other Pages== | ||
+ | |||
+ | *Back to the [[Benderlink for SolidWorks]] page | ||
+ | *The [[Benderlink for SolidWorks 1.71]] update page is the version where this feature was initially described. |
Latest revision as of 19:50, 25 March 2008
Bend Reduction Editor Screen
This editor allows you to enter a formula that reduces the arc lengths of the bends in order to correctly predict an accurate cut-length.
Predicting elongation in a tube shape requires complex mathematics that changes per customer application. Benderlink for SolidWorks now allows operators to program their Bend Reduction formula into the program. This is the Bend Reduction Function editor:
Editor Controls
The editor is very powerful because it allows you to enter action Pascal code to define the function that returns the adjusted arc lengths. The editor supports Ctrl-Y for deleting lines. Also Ctrl-C and Ctrl-X type features are supported. To insert a function from the box on the right, select the position in the editor, then double-click on the function in the list.
File in Editor and Enable State
Enable State: The check box allows you to control if the bend reduction formula is used to calculate a new reduced cut-length.
File in Editor: The code as it is saved in this editor will be automatically loaded each time Benderlink starts. The filename at the top indicates what "pas" file will be loaded each time. Different Pascal files can be saved to allow for quickly changing the formula. The last Pascal file is always the one used when the program is loaded again.
Sample Program
var BendAllowance: real; NewArc: real; begin BendAllowance := 0.64; NewArc := ((BendAllowance * blinksw(OD) + (PI/2 * (blinksw(CLR)-0.5 * blinksw(OD) ))) / 90) * blinksw(BENDANGLE); //MessageDlg('New Arc Length: ' + floattostr(NewArc), mtInformation, [mbOK], 0); result := NewArc; end;
Creating New Variables
Pascal is a strongly typed language that requires variables to be predefined in the "var" section like this:
var BendAllowance: real; NewArc: real;
Each variable is given a name like "BendAllowance" then its type is defined with a colon and the type. A few simple examples are:
var iValue: integer; bValue: boolean; rValue: real; szVal: string
All of this is placed before the "begin" statement.
Begin and End
Pascal starts and ends the actual formula section with the "begin" and "end" statements. They are required. Note that the "end;" statement has a semi-colon following.
begin end;
Assignment
Assignment means "assigning a value to a variable." In Pascal, this is done using the ":=" symbol. The "=" alone is used for constants (which are not variable). So wherever you see the ":=" characters, you know that the code is assigning a value. BendAllowance is a "real" type variable and it is assigned the value of 0.64:
BendAllowance := 0.64;
End of Statement Semi-Colon
Pascal uses the semi-colon to indicate the end of a statement. This allows for multi-line statements in Pascal. (BASIC uses the Carriage Return character to indicate the end of a line - so a statement can only be on a single line.)
Here are samples of how this works in Pascal. All of these have the same result because the semi-colon is used to indicate the end of the statement.
BendAllowance := 0.64;
BendAllowance := 0.64;
BendAllowance := 0.64;
The Function's Result
The value returned is called the "result". At the bottom of the code (just before the "end;" line), the...
result := NewArc;...line of code assigns the value in the NewArc variable to each arc length in Benderlink during conversion.
The function result type should be either "real", "double", or "extended" - which are all floating point types.
Accessing Benderlink's Values
There are three special functions that insert values from the bend data during conversion:
Insert the Outer Diameter
blinksw(OD)
Insert the Centerline Radius
blinksw(CLR)
Insert the Bend Angle
blinksw(BENDANGLE)
Each of these are should be formed as a complete word with no spaces between any of the characters.
Math Operators
Use the standard operators to form your formula:
- "+" and "-" are standard add and subtract
- "*" is multiplication
- "/" is floating point division
- "div" is integer division
- "(" and ")" control the order of operation
- "<" or ">" for "less than" and "greater than" conditional operations
- "<=" or ">=" for "less than or equal to" and "greater than or equal to" conditional operations
The main formula has a few of these operators:
NewArc := ((BendAllowance * blinksw(OD) + (PI/2 * (blinksw(CLR)-0.5 * blinksw(OD) ))) / 90) * blinksw(BENDANGLE);
Conditional Operators
It is also possible to use conditions like "If-Then" in Pascal. Here is an example:
This formula uses the If-Then condition to use different Bend Allowances depending on the bend angle.
var BendAllowance: real; NewArc: real; begin BendAllowance1 := 0.64; BendAllowance2 := 0.65; If blinksw(BENDANGLE) > 90 then begin NewArc := ((BendAllowance2 * blinksw(OD) + (PI/2 * (blinksw(CLR)-0.5 * blinksw(OD) ))) / 90) * blinksw(BENDANGLE); end else begin NewArc := ((BendAllowance1 * blinksw(OD) + (PI/2 * (blinksw(CLR)-0.5 * blinksw(OD) ))) / 90) * blinksw(BENDANGLE); end; result := NewArc; end;
Notes In Code
Pascal allows these methods for putting note lines into code:
Use two forward slashes makes a line into a note line:
// This is a note line
Use curly brackets for multiple lines of notes:
{This is a note line}
or
{This is note line 1 This is note line 2 This is note line 3}
Mathematical Function List
These are the available math functions:
blinksw(OD) blinksw(CLR) blinksw(BENDANGLE) sqr() sqrt() arctan() cos() sin() tan() abs() exp() ln() log() int() frac() trunc() round() arcsin() arccos() sign() not() PI ArcCos() ArcCosh() ArcCot() ArcCotH() ArcCsc() ArcCscH() ArcSec() ArcSecH() ArcSin() ArcSinh() ArcTan2() ArcTanh() Cosecant() Cosh() Cot() Cotan() CotH() Csc() CscH() CycleToDeg() CycleToGrad() CycleToRad() DegToCycle() DegToGrad() DegToRad() GradToCycle() GradToDeg() GradToRad() Hypot() IntPower() IsInfinite() IsNan() Ldexp() LnXP1() Log10() Log2() LogN() Max( Min() Power() RadToCycle() RadToDeg() RadToGrad() RandG() RandomRange() Sec() Secant() SecH() Sinh() Tan() Tanh()
Other Pages
- Back to the Benderlink for SolidWorks page
- The Benderlink for SolidWorks 1.71 update page is the version where this feature was initially described.