cancel
Showing results for 
Search instead for 
Did you mean: 

Spreadsheet in text format

Siemens Creator Siemens Creator
Siemens Creator

Hello,

 

I can create an expression that loads data from excel:

ug_cell_read("D:\Data.xlsx","B98")

 

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,

Marcio

11 REPLIES

Re: Spreadsheet in text format

Esteemed Contributor
Esteemed Contributor

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. 

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: Spreadsheet in text format

Phenom
Phenom

It should be noted that there is no associativity maintained between the source file and the NX part file when importing expressions as @Ken_A described (in case that is important to you).

Re: Spreadsheet in text format

Siemens Creator Siemens Creator
Siemens Creator
Ken_A,

Thanks for responding.

(Yes, the NX 11 Expressions window is overhauled. The "Import and Export Expressions" is not there anymore, but it still can be found under Menu / Tools.)

Anyway, it I can export something like this:

NAME FORMULA VALUE UNITS TYPE COMMENT
FA_PT_UpperAArm_CG_Loc_x ug_cell_read("D:\Data.xlsx","B2") 0 mm Number

At this point, I do not care much if this file is TXT or XLSX. In either case it works for both Export and Import, but the problem is that the formula is this function ug_cell_read(), which is (I think) the culprit that is taking too long.

Note that the formula has the information of where the actual data resides: Data.xlsx.
My hope was that having a text version of this data file would accelerate the process.

I actually was able to use ug_cell_read() with a tab-separated TXT file as an argument. It worked, but it took almost as long as when I specified an XLSX file.

Marcio

Re: Spreadsheet in text format

Siemens Creator Siemens Creator
Siemens Creator
cowski1,

Yes, I know. Every time the excel data file is modified, I have to click on the "Update for External Change" button. It sucks, but this is how it is currently.

Marcio

Re: Spreadsheet in text format

Phenom
Phenom

Does the Excel file have to be external?

Can you use the modeling spreadsheet for your calculations?

Re: Spreadsheet in text format

Siemens Creator Siemens Creator
Siemens Creator
cowski1,

The Data file must be external.
The excel data worksheet is the result of operations in other worksheets.

For example, the user interface worksheet could be nicely formatted with place for a few inputs. Potentially complicated formulas and relationships might calculate what goes to the data worksheet. Modifying one input could modify several other parameters.

The data worksheet is a plain list of two columns, Name and Value, which is to be read by SimCenter. Currently, ug_cell_read() works fine; it is just too slow.

That is why I am looking for alternatives, such as TXT files. It would require an extra file saving, but that would still be better than the long wait.

Marcio

Re: Spreadsheet in text format

Phenom
Phenom

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.

Re: Spreadsheet in text format

Siemens Legend Siemens Legend
Siemens Legend

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.  :-)

 

2016-09-06_import_export_exp.png

Taylor Anderson
NX Product Manager, Knowledge Reuse and NX Design
Tel: +1 (602) 441-0683
taylor.anderson@siemens.com

Re: Spreadsheet in text format

Siemens Legend Siemens Legend
Siemens Legend

Marcio --

 

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:

 

2016-09-06_Excel_list0.png 

 

Reading in that first column of values might look like this:

 

2016-09-06_Excel_list1.png

 

...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?

Taylor Anderson
NX Product Manager, Knowledge Reuse and NX Design
Tel: +1 (602) 441-0683
taylor.anderson@siemens.com