Cancel
Showing results for
Did you mean:

# How to drive NX expressions from a spreadsheet

Solution Partner Valued Contributor

## Quick Overview

This Tips & Trick shows how to drive expressions in NX from an external spreadsheet.

## Core content

Demo Video

When performing what-if or parametric studies, you may have to repeat simulations with different values of multiple parameters. These parameters can define various aspects of a model such as part dimensions, material properties, load magnitudes, etc. In a FEM part, parameters are defined in their respective dialogs, which makes the parameter updating process a time consuming and error-prone task.

NX expressions functionality allows you to define all of the required parameters in one spreadsheet and to update the FEM with a single click.

## Steps

Suppose you are going to run a simulation with multiple values for the part dimensions (Hole diameter and Rib thickness), material properties (Young’s Modulus and Poisson’s Ratio), and load application (Force magnitude and angle). First, create a spreadsheet with the name of parameters and their values as shown in Figure 1. Note that the name of the parameters and cell number in a spreadsheet are arbitrary.

Figure 1: Spreadsheet listing example parameters

In NX choose the Tools tab and under the Utilities group select Expressions.

Figure 2: Expression dialog

In the Expressions dialog, enter the name of the first parameter in the Name box and set the correct type and unit for that parameter.

To make NX read the value of the parameter from the external spreadsheet, click on the Functions icon.

In the Insert Function dialog from the Choose a Category list select spreadsheet. From the list of the functions, select ug_excel_read and click OK.

Figure 3: Insert function dialog

In the Function Arguments dialog, browse for the spreadsheet that you have created in the first step and enter the cell number corresponding to the parameter value in the Specify a Cell box and click OK. For example, for the Hole Diameter expression, the cell number is B1 (Figure 1). Click OK and repeat the process of defining expressions for all of the desired parameters.

Figure 4: Function Argument dialog

All user defined expressions as shown in Figure 5 can be used in the FEM. For example, to define the Young’s Modulus as an expression, in the box for Young’s Modulus instead of entering a constant value, select Expression.

Figure 5: Isotropic Material dialog

From the Expressions dialog then select the corresponding expression that you defined in previous steps, i.e. Young’s Modulus.

Figure 6: Select a predefined expression

After updating the values in the spreadsheet, the FEM can be updated by a simple click on Refresh values from external spreadsheet.

Figure 7: Expressions dialog

Maya HTT
US & Canada: +1-800-343-6292 | UK: +44 (0) 330 024 1029
info@mayahtt.com | https://www.mayahtt.com
4 REPLIES 4

# Re: How to drive NX expressions from a spreadsheet

Creator

Hello MayaHTT!

Thanks for the information! Is there a possiblity of defining more than one cell from the excel sheet.
For example: let a cantilever beam of length 'L' be acted upon non linear forces at different points along the length. Can we give these Forces from the excel sheet just by specifying the direction?

# Re: How to drive NX expressions from a spreadsheet

Solution Partner Valued Contributor

Good morning: You can drive as many expressions as you want from a spreadsheet.  Those expressions can include any number of loads.

# Re: How to drive NX expressions from a spreadsheet

Creator

Hello Carl!
I have tried doing so and I have to select individual cell everytime for the next load. Can this be avoided?
I want to select more than 1 cell at a time. Thank you!

# Re: How to drive NX expressions from a spreadsheet

Phenom

Another good one MayaHTT.

Can setting up an xls with multiple scenarios to define the expression be considered? Consider the case when 2 scenarios (4 variables) are defined;

A       B                 C

V1   1.0                1.0

V2   2.0                  2.5

V3 .33                  .33

V4 70000             69000

The user has 2 ways,

1. Follow your step-by-step example (column A&B defined only) and to run scenario #2 replace values in column B, refresh, etc
2. Edit the cells referring to the value from say B1 to C1, etc, refresh etc

It could be handy to only refer to the column (say C) and C1, C2, etc are automatically allocated. This way one can define a number of scenarios and keep track easily

Production: NX.CAE 10.0.2.6
Development: VB.NET (amateur level !)