Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

import .xls file, points

Status
Not open for further replies.

berri2

Mechanical
Apr 6, 2010
139
Hi,

How can I import an .xls file, I want to create a point cloud surface.

I have donde this with .dat files is there another way?

Thanks.
 
Replies continue below

Recommended for you

Unless you write your own application (or get something from someone who has) there is no direct way of reading an Excel file into NX and creating points from X,Y,Z data in the spreadsheet.

However, once the next version of NX is released there will be a function which will, for all intents and purposes, allow you to do just that.

John R. Baker, P.E.
Product 'Evangelist'
Product Design Solutions
Siemens PLM Software Inc.
Industry Sector
Cypress, CA

To an Engineer, the glass is twice as big as it needs to be.
 
Hi guys,

Can anyone load this macro or journal,(program)

for importing .XLS points to NX.

It can be a great help...

Thanks.
 
Attached is a VB journal which allows you to read in excel (.xlsx) data into a windows datagrid. Use the Browse button to select a Excel file. The file name is placed into the text box. Once a file is selected use the Import button to read the excel data. I have assumed that row 1 contains column headings.

Remember this is just a demo. It is of course possible to use data directly.

Hope this helps.

Frank Swinkels
 
 http://files.engineering.com/getfile.aspx?folder=f6337895-3191-4d21-b3d7-e16c24ba26b1&file=ReadExcelData.zip
Please save your excel file to Office 2008 format. I only have Office 2008 and there is a difference in the vb code for different database versions.

Frank Swinkels
 
I found a further error in when I was testing my program I used a sample excel file which I thought was Office 2008 when in fact it was Excel 97-2003 workbook. In fact I have not been able to run it with other than this format. I have attached a new journal file which should work wit Excel 97-2003 format.

Sorry about the error.

Frank Swinkels
 
 http://files.engineering.com/getfile.aspx?folder=1980c795-3b4a-4097-beb4-df6dcf170937&file=ReadExcelData1.zip
Hi Frank,

I have tested it with Excel 2010, I can find the .xls file but I can't read it. Can be office version problem?

Can you send me and example of an .xls file tested by you?

I don't know what I am doing wrong...

Sorry,

Thanks all.
 
Let me see if I can explain.

The following .NET libraries are supported by journaling:

mscorlib.dll

System.dll

System.Windows.Forms.dll

System.Drawing.dll

To access excel workbooks System.dll has a data class.OleDb which has a method OleDbConnection.

Unfortunately this method can only open excel spreadsheets to Excel 97-2003 format.

To read later spreadsheets we need to use the Microsoft library. Specifically Microsoft.Office.Interop. With this we can read 2010 spreadsheets.

To summerize we can use journals to read spreadsheets up to Excel 97-2003 format. To read later format spreadsheets we cannot use a journal. We can build the source code as an executable (.exe or .dll) to read the later formats.

Frank Swinkels
 
Hi again,

I have attached my simple test example. I have also included the journal. Just to make sure I have changed the file extension to .txt. Just change it back to .vb to run the journal. My simple example excel is data2.xls.

Regards

Frank Swinkels
 
 http://files.engineering.com/getfile.aspx?folder=4b8a73ae-1099-42f6-98f0-12b698754431&file=ReadExcelDatawithexample.zip
Ok FranK it works,

thanks for the .xls example.

I have to know ho to insert this points on NX .prt part.

Regards,
 
I have added the create points in the journal in the attached zip file. As before I have renamed the .vb file to a .txt file. Just rename it back. It works for the previously supplied data2.xls. To use for other data it needs to be in the same format i.e. row 1 must have the heading "xvalues" (in A1), "yvalues" (in B1) and "zvalues" (in C1). Alternatively you would need to reprogram the appropriate lines of code (to use your own column names). Also I have assumed Sheet1 as the sheet name.

Hope this helps further.

Regards

Frank Swinkels
 
 http://files.engineering.com/getfile.aspx?folder=5f41414c-afd7-4641-8ee7-063297271003&file=ReadExcelData2.zip
Hi Frank,

Thanks for the macro, the thing is that like the attached photo, now I can see the points with your macro, but I don't know how to accept to import these points to the NX model enviroment.
I see the cancel button, but not the accept button.

Thanks.
 
 http://files.engineering.com/getfile.aspx?folder=4ad1af7c-b9cb-42bf-a82b-281bed8e2fc7&file=1.bmp
I simply added the points creation to the import buttom (remember this is purely an example). I have created an additional journal file (in ReadExcelData3.zip). This time the apply points button creates the points and exits the journal. Now obviously the program can be much improved on. For example it would not be necessary to display the data grid. We could simply ask for the data file using a windows dialog. Then an apply button would create the points and ask for another data file. A cancel button would not create any points and an OK button would create the points and exit the program. Other options such as layer control etc can be included on a dialog.

As before I have renamed the vb file to a txt file. Just rename it back to .vb to run the journal.

Regards

Frank Swinkels
 
 http://files.engineering.com/getfile.aspx?folder=32b62da6-d7ca-4f9d-b709-04e22895c534&file=ReadExcellData3.zip
Hi Frank,

Yes, I was looking for this VB.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor