在交互窗口中打開一個Part文檔

譯自maruf.ca/rade/web/

#include "CATIIniInteractiveSession.h"n#include "CATSession.h"n#include "IUnknown.h"n#include "CATSessionServices.h"n#include "CATIEditor.h"nnCATBoolean OpenPartExample::OpenPart()n{ntHRESULT rc;ntrc = NULL;nntCATSession* pSession = NULL;ntrc = GetPtrSession(pSession);nntCATIIniInteractiveSession* interSession = NULL;ntrc = pSession->QueryInterface(IID_CATIIniInteractiveSession,(void**) &interSession);nntCATIEditor * pInterSesEditor = NULL ;ntrc = interSession->Open("C:tmpexample_part.CATPart",FALSE,&pInterSesEditor);ntntinterSession->Release();ntreturn TRUE;n}n

注意

  • GetPtrSession 回調是一個用來返回CATSession的全局宏。

  • 為了交互地打開一個part(相對batch模式來說)你一定要從CATSession檢索CATIIniInteractiveSession。這是通過對CATSession用QueryInterface方法完成的。如果你不想通過交互方式完成,你可以用CATDocumentServices類。
  • 一旦獲得了CATIIniInteractiveSession,你可以用CATIIniInteractiveSession的方法簡單地打開,關閉,保存,另存為等。
  • 在這個例子中,Open方法返迴文檔的CATIEditor。一個CATEditor在session里連接到一個文檔。(見Handling Multiple Parts In One Session)

推薦閱讀:

superset二次開發-修改圖表顏色
一種「自動」出圖的設計方法
CATIA二次開發之裝配約束
CATIA Automation Development

TAG:CATIA | 二次开发 | PLM |