I can create an expression that loads data from excel:
But is there something similar that loads data from a *.txt file?
My underlying problem is that loading from excel takes too long: my current test model has only 225 expressions, and it takes about 200 seconds to load.
In a real situation, I will have thousants of expressions like this.
My hope is that TXT will be much faster.
I would also be open for other methods to read expression values from a data file.
Thanks for any help,
Solved! Go to Solution.
Not sure about NX11 (I would assume it is still there, but I know they did change the expression dialog)
But in NX10 expressions dialog, in top-right corner, there are 2 icons to import/export expressions from a file.
This is going to look for (or create) and EXP file, which is just a text file. (export some sample expressions to figure out the format)
Perhaps if you create an EXP file and then import it, it would be faster.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be steemed than diseaseled
The only other option that I can think of right now is a custom journal that would read your Excel or text file and update the expressions accordingly. I suspect that NX is opening the Excel file for each "ug_cell_read" function; if this is the case, the journal would have an advantage in that it would open the file once and read all the necessary values. The downside is the journal would need to be told which cell value goes with which expression. One way to accomplish that would be to add the NX expression names in your Excel/text file.
To be clear, "Import and Export Expressions" are still there in NX 11. They're inside the "Import/Export" group in the left-side menu in the dialog. :-)
If your data worksheet is really a simple list of name/value pairs, then you might consider using one of the newer functions to read your list of values all at once.
ug_read_list() takes a starting cell and a direction (horizontal or vertical) as arguments, reads and collects values until it finds white space in the spreadsheet, and returns the entire set as one list expression.
ug_read_fixed_list() does just what it sounds like... It reads in a fixed range of values as a single list expression.
Once inside NX, you can easily reference the elements of this list expression with the nth() function.
And if the "chattiness" really is the issue, then this should reduce your Excel access to one instance per "external update."
For example, with an external spreadsheet like this:
Reading in that first column of values might look like this:
...and then just by changing the starting cell to "C2", you could read in the second set of data instead.
Does that make sense?
Does that help at all?