Submitted by ben.vernieres on Wed, 08/30/2017 - 00:43
Forums:
Hi,
I'm trying to create a list of values read from an external spreadsheet but can't find the correct syntax to make that work.
I haven't found anything about excel in the NXOpen Python Reference Guide nor in google so I am a bit stuck...
I'm using python / NX10 but even something written in VB would give me a starting point...
Can anyone help?
Thanks,
Ben
re: read data from excel
There are some code samples that ship with NX, you can find these in the NX install directory at:
{NX install dir}\UGOPEN\SampleNXOpenApplications
in the .NET\CAM subfolder, you will find one called "AssignAttributesForTooltips.vb"; this one will pull values from an external excel spreadsheet. The code is written in visual basic, but maybe the same strategy could be used in python code.
It should be noted that this example uses late binding so that it can be run as a journal. The .net journals are limited to referencing a select few libraries; with a .net author license, you can reference the Excel library to enable early binding and make it easier to work with. I'm not sure if python journals have the same limitations.
Thanks, I will take a look
Thanks, I will take a look there.
I also figured I should probably be using my original python install instead of the NX version. Hoping that by doing this I can then use the libraries such as openpyxl.
I'm struggling to set the environment variables at the moment though...
So I've managed to get the
So I've managed to get the Anaconda python to work with NX (ish and after a lot of fighting) and I can now read easily data in any spreadsheet like a normal python script.
The problem I'm having is NX crashes after running a script a second time.
I think it crashes when trying to import openpyxl module as the script runs fine if I mark it out.
Has anyone had this issue and fixed it?