Cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting multiple tables from .dft with macro or other means to excel

Creator
Creator

I am in the process of trying to find the simplist way to extract BOMs from a draft. I am an IS specialist at my company and we have an upload tool to get new parts and BOMs into our ERP system as long as it's formatted correctly. I just need a quick way to extract the table data so then I can format it as neccessary to interact with the upload tool.

 

These are not your standard BOMs that you would normally use in solidedge, instead they are manually typed parts lists that span multiple pages. I am aware that I can go to Properties>Data and highlight the fields and copy+paste into excel. This is really cumbersom when the BOM spans 20 pages so there are 20 individual tables, and there is potential of missing a page. What I am thinking is a macro that can find and save into an array, all tables of a certain type. From there its simple vb to get the data as I need it.  I just am not sure how to go about doing that, I am having some issues finding resources on the subject. Do you have any thoughts?

 

My backup plan for this works but idealy I would like to use the macro. I have successly been able to 'print' the BOM pages to PDF, convert to excel, and used a VB macro to get the csv file I need. But obviously a 1 click action an solidedge would be more ideal.

 

Any help is appreciated!

10 REPLIES

Re: Exporting multiple tables from .dft with macro or other means to excel

Phenom
Phenom

Probably better posting this on the Developer Forum.

At the top of the page there is a link to Useful Solid Edge Developer Community links.

If you understand VB etc you shouldn't have too much difficulty finding and modifying code (much of it by the genious Jason Newell). I know there is something in there about exporting Parts Lists - you will need to adapt it for 'Tables'

 

https://community.plm.automation.siemens.com/t5/Solid-Edge-Developer-Forum/Useful-Solid-Edge-Develop...

HP Z420 16GB RAM
Quadro K4000
ST10 MP6 on Windows 10 Pro 64.

Re: Exporting multiple tables from .dft with macro or other means to excel

Creator
Creator

Appreciated

Betreff: Exporting multiple tables from .dft with macro or other means to excel

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

HI @RyanP

 

 

 

 

 

IMHO there is an object grooup for tables in any draft file.

So with a simple Foreach objTable in objDocument.Tables You should be able to get all of them

 

 

 

regards
Wolfgang

Betreff: Exporting multiple tables from .dft with macro or other means to excel

Creator
Creator

That sounds logical to me but I can't seem to get the syntax right. From what you are saying I want to loop through each table in the document. Then display the name(for testing purposes)

 

Dim draftDocument = application.GetActiveDocument(Of SolidEdgeDraft.DraftDocument)()

 

For Each n in draftDocument.Tables

  console.write('''''How do I get the name of each table?)

Next

 

draftDocument.Tables.count does = 86 so I can grab the number of tables but I just cant seem to figure out how to grab the table title of each

Betreff: Exporting multiple tables from .dft with macro or other means to excel

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Hi @RyanP

 

 

 

 

every table has  objTable.Titels.Count giving the number of titles for that table

 

The objTable.Titels.Item(1).Value brings You the first title text.

Normally I look for the first title.

If a table has more than one title it might be not so important.

I always use the first one for comparison reasons.

 

You can compare this text with Your search text and if it matches then YOu will use it

 

Hope this helps

 

 

regards
Wolfgang

Re: Exporting multiple tables from .dft with macro or other means to excel

Phenom
Phenom

@RyanP

I would suggest downloading Spy for Solid Edge - you can find it on the page I linked to.

That will be a great help when looking for the way objects etc are organised.

It will show you everything about any open SE document.

Also the .Net Programmers guide is a great starting point for programming -

https://www.plm.automation.siemens.com/zh_cn/Images/Solid_Edge_API_tcm78-125829.pdf

HP Z420 16GB RAM
Quadro K4000
ST10 MP6 on Windows 10 Pro 64.

Betreff: Exporting multiple tables from .dft with macro or other means to excel

Creator
Creator

Thanks for getting me on the right track. After a lot of roadblocks mostly with how to syntax what I needed to do I was able to loop through all the tables and print the titles. From here I will keep building to get what what I need from it

 

Code for future googlers: 


Dim oApp As SolidEdgeFramework.Application
Dim oDoc As SolidEdgeDraft.DraftDocument
Dim otab As SolidEdgeDraft.TableTitles
Dim otab1 As SolidEdgeDraft.TableTitle
Dim otab2 As SolidEdgeDraft.Tables
Dim otab3 As SolidEdgeDraft.Table

 

oApp = Marshal.GetActiveObject("SolidEdge.Application")
oDoc = oApp.ActiveDocument

 

otab2 = oDoc.Tables
Dim icount As Integer = 1
For Each otab3 In otab2
otab = otab3.Titles

For Each otab1 In otab
Console.WriteLine(icount.ToString)
Console.WriteLine(otab.Item(otab1.Index).value)
' Console.WriteLine(otab2.Item(otab3).Titles.Item(otab1).value)
icount = icount + 1
Next

Next

Betreff: Exporting multiple tables from .dft with macro or other means to excel

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Hi @RyanP

 

 

 

 

congratulation to get it finally, and I'm happy being able helping a little.

 

Have You posted Your question in the programmers forum too?

 

 

regards
Wolfgang

Re: Exporting multiple tables from .dft with macro or other means to excel

Creator
Creator

@beachcomber

Spy is awesome! It made it easy to write the code for pulling cell data