Export Iproperties to excel for multiple files.

Export Iproperties to excel for multiple files.

J.VandeMerckt
Advocate Advocate
608 Views
6 Replies
Message 1 of 7

Export Iproperties to excel for multiple files.

J.VandeMerckt
Advocate
Advocate

Hi Everyone,

 

For work we need to create a data sheet in excel with the mass of al our product.

Product name - Mass

Problem we have thousands of them so I'm trying to find a way to export them in batch.

I don't have much experience but want t try using Ilogic.

I found a script that exports the mass of a single assembly to excel but it's still too slow.

 

Anyone who knows the best way to handle this?

Let me know if I need to provide more info.

We use Inventor pro 2020 & Vault Basic 2020

0 Likes
609 Views
6 Replies
Replies (6)
Message 2 of 7

A.Acheson
Mentor
Mentor

I just had a quick look and having vault won't help much as the property is calculated and unless placed as a custom iproperty in the file itself will not be able to be retrieved. See inventor idea

 

Can you share the code your using and what functionality you want to improve? Each document will need to be opened and updated which can be a slow process. Please share also the location of the files. 

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

johnsonshiue
Community Manager
Community Manager

Hi! Here are a few iLogic/VB solutions. Please take a look.

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/export-iproperties-to-excel/td-p/726...

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/iproperties-export-to-excel/td-p/921...

 

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 4 of 7

J.VandeMerckt
Advocate
Advocate

Hi A.Acheson 

 

Right now I'm using this code:

There is no custom Iproperty for mass in these parts and drawings.

I just want the physical mass next to the name of the part in a excel or cvs.

 

Right now the code only pulls the name out of the file and onto the .cvs file (which is a good start tbh) but no other information. The cells look like this right now: XTD_ACTUALPARTNAME,,""

 

Opening each document and updating by code will still be faster then doing this manually.

Thanks for the help

 

Code Below

 

 

Imports System.IO
' Declare the Application object
Dim oApplication As Inventor.Application

' Obtain the Inventor Application object.
' This assumes Inventor is already running.
oApplication = GetObject(, "Inventor.Application")

' FOLDER selection dialog
Dim FilePATH As String = "FilePATH"
Dim dialog As New System.Windows.Forms.FolderBrowserDialog()
dialog.SelectedPath = "R:\Drawings"
dialog.Description = "Select Folder to Pull Drawing Properties From (recursive)"
If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
	drawingDir = dialog.SelectedPath
Else
	MsgBox("canceled!")
End If

' FILE Selection dialog
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.InitialDirectory = oOrigRefName
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
End If


'Dim drawingDir = "R:\Drawings"
For Each foundFile As String In My.Computer.FileSystem.GetFiles(drawingDir, FileIO.SearchOption.SearchAllSubDirectories, "*.dwg")
	ThisDoc.Launch(foundFile)
	
	' Set a reference to the active document.
	' This assumes a document is open.
	Dim oDoc As Document
	oDoc = oApplication.ActiveDocument
	      
	' Obtain the PropertySets collection object
	Dim oPropsets As PropertySets
	oPropsets = oDoc.PropertySets
	
	PartNo = oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kPartNumberDesignTrackingProperties).Value
	Revision = oPropsets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kRevisionSummaryInformation).Value
	Description = oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDescriptionDesignTrackingProperties).Value

	'Write data info To CSV File
	Dim oAppend As System.IO.StreamWriter
	'selectedfile = "C:\temp\Book1.csv"
	oAppend = IO.File.AppendText(selectedfile)
	oAppend.WriteLine(PartNo & "," & Revision & "," & Chr(34) & Description & Chr(34))
	oAppend.Flush()
	oAppend.Close()
	
	ThisApplication.Documents.CloseAll()
	
Next

 

0 Likes
Message 5 of 7

CGBenner
Community Manager
Community Manager

@J.VandeMerckt 

Do you still need help with this?  Would you like me to move it to the iLogic forum?

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 6 of 7

J.VandeMerckt
Advocate
Advocate
Yes please that might be usefull.
0 Likes
Message 7 of 7

A.Acheson
Mentor
Mentor

Theae few lines are what is needed to extract the mass. Here is the API help for Mass from PartComponentDefinition.

 

'Press the button to update the mass.
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute2(True) 

'The calculated mass will be in system units, not document units
Dim oMass As Double =oDoc.ComponentDefinition.MassProperties.Mass

InventorVb.DocumentUpdate()

 

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