Search code examples
autodesk-forgeautodesk-designautomation

Unspecified error on adding the Drawing Document


i was stuck in a problem, where i need to open a new drawing file with the specified template file, as shown below.

objInventorServer.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject, templatePath)

But this line is giving an unspecified error in the workitem log. Problem is happening with InventorServer object, i guess. Because on using the same line in Local Machine with normal Inventor.Application object, its working fine. Please help me with issue.


Solution

  • I only ran into a problem if the drawing file was from a newer version than the Inventor Server I was running, but then I got more messages:

    [05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : 
    RunWithArguments called
    [05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : Creating 
    drawing based on template T:\Aces\Applications\317779a582552210117f0484dd24ec3e.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[9].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw
    [05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : FileExists = True
    [05/28/2020 16:23:54]     InventorCoreConsole.exe Error: 0 : Inventor message: This file was saved in a newer version of the product. Inventor can't open newer versions of drawing (.idw, .dwg) and presentation (.ipn) files.
    [05/28/2020 16:23:54] To open a part (.ipt) or an assembly (.iam) file one year newer than your current version, install the latest updates.
    [05/28/2020 16:23:54] T:\Aces\Applications\317779a582552210117f0484dd24ec3e.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[9].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw (Inventor Server x64 SDK 2020 (Build 240168000, 168))
    [05/28/2020 16:23:54] Search in the Inventor help for 'Troubleshooting Opening Newer Files' for information on how to open a newer file.
    [05/28/2020 16:23:54]     InventorCoreConsole.exe Error: 0 : Inventor inner xml:
    [05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : Deactivating plug-in: SampleBundlePlugin
    [05/28/2020 16:23:54]     InventorCoreConsole.exe Information: 0 : : SampleBundlePlugin: deactivating...
    [05/28/2020 16:23:54] T h e   p a r a m e t e r   i s   i n c o r r e c t .   ( E x c e p t i o n   f r o m   H R E S U L T :   0 x 8 0 0 7 0 0 5 7   ( E _ I N V A L I D A R G ) )
    [05/28/2020 16:23:54]
    

    But in that case Open would fail as well 🤔

    If I was using the same version for both the file and Inventor Server then this code succeeded:

    public void RunWithArguments(Document doc, NameValueMap map)
    {
    LogTrace("RunWithArguments called");
    
    string idwPath = map.Item["_1"];
    LogTrace("Creating drawing based on template " + idwPath);
    LogTrace("FileExists = " + System.IO.File.Exists(idwPath).ToString());
    Document idwDoc = inventorApplication.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject, idwPath); 
    LogTrace("Created drawing based on template " + idwPath);
    }
    

    This is the report:

    [05/28/2020 16:33:33]     InventorCoreConsole.exe Information: 0 : RunWithArguments called
    [05/28/2020 16:33:33]     InventorCoreConsole.exe Information: 0 : Creating drawing based on template T:\Aces\Applications\eb17e332f09e0e2951aafbe13df81d70.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[10].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw
    [05/28/2020 16:33:33]     InventorCoreConsole.exe Information: 0 : FileExists = True
    [05/28/2020 16:33:34]     InventorCoreConsole.exe Information: 0 : Created drawing based on template T:\Aces\Applications\eb17e332f09e0e2951aafbe13df81d70.rGm0mO9jVSsD2yBEDk9MRtXQTwsa61y0.SampleBundle[10].package\SampleBundlePlugin.bundle\Contents\Templates\ANSI (in).idw 
    

    Do you run into this problem with all your Inventor Drawing templates?