Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Version mismatch when exporting from Inventor to CATIA by the API

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
RichardErnstberger
947 Views, 3 Replies

Version mismatch when exporting from Inventor to CATIA by the API

Hi all,
i'm facing strange behaviour with Inventor 2013 (PDS Ultimate).

I'm working close with some CATIA users and therefore i have to export frequently files to CATIA (parts and assemblies).

If i export files manually by invoking Inventors SAVEAS command rom the pukkdown menu, i can select the proper CATIA target (V5 R19 in my case) and the exported files are pretty good in CATIA.

 

Attached is a screenshot from the options dialog in Inventor 2013 which proves the default output format is V5 R19,


For a set of company standard parts i use a small program (Inventor addin, written in C++) which generates the desired parts by selected parameters and automatically exports them as CATIA files.

And here things become weird.

All exported CATPart's and CATProduct's are created in format V5 R20 which my users cannot open.

I have tried 2 different approaches:

1, Create CATIA files by the current documents saveas method.

    I made sure that the CATIA output format was set to V5 R19 as default.
   This is the case when i open the SAVEAS command from Inventors pulldown menu,

   switch to CATIA export and check the options: default value is V5 R19.
  

   Then, in my appplication i make a call a like this:
   HRESULT hr = pDoc->SaveAs(CComBSTR("Test.CATPart") , VARIANT_TRUE);
   
   A file is created but it cannot be imported into CATIA V5R19 because it is in release R20.
   When i look into the file with a texteditor i can find the version ID tags as "V5R20SP0HF0".
   
2, Create CATIA files by the Translator addin.
   This doesn't work either.
   Here's my simplified code (based ona sample from the http://adndevblog.typepad.com/manufacturing blog:
    
   HRESULT createfile_CATIA_V5R19_Part(CComPtr<Application> m_pApplication ,

                                                                    CComPtr<Document> pDoc ,

                                                                    const CString sInventorFileToSave)
   {
    HRESULT hretv = S_OK;
    //
    // Find the translator addin
    CComPtr<ApplicationAddIns> pAddIns;
    m_pApplication->get_ApplicationAddIns(&pAddIns);
    //
    CComPtr<TranslatorAddIn> pAddIn;
    // Translator: CATIA V5 Part Export {2FEE4AE5-36D3-4392-89C7-58A9CD14D305}
    pAddIns->get_ItemById(_bstr_t("{2FEE4AE5-36D3-4392-89C7-58A9CD14D305}") , (ApplicationAddIn**)&pAddIn);
    //
    if (pAddIn == NULL){
        AfxMessageBox(_T("setCATIA_Out_Opts_V5R19(); No Addin object created!") , MB_OK);
        _tprintf_s(_T("*** Could not find the translator addin ***\n"));
        return E_FAIL;
    }
    //
    pAddIn->Activate();
    //
    // Set it up
    CComPtr<TransientObjects> pTr;
    m_pApplication->get_TransientObjects(&pTr);
    //
    CComPtr<TranslationContext> pContext;
    pTr->CreateTranslationContext(&pContext);
    pContext->put_Type(IOMechanismEnum::kFileBrowseIOMechanism);
    //
    CComPtr<DataMedium> pMedium;
    pTr->CreateDataMedium(&pMedium);
    //
    CComBSTR bstrOutputFile(sInventorFileToSave);
    pMedium->put_FileName(bstrOutputFile);
    //
    CComPtr<NameValueMap> pOptions;
    pTr->CreateNameValueMap(&pOptions);
    //
    VARIANT_BOOL hasOptions;
    pAddIn->get_HasSaveCopyAsOptions(pDoc, pContext, pOptions, &hasOptions);
    if (hasOptions == VARIANT_TRUE){
        hretv = pOptions->put_Value(_bstr_t("Version") , CComVariant(_T("CATIA V5(19)")));
        if(FAILED(hretv)) AfxMessageBox(_T("Failed to set CATIA output options!") , MB_OK);
    }
    //
    pAddIn->SaveCopyAs(pDoc, pContext, pOptions, pMedium);
    //
    return hretv;
   }
   
I have verified that the call to SaveCopyAs has succeeded,

but regardless of the CATIA version set in pOptions it always creates a V5R20 output file.
 
The problem must be specific to Inventor 2013.
Running the Addin in Inventor 2012 works as expected and creates V5R19 files.
 
Can anyone please verify this issue?
 
It would be great to get some information on this -

otherwise i cannot use Inventor 2013 and have to stay with 2012 - which is not my favourite.
 
Kind regards,
Richard

3 REPLIES 3
Message 2 of 4

Hi Richard,

 

In the API Help File you can see the options of the Translator AddIns. Here is an unformatted version of the relevant part:

>>>>>

Version Integer CATIA: 20
JT: 95
Pro/ENGINEER Granite: 7
Parasolid: 24
SAT: 7
CATIA V5, JT, Parasolid, Pro/ENGINEER, SAT 

<<<<<

 

The Version option is Integer (20 is the default value in case of CATIA), but you are passing in a string. You should simply pass in the number 19 as an Integer. I guess something like this should work:

>>>>>

hretv = pOptions->put_Value(_bstr_t("Version") , CComVariant(19));

<<<<<

 

I hope this helps.

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 4

Hi Adam,

many thanks for your suggestion.

 

It works this way.

 

I'm still struggling with that COM stuff.

From my experience with ObjectARx i know how tu use correct variable types but with COM and all that variants it's sometimes not that clear which types to use.

I've looked in the API docs, and there's a section labeled "Definitions of Export Values" and there's nothing about integer types in this section.

 

From my experience up to now it is not very likely to get help on C++ issues in this forum, so again many thanks to you.

 

However, this doesn't solve the root issue: Inventor 2013 doesn't take the last used export format (R19 as described) as the default when exporting from a API function but always uses the (maybe hardcoded) default version 20.

 

From the user interface (pulldown menu) the last successful exported format is recognized and treated as the default: a totally different behaviour of Inventor here between user interface and API.

 

Export via API functions has worked with Inventor 2012 - maybe just because the default output format for 2012 was CATIA R19?

 

Anyway, i can live with this solution - but maybe the development could look at this to keep the same behaviour in the API as in the user interface related to the default output version.

 

Regards,

Richard

Message 4 of 4

Hi Richard,

 

You're welcome! 🙂

 

"Export via API functions has worked with Inventor 2012 - maybe just because the default output format for 2012 was CATIA R19?"

I would bet that is correct.

 

I updated a similar logged behaviour concerning SaveAs not taking into account user settings with the info that it happens with the CATIA V5 translator as well.

 

Cheers,



Adam Nagy
Autodesk Platform Services

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report