MENU

Thursday July 23, 2015 at 11:19am

Recently I took a call on the help-desk from a Customer who, after modifying the File Card associated with SOLIDWORKS files, had a requirement to populate two new variables on that Card with information extracted from an already populated Variable.

Originally the File Card had a Variable called 'Description' which was populated, on creation from a Template, by selecting a standard 'category' from a list which was then concatenated with a manually typed 'description' and separated with a hyphen ( - ). The redesigned File Card now has these two items separated to assist in Search and BOM Reporting requirements. Moving forward this is not a problem, however there are lots of legacy files that need to be updated.

We considered a number of options, two of which involved Customisation of some sort (Dispatch or the creation of a bespoke API Add-In) and decided that we should investigate what could be done out of the box first, using an input formula.

Within the EnterprisePDM Help file, an input formula is defined as having the following purpose... *"Use the Input Formula dialog box to populate an edit box control with a string built up by values from variables linked to other controls on the data card." ...*so it should be capable of doing what we require.

Input formula can be used for two main reasons, the first of these being to display an 'Alias' value based on the value of another Variable on the Card.

The format of an alias in an input formula can be seen as follows:

%VARIABLENAME(VALUE1=ALIAS1, VALUE2=ALIAS2)%

Where VALUE*n* is the entered value in variable VARIABLENAME and ALIAS*n* is the evaluated value that is displayed in the control driven by this input formula.

This works in a similar manner to an Alias List, but has the added benefit of allowing both the source value and alias value to be retained (and therefore usable as Custom Properties in SOLIDWORKS files). There is a limitation however that this formula cannot exceed 1000 chrs so in longer lists, or in shorter lists with longer values, it is not practical.

The second function (and the focus of this Blog) is to manipulate a Variable using string and arithmetic functions to determine the value returned by the input formula.

A full list of Functions is available within the EnterprisePDM Help files and will not be covered here, we can however break them down into three areas.

- Arithmetic Functions: Add / Subtract / Multiply / Divide
- String Functions: Left / Right / Middle/ Token / Length / Find / Reverse
- System Information: Time

Each of these Functions requires one or more inputs to determine the output, for example with Add we supply two values...

Add(<term1>,<term2>)

...the 'terms' here can be existing Variables from the Card, predefined text (numbers in this case) or even a secondary Function.

To solve this particular problem we will need to make use of Length, Find, Left, Right, Add and Subtract and need to be careful how we construct the final function to make sure it evaluates correctly in the right order.

Getting the information to the left of the hyphen is pretty straightforward. We simply need to use a Left function alongside a Find function to locate the hyphen's position within that Variable. To insert a formula, select the Variable Control on the File Card then from the properties panel use the fly out menu alongside the 'Input Formula' box to add the function you require, or the variable you want to add into that formula.

The result looks like this...

Getting the data from the Right of the hyphen is a little more tricky since the 'Find' function works from the left and starts it's count from '0'. There is also a space alongside the hyphen that we want to remove from the final string. To create this variable I therefore need to combine quite a few functions that allow me to determine the complete length of the Description and the position from the left of the hyphen. I then need to Subtract these to determine the letters to the Right of the hyphen whilst also adding '2' to ensure we ignore the hyphen and the 'space' in the result. The final function now looks like....

The other thing that we need to bear in mind when it comes to an Input Formula is that, currently, a Formula will only evaluate if one of the Variables in the equation changes via manual intervention, which in this case means I have to Check Out the Part and make a Change to the 'Description' (this could literally just be hitting SPACE then DELETE) in order for the formulas to both update as below...

Thanks for reading I hope you found this of interest

*By* **Wayne Marshal**l

Customer Support Manager

**Solid Solutions Management Ltd. **

» Categories:
Technical Tips & Tricks, SOLIDWORKS PDM

## Comments

## Leave a Comment

## Human Validation Check

What is 12 - 6?