Hi Jefkee,
Here is a quick iLogic example that you can run from the assembly file. It will save and close the assembly, and then open a drawing file of the same name. For example Roadrunner_Catcher.iam expects a drawing file named Roadrunner_Catcher.idw
Once the drawing is open the parts list is exported as an XLS (example: Roadrunner_Catcher.xls ) and then the drawing is closed.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oControlDef As ControlDefinition
oControlDefs = ThisApplication.CommandManager.ControlDefinitions
'save the current file (assumes the assembly is active)
ThisDoc.Save
'change the extension to *.idw
sDrawName = ThisDoc.ChangeExtension(".idw")
'get parts list XLS file path and name
sXLS = ThisDoc.ChangeExtension(".xls")
'close the current file (assembly file)
oControlDefs.Item("AppFileCloseCmd").Execute
'open the drawing file, false opens the file without generating the graphics
ThisApplication.Documents.Open(sDrawName, True)
' - - - - - - - export Parts List code - - - - - - - - - - - - - - - - - - -
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
'look at the first sheet of the drawing
Dim oSheet As Inventor.Sheet
oSheet = oDrawDoc.Sheets(1)
'get the 1st Partslist on the sheet.
Dim oPartslist As PartsList
oPartsList = oSheet.PartsLists(1)
'create a new NameValueMap object
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True
'check for existing XLS file and delete it if found
Try
'delete XLS file
Kill (sXLS)
Catch
'catch error if XLS file doesn't exist
End Try
'export the Partslist to Excel.
oPartslist.Export(sXLS,PartsListFileFormatEnum.kMicrosoftExcel, oOptions)
' - - - - - - - export Parts List code - - - - - - - - - - - - - - - - - -
'close the drawing file
oControlDefs.Item("AppFileCloseCmd").Execute
