Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advice on a strategy to get expression data into and out of a spreadsheet

Status
Not open for further replies.

please_dont_crash

Automotive
Apr 21, 2020
25
NX version 1973, integrated with TC.

I'm hoping someone can point me in the right direction. I'm pretty new to NX so there may be some fundamental misunderstandings about how things work here, but I hope this is clear enough:

Part setup:

-- DatumCSYS at part absolute origin, that stays fixed.

-- Multiple other DatumCSYS whose position is defined via "Offset CSYS" from the absolute origin DatumCSYS via expressions. When the expression editor is opened, it contains a list of expressions along the lines of:

Code:
datumcsys_1_x = <value>
datumcsys_1_y = <value>
datumcsys_1_z = <value>
datumcsys_1_angle1 = <value>
datumcsys_1_angle2 = <value>
datumcsys_1_angle3 = <value>
datumcsys_2_x = <value>
...


Desired functionality:

-- The various non-absolute-origin DatumCSYS can be moved around via dynamic positioning (i.e. with the mouse and handles). When they are moved, the expressions in the expression editor update to reflect the new offset values.

-- These expressions and their values can be written to an Excel file in Teamcenter.

-- The Excel file can be manually edited and these new values can then be assigned to the expressions, resulting in the various DatumCSYS moving to new locations.

I hope that's clear enough.

My work so far, covering possible approaches:

1) I've looked into using ug_cell_read() when entering the translation/rotation values for each DatumCSYS. I see that from there, I can specify an Excel spreadsheet in Teamcenter. This gives me the impression that I can only read data from the Excel file, but not move the DatumCSYS dynamically and then write out the new data to that Excel file.

2) I have also looked at the Spreadsheet functionality. I suspect this might be closer to what I want. But I am still trying to learn if the spreadsheet can be accessed as a stand-alone file (without doing a Save Copy As), and I don't think it can. I'd like to avoid things like copy-pasting into and out of the Spreadsheet window.

3) A third option (and honestly it's looking like I might go this route, because it is the simplest) is to give up on the spreadsheet idea altogether, and just use the Import Expressions/Export Expressions to save and load text files containing expressions and their values. I can always write a glue script to move these to and from whatever Excel file I am working with. With this approach, the only thing to determine is if I can indeed move the various DatumCSYS dynamically and have the expressions update with new values. I think this is the case.

Thoughts and suggestions appreciated!

 
Replies continue below

Recommended for you

I also think third option is most suitable for your requirement.
 
I recently started importing and exporting expressions. Indeed it is a royal drag that the format of these files is not spreadsheet-friendly.

However, it may be simpler to parse an expressions file using VBA to make an Excel-compatible format than to export directly to Excel.
 
Thank you for these suggestions.

It sounds like option 3 is the way to go.

If anyone else has any input, feel free to add it.
 
I guess this leads to a second question:

Is my assumption that I can dynamically move a DatumCSYS that has been defined via OffsetCSYS wrong?
 
please_dont_crash said:
Is my assumption that I can dynamically move a DatumCSYS that has been defined via OffsetCSYS wrong?

Yes and no. You cannot move it dynamically while it is set to "offset"; in this case you would have to edit the offset values in the dialog. Alternately, you could change the type to "dynamic", move it where you want, and reset it to "offset". The offset values should update to the new location.

www.nxjournaling.com
 
Thanks cowski! Hadn't thought of the second approach, and it works great!!
 
Actually, looks like I spoke too soon.

My goal is to move a DatumCSYS that has been defined via Offset CSYS using expressions, not fixed values. Changing the type to Dynamic, moving the DatumCSYS using the handles, and changing back to OffsetCSYS turns the offset quantities into fixed values, breaking the link with the expression.

I have a feeling the only way to move the DatumCSYS and update the expression value is to edit the expression value. There is probably no way to use the Dynamic handles as a driver for expression quantities, while retaining the ability to use the expressions to also drive the position of the DatumCSYS.



 
You have the ability to save the WCS and then select it the next time you need to utilize it.
Menu -> Format -> WCS - Save

Jerry J.
UGV5-NX1961
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor