50 1 1MB
The Little Book of Rules DriveWorksXpress and DriveWorks Solo Edition
www.driveworks.co.uk
DriveWorks Ltd.
The Little Book of Rules (DriveWorksXpress and DriveWorks Solo Edition) Copyright © 2011 DriveWorks Ltd. www.driveworks.co.uk All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means without written permission of the author.
2
The Little Book of Rules
About this Book This book has been written as a pocket guide to accompany DriveWorksXpress and DriveWorks Solo Design Automation software products, developed by DriveWorks Ltd. Throughout this book we have used this symbol identify information that is relevant exclusively to DriveWorks Solo.
to
DriveWorksXpress has been incorporated as core functionality into every license of SolidWorks. ‘How to’ Video clips, Tutorials and Sample Projects are available for you at www.driveworksxpress.com DriveWorks Solo is available to purchase worldwide through the SolidWorks/DriveWorks Value Added Reseller Channel. A FREE 30 day license is available to allow you to TRY DriveWorks Solo. Simply register online at www.driveworkssolo.com, request the 30 day license and download the software. ‘How to’ Video Clips, Training Tutorials and Sample Projects are all also available on the web at www.driveworkssolo.com
3
Table of Contents THE LITTLE BOOK OF RULES ................................... 1 ABOUT THIS BOOK ................................................ 3 WHAT IS A RULE? .................................................. 9 WHY ARE RULES GOOD? ......................................10 TYPICAL RULES.....................................................11 WHAT’S IN A RULE? .............................................12 DATA TYPES ............................................................ 13 WHAT CAN GO IN A RULE? ......................................... 14 Operators ......................................................... 14 Functions.......................................................... 15 Literals ............................................................. 16 Names .............................................................. 16 Other Rules ...................................................... 17 MAKING DECISIONS .................................................. 18 IF ...................................................................... 18 Conditions ........................................................ 19 Comparison Operators ..................................... 19 Values .............................................................. 20 Lookup ............................................................. 21 CONCATENATE OR JOIN TEXT, VALUES AND FUNCTIONS .... 23 SPEECH MARKS........................................................ 23 PARENTHESES .......................................................... 24 www.driveworks.co.uk
DriveWorks Ltd.
ADVANCED RULES ............................................... 25 NESTED IF STATEMENT .............................................. 25 NESTING AND COMBINING OTHER FUNCTIONS ................ 28 TYPES OF RULE .................................................... 31 INPUT CONTROL LIST RULES ....................................... 32 FILE NAME RULES..................................................... 32 Unique naming ................................................ 32 Intelligent naming ............................................ 34 Remove Master File Name ............................... 35 Move Master File Name to the End ................. 35 Deleting or suppressing components ............... 36 Replacing components ..................................... 37 Replacing driven components .......................... 38 RELATIVE PATH RULES ............................................... 39 Relative ............................................................ 39 Absolute ........................................................... 40 CONFIGURATION RULES ............................................. 41 Delete unused configurations .......................... 41 DIMENSION RULES ................................................... 42 Linear Dimensions ............................................ 42 Angles .............................................................. 43 Patterns ........................................................... 43 Tolerances ........................................................ 45 FEATURE RULES ....................................................... 47 ADVANCED FEATURE RULES ....................................... 48 Advanced Base Extrude and Base Extrude Thin Parameters ...................................................... 48 Advanced Boss Extrude Parameters ................ 51 Advanced Boss Extrude Thin Parameters......... 53 Advanced Cut Extrude parameters .................. 56 6
The Little Book of Rules
Advanced Cut Extrude Thin parameters .......... 59 Advanced Chamfer parameters ....................... 62 Advanced Fillet parameters ............................. 64 Advanced Text parameters .............................. 66 CUSTOM PROPERTY RULES ......................................... 67 Driving the Color .............................................. 67 Driving the Material......................................... 69 Driving the Texture .......................................... 70 INSTANCE RULES ...................................................... 71 DRAWING RULES ...................................................... 73 File Name Rule ................................................. 73 Relative Path Rule ............................................ 74 Layer State Rule ............................................... 75 Sheet State ....................................................... 75 Sheet Scale Numerator and Denominator Rules ......................................................................... 76 View State Rules .............................................. 77 View Scale Numerator and Denominator Rules78 View Left and Top (Position) Rules................... 79 Breakline Rules................................................. 80 Drawing Custom Property Rules ...................... 81 Annotation Rules ............................................. 81 Dimension Text Rules ....................................... 82 Surface Finish Symbol Rules ............................. 83 Surface Finish Value Rules ............................... 85 Combining Surface Finish Symbol and Value Rules ................................................................ 87 COMMON FUNCTIONS .........................................88 DATE AND TIME FUNCTIONS ....................................... 89 HELPER FUNCTIONS .................................................. 98 7
DriveWorks Ltd.
LOGIC FUNCTIONS .................................................. 101 MATH FUNCTIONS.................................................. 106 TEXT FUNCTIONS .................................................... 126 TABLE FUNCTIONS .................................................. 138 VALIDATION FUNCTIONS .......................................... 145 FILE SYSTEM FUNCTIONS.......................................... 149 APPENDIX ......................................................... 150 NetWorkDaysCustom function WeekendValues: ....................................................................... 150 WeekDay function ReturnType values: .......... 151 WeekNum function ReturnType values:......... 152 WorkDayCustom function Weekend values:.. 153 INDEX................................................................ 154
8
What is a Rule? The dictionary explanation of a rule is:
rule (noun) [rool] 1.
A principle or regulation governing conduct The rules of chess
2.
The customary or normal circumstance The rule rather than the exception
3.
A prescribed mathematical method for performing a calculation or solving a problem If x is > y, add 200
When used as a verb, to rule implies exercising controlling authority over somebody or something. In this book, we will be discussing rules in the sense of a mathematical method for solving a problem. This type of rule works best when it can be defined in words:
We use a support if the length of the gantry is greater than 2 metres
We always have a ¼ inch gap around the door frame, unless the frame is over 4 feet wide, in which case the gap is increased to 5/16th of an inch
Customers in the USA are invoiced in US dollars; customers in Europe are invoiced in Euros. www.driveworks.co.uk
DriveWorks Ltd.
Why are Rules good? Rules are a great way of defining the solution to a given problem. Rules allow your knowledge to be captured and transferred in a simple way to others. Rules can also be a great way of telling a computer how to work something out. This allows computers to perform mundane tasks that humans undertake day in and day out, allowing us to concentrate on more interesting and important responsibilities. If you can put some of your knowledge and intelligence (or rules) into a computer, you can then use that rule to make relevant decisions and actions. Rules can work out many things, and be applied in many different scenarios. Rules can be based on:
A mathematical formula
A conditional or logical statement
The stringing together of lots of text
A lookup in a table on a value you have entered
If you create enough of these rules, then you can automate some of your daily tasks. This is the idea behind DriveWorks. This book aims to help you to understand rules and how they ® can be used in DriveWorks to automate your SolidWorks designs.
10
The Little Book of Rules
Typical Rules Below are some typical rules: A typical mathematical formula would be: (34 + 98) x 5
A logical rule may look something like this: IF(SafeWorkingLoad="500 Kg",200,250)
Stringing text together (also called Concatenation) might look something like this: OpeningWidth & "wide x" & SafeWorkingLoad & "safe working load"
And a lookup on some data might look like this: VLookup(Customer,CustomerTable,3,False)
11
DriveWorks Ltd.
What’s in a Rule? A rule, when broken down, is made up of two elements that are separated by an equals sign: ModelHeight = (234+987)*34
In English this means that the height of the model is equal to 34 multiplied by the result of adding 234 and 987. When we start building a rule we ignore the left hand side, because that is what we are building the rule for. The only part we need to concentrate on is the right hand side – this is what we call "The Rule". Note that in the DriveWorksXpress Rule Builder the "=" must be present at the beginning of the rule. In DriveWorks Solo’s Rule Builder the "=" is implied and is not shown. The right hand side must be written in a certain form (this is called syntax), as otherwise DriveWorks won’t be able to understand it; much like a mathematical equation. The good news is that DriveWorks’ syntax is easy to work with as it is based on Microsoft Excel’s syntax and many people will have used Excel or be familiar with it. Elements of the rule can be fixed values (also called Literals), e.g. 12 + 345 * 234
Or names that refer to values that are entered, or calculated elsewhere: WallGap + OpeningWidth * NumberOfDoors
12
The Little Book of Rules
Data Types Values in a rule, as well as the result of the rule, have a data type. The data types that are available in a rule are:
Numbers, e.g. 3, or -4.7
Text, e.g. "500 Kg"
Booleans, i.e. TRUE or FALSE
There is a fourth data type which is the Date/Time, but these are generally entered as Text and are converted to a Date/Time by a Date/Time function.
13
DriveWorks Ltd.
What can go in a Rule? A rule can be made up of:
Operators
Functions
Literals (e.g. a Number or Text value)
Names (Which refer to values entered or calculated elsewhere)
Other Rules
Operators All mathematical operators can be used in a rule. Parentheses can also be used as you would use them in any mathematical formula. -
subtract
+
add
*
multiply
/
divide
() parenthesis ^
power
Remember to use the asterisk for multiplication (*) and the circumflex for "to the power" – (^) when creating your rules in DriveWorks.
14
The Little Book of Rules Functions Functions are fantastic and are the real power of rules. Functions start with their name; have parentheses, with zero or more arguments in between. Different functions have different numbers of arguments, and some functions can have varying amounts of arguments. So, a typical function would be: ROUNDUP(345.876,2)
This function means that it will round up 345.876 to 2 decimal places. SUM(234,765,912)
This function will add up the three numbers; 234, 765 and 912. Notice that each argument is separated by a comma1. Parentheses always surround the arguments, and the function name always goes before the opening parenthesis: FunctionName(Argument1,Argument2)
The type of value which gets returned depends on the function. For instance, the RoundUp function expects two numbers as the arguments, and will give you back (or return) a number. However, if you use the Left function, you will need to give it two arguments, one as text and one as a number: LEFT("DriveWorks",2)
The Left function will return the result "Dr", which is the first two letters of "DriveWorks". 1 On English language installations, the default system separator is the comma. Other languages may use the semi-colon (;) as the system separator.
15
DriveWorks Ltd. There is a comprehensive list of functions, what arguments they expect, and what they return in the ‘Common Functions’ section of this book. Literals A literal is a value which is typed directly into a rule; it could be a Number, Text, or a Boolean. Numbers exist in rules to be calculated or to assist a function. 9 + 6 (4 ^ 4) * (4 + 2)
Text is used in rules for things like names of files, or configurations. Notice how literal text needs to be encased within speech marks, whereas numbers do not. So returning to an earlier rule: IF(SafeWorkingLoad="500 Kg",200,250)
This is a function with three arguments; the first is comparing the value referred to by a name (SafeWorkingLoad – which isn’t in speech marks) with a literal value ("500 Kg"– which needs to be in speech marks). If the comparison is true, then the function will send back (or return) 200, and if it isn’t (i.e. the comparison is false) then it will return 250. Names Names are references to values which come from somewhere else. For example, the value that is typed into a textbox, an option that is picked from a list of values, or the result of a variable2.
2
Variables are available in DriveWorks Solo only.
16
The Little Book of Rules You’ve already seen names used in various examples, for example: IF(SafeWorkingLoad="500 Kg",200,250)
In this example, SafeWorkingLoad is a name which refers to the selected value in an input control which shows a list of values. Similar to the way the type of a function’s return value depends on the function, the type of a name depends on the value to which it refers. In DriveWorks, names can be used in place of numbers, text, and Booleans, for example: OpeningHeight – 345
where OpeningHeight is a name which refers to the result of a textbox. Keep in mind that if you have not entered or calculated a value for the OpeningHeight then it will actually be seen as an empty text string, and so cannot have 345 taken away from it. Input controls in DriveWorks Solo provide many properties (for example Min, Max and Visibility) in addition to the input value. So to get the input value from the control, the term Return is added to the end of the control name, e.g. MyTextBoxReturn. DriveWorksXpress only provides the value coming from the input control, so all input controls are referred to by the name applied when they were created, e.g. MyTextBox. Other Rules A rule can also be nested – that is, it can contain bits of other rules, for example: ROUNDUP(OpeningHeight - 34, 3)
17
DriveWorks Ltd. In this example, OpeningHeight – 34 is effectively a rule on its own, and the result is used as the first argument of the ROUNDUP function. In the next section, we’ll see another example which chains together IF functions to make decisions.
Making decisions Making decisions is an essential part of many rules, for example, the rule: We use a support if the length of the gantry is greater than 2 metres
shows one type of decision – a choice between two values. Another type of decision is looking up one value in a table and returning another value on the same row. This section shows you how to make decisions in your DriveWorks rules. IF The IF function is probably one of the most common rules used. The IF Function checks whether a specified condition has been met, and returns one value if the condition is True and another value if the condition is False. Use IF to conduct conditional tests on values and formulas. The format of the IF function is as follows; IF(condition , value if condition is TRUE , value if condition is FALSE)
IF initiates the function. Separators divide the condition and the values. Using the IF Wizard in DriveWorks allows you to concentrate on building the condition and the values; the wizard takes care of adding the initiating IF, the opening and closing parentheses and the separators.
18
The Little Book of Rules Conditions Conditions allow you to determine if the User has made a specific selection from a control, or entered a certain number. Conditions can be set to determine when a variable equates to a particular value or is under a certain value. Conditions can evaluate who has logged onto the application. Basically, conditions are arguments that determine if something has happened. A condition exists of three elements; 1.
A reference that has a value
2.
A comparison operator
3.
A result to compare to the referenced value
A condition looks like this: SafeWorkingLoad = "500 Kg"
Here, SafeWorkingLoad is a name referring to an input control that can have a range of test values selected from it. This condition asks if the selected value equals 500 Kg. Comparison Operators The chart below shows the available comparison operators that can be used within a condition: Comparison Operator
Example
=
equal to
SafeWorkingLoad = "500 Kg"
>
greater than
Length > 100
=
greater than or equal to
Length >= 3000
100")will look in the People
Data table in column 1 and return the smallest value that is greater than 100, which is 107.
139
DriveWorks Ltd.
DWVLookup This function searches a table for a specific value in a specified column and returns a value from the same row. DWVLOOKUP([Lookup],[In], [LookupColumn],[ReturnColumn], [MatchType]) DWVLOOKUP(AgeComboBoxReturn,PeopleData,3,2, FALSE)will look in the third column (LookUpColumn) of
the People Data table (In) for an exact match (denoted by FALSE as the MatchType) to the Age Combo Box return value of 42, denoted by LookUp. If a match is found, the function will then look to the second column (implied by ReturnColumn) and return the value in the same row as the match found, which is Sandra Shield. If there were no matches to 42 in the Age Column, then no result will be returned. MatchType can be ‘FALSE’ (where an exact match to the LookUp must be found), or ‘Nearest’ (where the nearest match to the LookUp must be found).
GetTableValue This function returns a value from a table from specified column and row indexes. GETTABLEVALUE([TableName], [RowIndex],[ColumnIndex]) GETTABLEVALUE(PeopleData,2,4)returns the value in row 2, column 4 of the People Data table, which is Male.
140
The Little Book of Rules
ListAll The ListAll function retrieves all data cells from the specified column within the selected table and returns a list. LISTALL([Table],[Column]) LISTALL(PeopleData,3)will look in the People Data
table and retrieve all data from the third column. The list returned for this specific function will be: 25|37|42|21|56
ListAllConditional This function lists all values from a table’s column, where specified conditions are met for each row within that specified column. LISTALLCONDITIONAL([Table],[Column], [ConditionalColumn1],[Condition1]) LISTALLCONDITIONAL(PeopleData,2,3,"