Symbolica Pushing A Value From NX To An External Spreadsheet

2021-10-06T23:27:16Z
Symbolica

Summary


Details

Can an expression in an NX part file be pushed (written) to a cell in an external spreadsheet?


It currently works if the spreadsheet is within the confines of the part file, however, in this case the spreadsheet is on the OS.



Solution

You can do this today using a few Knowledge Fusion functions in the expression editor as follows:


Using this as the value for an expression:


@{ 
$port << ug_excel_open_file("C:\temp\test\test.xlsx", makename("Write") ); 
$write << ug_excel_write_range( $port, {1, 3, 3, 4, 4, "1", "2", "3", "4"}); 
$close << ug_excel_close_file( $port, True ); 
}


Will produce (write) the above values in a blank Excel file at the above location.


The key is the ug_excel_write_range() function. The arguments here are:


   1. The file port from the ug_excel_open_file() function [in the line above] 

  2. A KF list of spreadsheet requirements as follows: 
       a. The sheet ID 
       b. Starting Row 
       c. Starting Column 
       d. Ending Row 
       e. Ending Column 
       f. The data (as strings) that will be written, top left to bottom right,  rows first.


You can write out a single value to a single cell like this:


@{ 
$port << ug_excel_open_file("C:\temp\test\test.xlsx", makename("Write") ); 
$write << ug_excel_write_range( $port, {1, 2, 5, 2, 5, "Wow!!"}); 
$close << ug_excel_close_file( $port, True ); 
}


This could easily be wrapped into a new Knowledge Fusion function that could just require the filename and the list of data.


These functions (and more documentation of the detailed parameters) are found in:


 %UGII_BASE_DIR%\ugii\dfa\kf\funclib\ug_external_spreadsheet.dfa


These particular functions are not exposed in NX, but Knowledge Fusion functions can generally be used in expressions without any problems, as long as the user knows what they are doing.


For example, the spreadsheet_write.prt could contain these expressions:


[mm]length=length10 // 50 
[mm]p3=50 // 50 
[mm]p4=60 // 60 
[mm]p5=10 // 10 
[mm]p17=distance16 // 78.74007874012 
(Boolean) write_test=@{ 
$port << ug_excel_open_file("C:\temp\test\test.xlsx", makename("Write") ); 
$write << ug_excel_write_range( $port, {1, 3, 3, 3, 3, format("%f", length) }); 
$close << ug_excel_close_file( $port, True );} // TRUE 
(Boolean) write_test_2=@{ 
$port << ug_excel_open_file("C:\temp\test\test.xlsx", makename("Write") ); 
$write << ug_excel_write_range( $port, {1, 3, 4, 3, 4, format("%f", p17)}); 
$close << ug_excel_close_file( $port, True );} // TRUE

Notes and References


Hardware/Software Configuration

Platform: INTL64
OS: window
OS Version: 764SP1
Product: NX
Application: DESIGN
Version: V1847
Function: EXPRESSION

Ref: 002-7006788

KB Article ID# PL7006788

Contents

SummaryDetails

Associated Components

Symbolica