iCAx开思网

标题: CATIA用VBScript能不能用VB做复杂点的对话框 [打印本页]

作者: liketulip    时间: 2004-12-5 22:03
标题: CATIA用VBScript能不能用VB做复杂点的对话框
看CAA帮助里面只有InputBox 和msgbox
没提到用VB做复杂的对话框
作者: acoka    时间: 2004-12-6 08:05
认为不能
作者: liketulip    时间: 2004-12-6 10:34
我试也不能
在C++的CAA上的一个对话框的按钮的响应能不能直接运行script文件呢
作者: acoka    时间: 2004-12-6 11:45
ExecuteScript( const CATUnicodeString&  iLibraryName,  
  CatScriptLibraryType  iType,  
  const CATUnicodeString&  iProgramName,  
  CATVariant&  oResult,  
  const CATUnicodeString&  iFunctionName = "CATMain",  
  CATVariant*  iParams = NULL,  
  unsigned int  iParamCount = 0,  
  CATBoolean  iAutomaticReplay = TRUE)  
作者: liketulip    时间: 2004-12-6 14:22
没试出来
麻烦说一下参数吧
iLibraryName
iType
oResult的初始赋值
作者: liketulip    时间: 2004-12-7 13:35
?
作者: acoka    时间: 2004-12-7 14:03
[quote][b]liketulip wrote:[/b]
没试出来  
  麻烦说一下参数吧  
  iLibraryName  
路径名之类
  iType  
CATScript, VBScript...
  oResult的初始赋值 [/quote]
  
Example:  
This example illustrates how to call this method on time-out. It describes how to migrate from a CATStateCommand, named CAAMyStateCommand, which would run ExecuteScript synchronously, to a CATStateCommand which would run ExecuteScript on time-out.
Instead of:  
a transition, and its associated action, which:  
run the script synchronously  
do the actions which must be ran after the script execution  
the transition triggering during execution making pass from a CATDialogState named SourceState to a CATDialogState named DestinationState  
we will have:  
a transition executing the first part of the preceeding solution: it adds a call-back on time out, the call-back running the script  
this transition makes pass from a CATDialogState named SourceState to a CATDialogState named IntermediaryState  
during execution, when the current state will be IntermediaryState, the preceeding call-back will be executed. This call-back runs the script, and triggers the other transition  
another transition executing the second part of the preceeding solution: do the actions which must be ran after the script execution  
this transition makes pass from IntermediaryState to a CATDialogState named DestinationState  
Your code will be the following:  
CAAMyStateCommandInteractionNotifier.h:
#ifndef CAAMyStateCommandInteractionNotifier_H
#define CAAMyStateCommandInteractionNotifier_H
#include "CATCommand.h"
class CATNotification;   
class CAAMyStateCommandInteractionNotifier: public CATCommand
{ public:
  CAAMyStateCommandInteractionNotifier();
  virtual ~CAAMyStateCommandInteractionNotifier();
  void Advise(CATCommand* ToClient, CATNotification* Notif);
};
#endif
CAAMyStateCommandInteractionNotifier.cpp:
#include "CAAMyStateCommandInteractionNotifier.h"
#include "CATCommand.h"
#include "CATNotification.h"
CAAMyStateCommandInteractionNotifier::CAAMyStateCommandInteractionNotifier()  
{}
CAAMyStateCommandInteractionNotifier::~CAAMyStateCommandInteractionNotifier()
{}
void CAAMyStateCommandInteractionNotifier::Advise(CATCommand* ToClient, CATNotification* Notif)
{ SendNotification(ToClient,Notif); }
CAAMyStateCommandNotification.h:
#ifndef CAAMyStateCommandNotification_H
#define CAAMyStateCommandNotification_H
#include "CATNotification.h"
class CAASourceStateToIntermediaryStateNotif : public CATNotification
{ CATDeclareClass;
  public:
    CAASourceStateToIntermediaryStateNotif();
    virtual ~CAASourceStateToIntermediaryStateNotif();
};
class CAAIntermediaryStateToDestinationStateNotif : public CATNotification
{ CATDeclareClass;
  public:
    CAAIntermediaryStateToDestinationStateNotif();
    virtual ~CAAIntermediaryStateToDestinationStateNotif();
};
class CAADestinationStateToNULLStateNotif : public CATNotification
{ CATDeclareClass;
  public:
    CAADestinationStateToNULLStateNotif();
    virtual ~CAADestinationStateToNULLStateNotif();
};
#endif
CAAMyStateCommandNotification.cpp:
#include "CAAMyStateCommandNotification.h"
CATImplementClass(CAASourceStateToIntermediaryStateNotif,Implementation,CATNotification,CATNull);
CAASourceStateToIntermediaryStateNotif::CAASourceStateToIntermediaryStateNotif() {}
CAASourceStateToIntermediaryStateNotif::~CAASourceStateToIntermediaryStateNotif() {}
CATImplementClass(CAAIntermediaryStateToDestinationStateNotif,Implementation,CATNotification,CATNull);
CAAIntermediaryStateToDestinationStateNotif::CAAIntermediaryStateToDestinationStateNotif() {}
CAAIntermediaryStateToDestinationStateNotif::~CAAIntermediaryStateToDestinationStateNotif() {}
CATImplementClass(CAADestinationStateToNULLStateNotif,Implementation,CATNotification,CATNull);
CAADestinationStateToNULLStateNotif::CAADestinationStateToNULLStateNotif() {}
CAADestinationStateToNULLStateNotif::~CAADestinationStateToNULLStateNotif() {}
CAAMyStateCommand.h:
#ifndef CAAMyStateCommand_h
#define CAAMyStateCommand_h
#include "CATStateCommand.h"
#include "CATPanelAcquisition.h"
#include "CAAMyStateCommandNotification.h"
#include "CAAMyStateCommandInteractionNotifier.h"
#include "CATPathElement.h"
#include "CATNotifier.h"
class CATDialogAgent;
class CAAMyStateCommand: public CATStateCommand
{ CmdDeclareResource(CAAMyStateCommand,CATStateCommand);
  public:
  CAAMyStateCommand( );
  virtual ~CAAMyStateCommand();
  virtual CATStatusChangeRC Activate(CATCommand*  iFromClient,CATNotification*  iNotification);
  virtual CATStatusChangeRC Desactivate(CATCommand*  iCmd,CATNotification*  iNotification);
  virtual CATStatusChangeRC Cancel(CATCommand*  iCmd,CATNotification*  iNotification);
  virtual void BuildGraph();
  static void sRunScriptAndTriggerSecondPartTransition(CATCommand* iCAAMyStateCommand,int iSubscribedType,
                                                       CATString* iScriptName);
  CAASourceStateToIntermediaryStateNotif* _CAASourceStateToIntermediaryStateNotif;
  CAAIntermediaryStateToDestinationStateNotif* _CAAIntermediaryStateToDestinationStateNotif;
  CAADestinationStateToNULLStateNotif* _CAADestinationStateToNULLStateNotif;
  CATBoolean FirstPartTransitionAction(void *data);
  CATBoolean SecondPartTransitionAction(void *data);      
  CATBoolean EndCommandTransitionAction(void *data);
  static CAAMyStateCommandInteractionNotifier* sInteractionNotifier;         
  CATDialogAgent* _FirstPartDialogAgent;
  CATDialogAgent* _SecondPartDialogAgent;
  CATDialogAgent* _EndCommandDialogAgent;
  CATString _ScriptName;
};
#endif
CAAMyStateCommand.cpp:
#include "CAAMyStateCommand.h"
#include "CAAMyStateCommandNotification.h"
#include "CATApplication.h"
#include "CATScriptUtilities.h"
#include "CATAutoConversions.h"
#include "CATDialogAgent.h"
#include "CATGetEnvValue.h"
CAAMyStateCommandInteractionNotifier*  CAAMyStateCommand::sInteractionNotifier  = NULL;
void CAAMyStateCommand::sRunScriptAndTriggerSecondPartTransition(
                        CATCommand* iCAAMyStateCommand,int iSubscribedType,
                        CATString* iScriptName)
{ CATLibStatus LibOK;
  CATUnicodeString FolderName;
  CAAIntermediaryStateToDestinationStateNotif* CAAIntermediaryStateToDestinationStateNotif = NULL;
  CAAMyStateCommand* MyStateCommand;
  CATDialogAgent* SecondPartDialogAgent = NULL;
  CATApplication* Application = NULL;
  char* CATTempValue = NULL;
  CATVariant VariantReturnValue;
  long ReturnValue;
  HRESULT hr;
   Application = CATApplication::MainApplication();
  MyStateCommand = (CAAMyStateCommand*)iCAAMyStateCommand;
  CAAIntermediaryStateToDestinationStateNotif =  
    MyStateCommand->_CAAIntermediaryStateToDestinationStateNotif;
  SecondPartDialogAgent = MyStateCommand->_SecondPartDialogAgent;
   // We run the "CATMain" sub of the "MyScript.catvbs" script located in the place specified by
  // the CATTemp environment variable  
  LibOK = CATGetEnvValue("CATTemp",[$CATTempValue)]
  if (LibOK == CATLibSuccess)  
    { FolderName = CATTempValue; ReturnValue = 0;
      hr = BuildVariant((const long)ReturnValue,VariantReturnValue);
       hr = CATScriptUtilities::ExecuteScript(FolderName,catScriptLibraryTypeDirectory,  
                                               iScriptName->CastToCharPtr(),VariantReturnValue,
                                               "CATMain");
    }
  // we trigger the second part transition
  sInteractionNotifier->Advise(SecondPartDialogAgent->GetFather(),
                               MyStateCommand->_CAAIntermediaryStateToDestinationStateNotif);
}
CAAMyStateCommand::CAAMyStateCommand():
  CATStateCommand ("CAAMyStateCommand",CATCommandModeExclusive)  
  ,_FirstPartDialogAgent(NULL),_SecondPartDialogAgent(NULL)
{ _CAASourceStateToIntermediaryStateNotif = new CAASourceStateToIntermediaryStateNotif();
  _CAAIntermediaryStateToDestinationStateNotif = new CAAIntermediaryStateToDestinationStateNotif();
  _CAADestinationStateToNULLStateNotif = new CAADestinationStateToNULLStateNotif();
  sInteractionNotifier = new CAAMyStateCommandInteractionNotifier();
}
CAAMyStateCommand::~CAAMyStateCommand()
{ if (_CAASourceStateToIntermediaryStateNotif!=NULL)  
    { _CAASourceStateToIntermediaryStateNotif->Release(); _CAASourceStateToIntermediaryStateNotif = NULL; }
  if (_CAAIntermediaryStateToDestinationStateNotif!=NULL)  
    { _CAAIntermediaryStateToDestinationStateNotif->Release(); _CAAIntermediaryStateToDestinationStateNotif = NULL; }
  if (_CAADestinationStateToNULLStateNotif!=NULL)  
    { _CAADestinationStateToNULLStateNotif->Release(); _CAADestinationStateToNULLStateNotif = NULL; }
  if (_FirstPartDialogAgent!=NULL)   
    { _FirstPartDialogAgent->RequestDelayedDestruction(); _FirstPartDialogAgent = NULL; }
  if (_SecondPartDialogAgent!=NULL)   
    { _SecondPartDialogAgent->RequestDelayedDestruction(); _SecondPartDialogAgent = NULL; }
  if (_EndCommandDialogAgent!=NULL)   
    { _EndCommandDialogAgent->RequestDelayedDestruction(); _EndCommandDialogAgent = NULL; }
  if (sInteractionNotifier!=NULL)  
    { sInteractionNotifier->RequestDelayedDestruction(); sInteractionNotifier = NULL; }
}
CATStatusChangeRC CAAMyStateCommand::Activate (CATCommand* FromClient,CATNotification* EvtDat )
{ return (CATStatusChangeRCCompleted); }
CATStatusChangeRC CAAMyStateCommand::Desactivate (CATCommand* iCmd,CATNotification* iNotification)
{ return (CATStatusChangeRCCompleted); }
CATStatusChangeRC CAAMyStateCommand::Cancel (CATCommand* iCmd,CATNotification* iNotification)
{ return (CATStatusChangeRCCompleted); }
void CAAMyStateCommand::BuildGraph()
{ CATDialogState* SourceState = NULL;
  CATDialogState* IntermediaryState = NULL;
  CATDialogState* DestinationState = NULL;
  // we fill the dialog agents
  _FirstPartDialogAgent = new CATDialogAgent("CAASourceStateToIntermediaryStateNotif");
  _FirstPartDialogAgent->AcceptOnNotify(sInteractionNotifier,_CAASourceStateToIntermediaryStateNotif);
  _SecondPartDialogAgent = new CATDialogAgent("CAAIntermediaryStateToDestinationStateNotif");
  _SecondPartDialogAgent->AcceptOnNotify(sInteractionNotifier,_CAAIntermediaryStateToDestinationStateNotif);
  _EndCommandDialogAgent = new CATDialogAgent("CAADestinationStateToNULLStateNotif");
  _EndCommandDialogAgent->AcceptOnNotify(sInteractionNotifier,_CAADestinationStateToNULLStateNotif);
  // we fill the states
  SourceState = GetInitialState("CAAMyStateCommandSourceState");
  SourceState->AddDialogAgent(_FirstPartDialogAgent);
  IntermediaryState = AddDialogState("CAAMyStateCommandIntermediaryState");
  IntermediaryState->AddDialogAgent(_SecondPartDialogAgent);
  DestinationState = AddDialogState("CAAMyStateCommandDestinationState");
  DestinationState->AddDialogAgent(_EndCommandDialogAgent);
  // we fill the transitions
  AddTransition(SourceState,IntermediaryState,
                IsOutputSetCondition(_FirstPartDialogAgent),
                   Action((ActionMethod) [$CAAMyStateCommand::FirstPartTransitionAction))]
  AddTransition(IntermediaryState,DestinationState,
                IsOutputSetCondition(_SecondPartDialogAgent),
                   Action((ActionMethod) [$CAAMyStateCommand::SecondPartTransitionAction))]
  AddTransition(DestinationState,NULL,
                IsOutputSetCondition(_EndCommandDialogAgent),
                   Action((ActionMethod) [$CAAMyStateCommand::EndCommandTransitionAction))]
  // we trigger the first part transition
  sInteractionNotifier->Advise((CATDialogAgent*)_FirstPartDialogAgent->GetFather(),
                               _CAASourceStateToIntermediaryStateNotif);
}
CATBoolean CAAMyStateCommand::FirstPartTransitionAction(void *data)
{ CATApplication* Application = NULL;
  // insert here the actions which must be ran before the script execution
  
  // we set the sRunScriptAndTriggerSecondPartTransition call-back on time-out
   Application = CATApplication::MainApplication();
  _ScriptName = "MyScript.catvbs";
  Application->AddTimeOut(1,this,&_ScriptName,
                          (void(*)())sRunScriptAndTriggerSecondPartTransition);   
  // we prevent _FirstPartDialogAgent to be valued any more through the notification
  _FirstPartDialogAgent->IgnoreOnNotify(sInteractionNotifier,_CAASourceStateToIntermediaryStateNotif);
  
  return TRUE;
}
  
CATBoolean CAAMyStateCommand::SecondPartTransitionAction(void *data)
{ // insert here the actions which must be ran after the script execution
  
  // we prevent _SecondPartDialogAgent to be valued any more through the notification
  _SecondPartDialogAgent->IgnoreOnNotify(sInteractionNotifier,_CAAIntermediaryStateToDestinationStateNotif);
  // we trigger the end command transition
  sInteractionNotifier->Advise(_EndCommandDialogAgent->GetFather(),_CAADestinationStateToNULLStateNotif);
  
  return TRUE;
}
CATBoolean CAAMyStateCommand::EndCommandTransitionAction(void *data)
{ // we prevent _EndCommandDialogAgent to be valued any more through the notification
  _EndCommandDialogAgent->IgnoreOnNotify(sInteractionNotifier,_CAADestinationStateToNULLStateNotif);
  return TRUE;  
}
作者: 后备力量    时间: 2004-12-7 19:05
请问各位大侠有些什么CATIA的二次开发的书籍或资料呀?谢谢
作者: Patton_icax    时间: 2004-12-9 20:55
就是阿,谢谢先
作者: apple_bao_bao    时间: 2004-12-10 16:59
程序开发的前期可以用CATIA中的VBA做,后期或者要做比较复杂的对话框就把在VBA中做的模块导入到VB中做吧,可以做的。
作者: maxiaozheng    时间: 2004-12-15 17:48
apple_bao_bao wrote:
程序开发的前期可以用CATIA中的VBA做,后期或者要做比较复杂的对话框就把在VBA中做的模块导入到VB中做吧,可以做的。

楼上说的对!VBA开发原理都是一样。但这样不能在CATIA内部框架实现,对话框有点怪,但可设计的很复杂很花哨。
作者: mdy0    时间: 2004-12-18 22:49
应该不能!
作者: acoka    时间: 2004-12-19 20:41
我想的复杂,->与标准catia同等操作性
比如calback, lisence check, dialog state trans, agent function...
作者: qingcai85    时间: 2010-11-24 16:51
没看明白?能不能VB开发界面,嵌入到CATIA界面中?如果可以,怎么做?
作者: qingcai85    时间: 2010-11-24 16:51
没看明白?能不能VB开发界面,嵌入到CATIA界面中?如果可以,怎么做?
作者: qingcai85    时间: 2010-11-24 16:52
没看明白?能不能VB开发界面,嵌入到CATIA界面中?如果可以,怎么做?
作者: xacf    时间: 2010-12-22 21:59
可以开发相当复杂的界面.不要叫CATIA VB 开发.要叫CAA AUTOMATION DEVELOP.
作者: 弓长门各    时间: 2012-8-22 15:43
qingcai85 发表于 2010-11-24 16:51
没看明白?能不能VB开发界面,嵌入到CATIA界面中?如果可以,怎么做?

好像不行吧,我试过。你如果现在可以做的话告诉我。




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3