Inventor General Discussion

Reply
Contributor
rthapa
Posts: 14
Registered: ‎12-05-2006
Message 1 of 5 (1,593 Views)
Accepted Solution

Inventor 2012 SAVE COPY AS DWG Ilogic Code Error

1593 Views, 4 Replies
01-09-2012 06:55 AM

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.

Employee
jeffrey.sun
Posts: 33
Registered: ‎08-07-2011
Message 2 of 5 (1,578 Views)

Re: Inventor 2012 SAVE COPY AS DWG Ilogic Code Error

01-09-2012 07:42 PM in reply to: rthapa

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

 

  • Create a VB console project
  • Add COM referece "Autodesk Inventor Object Library";

 

  • Add the code to do the dwgout work.

 

 

 

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

 


Please mark this response as "Accept as Solution" if it answers your question.
-----------------------------------------------------------------------------------------



Jeffrey Sun
SW Engineer
Manufacturing Industry Group
Autodesk, Inc.

Employee
jeffrey.sun
Posts: 33
Registered: ‎08-07-2011
Message 3 of 5 (1,571 Views)

Re: Inventor 2012 SAVE COPY AS DWG Ilogic Code Error

01-09-2012 08:36 PM in reply to: jeffrey.sun

Dwg out in c# application

 

 

  • Create a C# console project
  • Add COM referece "Autodesk Inventor Object Library"
  • Add the code to do the dwgout work.

 

 

 

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);

}

}

}

}

 


Please mark this response as "Accept as Solution" if it answers your question.
-----------------------------------------------------------------------------------------



Jeffrey Sun
SW Engineer
Manufacturing Industry Group
Autodesk, Inc.

Contributor
rthapa
Posts: 14
Registered: ‎12-05-2006
Message 4 of 5 (1,557 Views)

Re: Inventor 2012 SAVE COPY AS DWG Ilogic Code Error

01-11-2012 07:51 AM in reply to: rthapa

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.

Member
luigi.trabacchin
Posts: 4
Registered: ‎01-15-2013
Message 5 of 5 (894 Views)

Re: Inventor 2012 SAVE COPY AS DWG Ilogic Code Error

01-15-2013 08:27 AM in reply to: rthapa

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 ...

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube