Hi,
I have a Q: how can i close a drawing + part using ilogic?
Why:
I have this rule to export partslists from .dwg to a Excel template that is launched from my TOP-assembly.
What it does is:
- Open the drawing that contains the partslists
- Export partslist via API (trigger on open document)
What it need to do is close the drawing afterworth, but i cannot find the right way to do this.. can someone help me?
Thanks!!
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
Hi,
Thanks for replying on this matter! I tried the rule, but didn't have time to come back on it.
The rule works, but i gives me an error after closing my drawing.
Is this normal? Or did i do somthing wrong?
Code:
Dim oControlDef As ControlDefinition oControlDefs = ThisApplication.CommandManager.ControlDefinitions 'close the drawing file oControlDefs.Item("AppFileCloseCmd").Execute
Error:
Edit Rule Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Can't find what you're looking for? Ask the community or share your knowledge.