admin 发表于 2017-4-17 21:58:43

Catia二次开发源码分享:选择一个平面


Catia二次开发源码分享:选择一个平面

#include "CAARCSelectPlane.h"
#include "CATIndicationAgent.h"
#include "CATMathPlane.h"

#include "CATCreateExternalObject.h"


#include "CATIGSMPlane.h"

#include "CATPathElementAgent.h"

#include "CATPathElement.h"

#include "CATISpecObject.h"

#include "CATApplicationFrame.h"

#include "CATDlgWindow.h"

#include "CATDlgNotify.h"

#include "CATSO.h"

CATCreateClass( CAARCSelectPlane);


//-------------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------------
CAARCSelectPlane::CAARCSelectPlane() :
CATStateCommand ("CAARCSelectPlane", CATDlgEngOneShot, CATCommandModeExclusive)
{
}

//-------------------------------------------------------------------------
// Destructor
//-------------------------------------------------------------------------
CAARCSelectPlane::~CAARCSelectPlane()
{

}


//-------------------------------------------------------------------------
// BuildGraph()
//-------------------------------------------------------------------------
void CAARCSelectPlane::BuildGraph()
{
// ---------------------------
// TODO: Define the StateChart
// ---------------------------
_daPathEltPlane = new CATPathElementAgent("SelPlane");
_daPathEltPlane->AddElementType(IID_CATIGSMPlane);
_daPathEltPlane->SetBehavior(CATDlgEngWithPSOHSO |CATDlgEngMultiAcquisitionUserCtrl | CATDlgEngWithPrevaluation |CATDlgEngWithCSO | CATDlgEngWithUserSelectionFilter);//CATDlgEngMultiAcquisitionCtrl需要用户确定选择对象;CATDlgEngMultiAcquisitionSelModes 不需要用户确定直接得到用户选择
AddCSOClient(_daPathEltPlane);

CATDialogState *stGetPlane = GetInitialState("选择面");
stGetPlane->AddDialogAgent(_daPathEltPlane);

CATDialogTransition *pFirstTransition = AddTransition
    (
    stGetPlane,
    NULL,
    IsOutputSetCondition(_daPathEltPlane),                  
    Action((ActionMethod) & CAARCSelectPlane::ActionOne)
    );
}


//-------------------------------------------------------------------------
// ActionOne ()
//-------------------------------------------------------------------------
CATBoolean CAARCSelectPlane::ActionOne( void *data )
{
// TODO: Define the action associated with the transition
// ------------------------------------------------------
//CATPathElement* pObject = _daPathEltPlane->GetValue();

////如果选择对象不为空的处理
//if (pObject && pObject->GetSize())
//{
//int objectSize = pObject->GetSize() - 1;
//CATBaseUnknown *sProduct = (*pObject);

//CATISpecObject *spArea;
//sProduct->QueryInterface(IID_CATISpecObject, (void**)&spArea);

//CATUnicodeString displayName = spArea->GetDisplayName();

//CATApplicationFrame *pApplication = CATApplicationFrame::GetFrame();

//if (NULL != pApplication) {

//    CATDlgWindow * pMainWindow = pApplication->GetMainWindow();

//    CATDlgNotify *pNotifyDlg = new CATDlgNotify
//      (pMainWindow, "提示", CATDlgNfyOK);

//    if (NULL != pNotifyDlg) {
//      pNotifyDlg->DisplayBlocked
//      (displayName,
//      "选择的面为:");

//      pNotifyDlg->RequestDelayedDestruction();
//    }
//}

//}

CATSO * pPlaneCATSO = _daPathEltPlane->GetListOfValues();

if (pPlaneCATSO != NULL)
{
    int pPlaneCATSOSize = pPlaneCATSO->GetSize();

    for ( int i = 0; i < pPlaneCATSOSize; i++ )
    {
      CATPathElement * pPlanePathElement = (CATPathElement*)(*pPlaneCATSO);

      if (NULL != pPlanePathElement)
      {
      int pPlanePathElementSize = (pPlanePathElement->GetSize() - 1);

      CATBaseUnknown * pPlaneObject = (*pPlanePathElement);

      CATISpecObject *spArea;
      pPlaneObject->QueryInterface(IID_CATISpecObject, (void**)&spArea);

      CATUnicodeString displayName = spArea->GetDisplayName();

      CATApplicationFrame *pApplication = CATApplicationFrame::GetFrame();

      if (NULL != pApplication) {

          CATDlgWindow * pMainWindow = pApplication->GetMainWindow();

          CATDlgNotify *pNotifyDlg = new CATDlgNotify
            (pMainWindow, "提示", CATDlgNfyOK);

          if (NULL != pNotifyDlg) {
            pNotifyDlg->DisplayBlocked
            (displayName,
            "选择的面为:");

            pNotifyDlg->RequestDelayedDestruction();
          }
      }
      }
    }
}

return TRUE;
}


cwp86 发表于 2018-3-29 17:57:55

在试编译代码过程,无法找到CAARCSelectPlane.h这个文件

cwp86 发表于 2018-5-6 19:25:32

这段代码好像有问题不能正常运行
页: [1]
查看完整版本: Catia二次开发源码分享:选择一个平面