Export iProperties data from files to excel

Export iProperties data from files to excel

eladm
Collaborator Collaborator
1,396 Views
7 Replies
Message 1 of 8

Export iProperties data from files to excel

eladm
Collaborator
Collaborator

Hi

 

Is someone know how from windows explorer I select some files and create an excel file with part number , description etc.  ? 

I can place these files at assembly and export BOM but I have a lots of files

regards

happy new year

 

0 Likes
1,397 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

Hi @eladm.  That sounds like a job for a custom standalone application, and maybe utilizing the Apprentice Server, but might also be accomplished though other means.  What would be the purpose of the resulting Excel sheet?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 8

eladm
Collaborator
Collaborator

HI

I want to have an excel file that have properties from all my IPT file in my computer

 

Vault can do that , but I don't want to use it 

regards

0 Likes
Message 4 of 8

el_jefe_de_steak
Collaborator
Collaborator

It would probably be easier to create an external iLogic rule or VBA macro that does what you are asking. You would have to open Inventor and run the macro. You could relatively easily make a VBA macro that would ask you for a directory to search through, and then it would explicitly open each file in that directory and export your desired properties to a CSV.

 

@WCrihfield is correct that this could be done exactly how you want with a standalone application, but IMO that would be pretty complex to design and implement. Setting up a standalone application is a LOT more work than just using VBA or iLogic. 

0 Likes
Message 5 of 8

WCrihfield
Mentor
Mentor

Depending on the size of your file system and how many files were talking about here, this could be a HUGE task to attempt to run from an iLogic rule or Inventor VBA macro, and it could seriously bog down or freeze up Inventor for a long time while it is working...if it doesn't cause Inventor to crash.  Sure it sounds like a doable process from a code point of view, but I wouldn't want to be the one responsible/blamed if a code I provided you causes any serious problems/damages on your end.  If I were to use a VBA macro for this task, I would probably do it from the Excel side (use Excel's VBA Editor to create the macro there, then run it from Excel).  I'm not 100% sure it would make a lot of difference, but it sounds a little safer to me.  And if you have Inventor Apprentice Server installed, you might be able to use that instead of the main Inventor application to gather the iProperties data from all the Inventor files, because I hear that using that is way more efficient, and won't bog Inventor down, because it is a separate standalone system.  I've never tried to use it from Excel VBA before though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 8

el_jefe_de_steak
Collaborator
Collaborator

You may be right here, but I have to disagree on one point - I don't believe there is any way that any VBA macro or iLogic rule can cause "serious problems" or "damage". It is true that this process would "bog down" Inventor on large datasets, but that is just because it is "busy" and you can always run another instance of Inventor on the side. Worst case scenario is that Inventor crashes outright, or that it gets "stuck" due to a bug while processing one of the files. A force close via Task Manager would be an acceptable response if Inventor gets "stuck".

That being said, I agree that the Apprentice Server in Excel VBA is going to be a great option, and will be faster than running in Inventor. The only downside is that you have to go through the work of adding references to your Excel VBA project. I found a couple of articles that show how to start setting it up:
1. https://spiderinnet2.typepad.com/blog/2013/05/inventor-api-manipulate-inventor-in-office-excel.html
2. https://modthemachine.typepad.com/my_weblog/2010/03/iproperties-without-inventor-apprentice.html

If this were me, I would test it in Inventor VBA first with a small dataset just to see how it performs. If it performs fairly well, Bob's your uncle. If that didn't work well, I would then be able to copy-paste most of the code I already wrote in to Excel VBA.

0 Likes
Message 7 of 8

el_jefe_de_steak
Collaborator
Collaborator
Something else you could explore is using Inventor's Task Scheduler software to do this. I have never used it myself and so can't speak much to its capabilities, but I do know that at my company our Inventor manager uses it to batch migrate .ipt files, and it's great at working with larger datasets.
Message 8 of 8

A.Acheson
Mentor
Mentor

Here is a VBA rule that will  query files using the apprentice server tested in Inventor 2020 and called from excel VBA. It is just returning one file at the moment but you can adapt from there. 

 

'https://forums.autodesk.com/t5/inventor-customization/determining-if-references-are-missing-before-opening-an-iam-file/td-p/3518626
'Filename is path, Name and ext
Dim filename
Dim outputstring

Sub StartProcessingFiles()



    filename = InputBox("Input FileName & Path & ExtTo Search For Information", "Enter Path Information")
    If filename = "" Then
        WScript.Quit
    End If

    Call GetInformation

    oTextSave = "C:\temp\iLogicBuffer.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oWrite = fso.CreateTextFile(oTextSave, True)
oWrite.WriteLine ("")

    oWrite.WriteLine ("File Checked: " & filename)

   oWrite.WriteLine (outputstring)
    oWrite.Close

    Dim WshShell
    Dim oExev

    Set WshShell = CreateObject("WScript.Shell")
    Set oExec = WshShell.Exec("notepad " & oTextSave)
        
    Set oExec = Nothing
    Set WshShell = Nothing
End Sub

Sub GetInformation()

    On Error Resume Next

    Dim invApprenticeApp
    Set invApprenticeApp = CreateObject("Inventor.ApprenticeServer")

    Dim invApprenticeDoc
    Set invApprenticeDoc = invApprenticeApp.Open(filename)

    Dim oFM
    Set oFM = invApprenticeApp.FileManager
    
    Dim oMainFile
    Set oMainFile = oFM.Files(filename)

    If oFM Is Nothing Then
        Exit Sub
    End If

    PartNumber = invApprenticeDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
    outputstring = outputstring & "    " & PartNumber & vbCrLf
    
    MsgBox (PartNumber)
    
    invApprenticeApp.Close
    Set invApprenticeApp = Nothing
        
End Sub

 If you want you can use  vb script file (.vbs) on the desktop. It is the same as the VBA rule with small differences. To make it run in .vbs just call the first sub routine.

AAcheson_0-1642026899965.png

 

Dim filename 
Dim outputstring


Call StartProcessingFiles 'Used to call the rule from VB.Script

Sub StartProcessingFiles()

 

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan