Save iProperty info to Excel from dwg files

MH-J
Enthusiast
Enthusiast

Save iProperty info to Excel from dwg files

MH-J
Enthusiast
Enthusiast

Hello all.

I've created an array list of all dwg files in a directory structure and wish to iterate through each of them and send the part number, description, revision and creation date iProperties through to the excel sheet. Everything is fine except for the reading and writing of the iProperties. The code I have is as noted below and fails stating the following

iProperties:The document named "C:\Users\Public\Documents\Dropbox\design work\SAB\01-Design\00-Product Codes\01-RB1.8\02-Design\01-RB1.8.dwg" was not found.

 

Thanks for any help

 

Dim oDrawingNumbers() As String = System.IO.Directory.GetFiles(oPath, "*.dwg", System.IO.SearchOption.AllDirectories)

For Each Drawing As String In oDrawingNumbers
	If (InStr(1, Drawing, "OldVersion")) Then  'Do nothing with this file as it is in the OldVersions Folder
	 
	Else	'This is a live drawing	
		GoExcel.CellValue("A" & oRow) = iProperties.Value(Drawing, "Project", "Description") 
		GoExcel.CellValue("B" & oRow) = iProperties.Value(Drawing,"Project", "Description")
		GoExcel.CellValue("C" & oRow) = iProperties.Value(Drawing, "Project", "Revision")
		GoExcel.CellValue("D" & oRow) = iProperties.Value(Drawing,"Project", "Creation Date")
		oRow = oRow+1
	End If
Next

 

0 Likes
Reply
528 Views
3 Replies
Replies (3)

Curtis_Waguespack
Consultant
Consultant

Hi @MH-J 

 

Try something along these lines.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oPath = "C:\Temp"
oExt = "*.idw"

Dim oDrawingNumbers() As String = System.IO.Directory.GetFiles(oPath, oExt, System.IO.SearchOption.AllDirectories)

		Dim oOptions As Inventor.NameValueMap
		oOptions = ThisApplication.TransientObjects.CreateNameValueMap	
		
		Dim oDoc As DrawingDocument
		

For Each Drawing As String In oDrawingNumbers
	
	If Drawing.Contains("OldVersion") = False Then  
		'false opens invisibly
		oDoc = ThisApplication.Documents.OpenWithOptions(Drawing, oOptions, False)
		oPN = oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value 
		MsgBox(oPN)
	End If
Next

 

 

 

mikejones
Collaborator
Collaborator

Thanks for the quick response Curtis.

I've added the lines of code in which appears to work but I was hoping for a solution that would interrogate the files iProperties without having to open it up. Would that be feasible? 

 

Mike

Autodesk Certified Professional
0 Likes

Curtis_Waguespack
Consultant
Consultant

Hi @mikejones ,

 

Unfortunately,  I don't know of a way to access the iproperties via iLogic/VB without having the file already opened or without opening  the files if they are not already opened.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

0 Likes