HELP!
Are there anyone out there using Inventor 2012 and using ilogic rule or VB codes to auto Save Copy AS DWG?
My old code error out when debugging. The exact error is on this code line:
DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Autodesk has agreed that this code does not work on Inventor 2012 and that the development is working on it. This code is part of the Snippets built in Inventor iLogic Rule Browser.
Someone must have an answer or workaroudn this problem out there. Help.
Solved! Go to Solution.
Hi Rthapa,
I reply the iLogic issue in this thread (http://forums.autodesk.com/t5/Autodesk-Inventor/EXPORT-TO-DWG-ILOGIC-RULE-DOES-NOT-WORK/m-p/3283079/...)
If you want to do the export work with VB or C# application, it is also possilbe, and it would be easy to implement export automation. The detailed steps is stated below.
Dwg out in VB application
Imports Inventor
Module Module1 SubSaveAsDwg() DiminventorTypeAsType = System.Type.GetTypeFromProgID("Inventor.Application") DimInvAppAsInventor.Application = System.Activator.CreateInstance(inventorType) IfInvAppIsNothingThenThrowNewException("Could not start Inventor.") EndIf ' Dim InvApp As Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") 'InvApp.Visible = True'We must use true. Otherwise it will crash when do dwgout.DimInvDocAsDrawingDocument = InvApp.Documents.Open("C:\drawing.idw", True) IfInvDocIsNothingThenThrowNewException("Could not open idw file.") EndIf ' Get the DWG translator Add-In.DimDWGAddInAsTranslatorAddIn = InvApp.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}") IfDWGAddInIsNothingThenThrowNewException("Could not access DWG translator.") EndIf DimtranslationContextAsTranslationContext = InvApp.TransientObjects.CreateTranslationContexttranslationContext.Type = IOMechanismEnum.kFileBrowseIOMechanism DimoptionsAsNameValueMap = InvApp.TransientObjects.CreateNameValueMap IfDWGAddIn.HasSaveCopyAsOptions(InvDoc, translationContext, options) Then options.Value("Export_Acad_IniFile") = "C:\dwg.ini" DimdataMediumAsDataMedium = InvApp.TransientObjects.CreateDataMediumdataMedium.FileName = "C:\test2.dwg" CallDWGAddIn.SaveCopyAs(InvDoc, translationContext, options, dataMedium) EndIf EndSub SubMain() TrySaveAsDwg() CatcheAsExceptionConsole.Write(e.Message) EndTryEndSub
End Module |
Dwg out in c# application
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace dwgOutAddInCSharp { classProgram{ publicstaticvoidSaveAsDwg(){ System.TypeinventorType = System.Type.GetTypeFromProgID("Inventor.Application");Inventor.ApplicationInvApp = System.Activator.CreateInstance(inventorType) asInventor.Application; if (null == InvApp) thrownewException("Could not start Inventor.");
// We must use true. Otherwise it will crash when do dwgout. Inventor.DrawingDocumentInvDoc = InvApp.Documents.Open("C:\\drawing.idw", true) asInventor.DrawingDocument;if (null == InvDoc) thrownewException("Could not open idw file."); Inventor.TranslatorAddIndwgAddIn = (Inventor.TranslatorAddIn)InvApp.ApplicationAddIns.get_ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}"); if (dwgAddIn == null) thrownewException("Could not access DWG translator."); Inventor.TranslationContexttranslationContext = InvApp.TransientObjects.CreateTranslationContext(); translationContext.Type = Inventor.IOMechanismEnum.kFileBrowseIOMechanism; Inventor.NameValueMapoptions = InvApp.TransientObjects.CreateNameValueMap(); if (dwgAddIn.get_HasSaveCopyAsOptions(InvDoc, translationContext, options)) { options.set_Value("Export_Acad_IniFile", @"c:\dwg.ini");Inventor.DataMediumdataMedium = InvApp.TransientObjects.CreateDataMedium(); dataMedium.FileName = @"C:\test2.dwg"; dwgAddIn.SaveCopyAs(InvDoc, translationContext, options, dataMedium); } } staticvoidMain(string[] args){ try{ SaveAsDwg();} catch (System.Exceptionex){ System.Console.Write(ex.Message);} } } } |
Thank you. Problem is resolved now.
My findings:
1. Migrating 2011 IDW Standard Template with embedded iLogic Rule to 2012 version does not work and corrupts the template file internally some how.
2. DWGOUT.INI file was in specified directory. Missing DWGOUT.INI file does crash the iLogic rule
3. Deleting iLogic Rules from migrated template, Save Copy AS to new file then add iLogic Rules back in Solved the problem.
4. DWGOUT.INI was already in place and was not modified.
i've a similar issue in vb.net i'm trying to do an export from an iventor idw to an autocad dwg, and i'm trying to do this parallelly with the TPL of .net and i get this COMexception "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
any suggestion ?
i've tried generating a new template file, but maybe i've done smthing wrong ...
Can't find what you're looking for? Ask the community or share your knowledge.