Driving Global Variables with an External Text File

By Tyler Braginton

If you are a fairly advanced SOLIDWORKS user, you have probably used Global Variables at some point. Global Variables are the easiest way allow certain dimensions to change quickly without having to go in and modify them individually. Here I have a block that is being driven by 5 Global Variables.



If I open the Equation Manger by going to Tools > Equations, I can see and control the table of Global Variables. This is where you can change the value of each Global Variable to create a whole new model variation. However, there is an underutilized option from the Equations Manager which will let you take Global Variables one step further, Link to External File. This will give you the ability to control Global Variables or equations from a text or database file.

Equations, global variables and dimensions menu

When you turn this option on, you can choose to create the file from scratch or link to an existing file. Creating a new file will let you choose where to save it, and which of the Global Variable or equations you want to control with the text file. Once you have that set, click Link to establish the relationship.

link equations menu

If you create a new file, the current values will automatically populate the new file. The format for the text file is simple, “Global Variable Name” = Value, each one gets its own row. It will look something like this...

equations - notepad menu

Now you will control the selected items from the text file instead of the Equations Manager. In fact if you look at the Equations Manager, you will see that those items are now locked out and show the linked to file icon.

global variables menu

Testing it out, I will change some of the values on the text file. Make sure to save the text file once you have made your changes. Then switch back to SOLIDWORKS, if the Equations Manager is still open, just close it down. Your model should automatically rebuild and reflect the changes, if not you can force a rebuild with Ctrl+B.


So why would you want to control your Global Variables from an external file? Often times, manipulating the values can be easier on a text file instead of in the Equations Manager. Also the text file can be modified by a non SOLIDWORKS user and the model will update the next time it is opened, and this can free up a license on crowded networks. Another use case is automatically generated text files from sources like Excel. An Excel workbook or other tool could be used to handle complex equations to determine the Global Variable values and then exported to a text file that can be used to control a model. With the easy linking of Global Variables to an external text file, the possibilities of what you will model are endless.

If you have any questions regarding the information above, please contact Hawk Ridge Systems Technical Support at 1-877-266-4469  (US), 1-866-587-6803  (CAN), or support@hawkridgesys.com.

Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.