找回密码 注册 QQ登录
开思网工业级高精度在线3D打印服务

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
查看: 21171|回复: 17
打印 上一主题 下一主题

CATIA用VBScript能不能用VB做复杂点的对话框

[复制链接]
跳转到指定楼层
1
发表于 2004-12-5 22:03:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多同行朋友,交流,分享,学习。

您需要 登录 才可以下载或查看,没有帐号?注册

x
看CAA帮助里面只有InputBox 和msgbox
没提到用VB做复杂的对话框
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 赞一下!赞一下!
2
发表于 2004-12-6 08:05:03 | 只看该作者
认为不能
3
发表于 2004-12-6 10:34:20 | 只看该作者
我试也不能
在C++的CAA上的一个对话框的按钮的响应能不能直接运行script文件呢
4
发表于 2004-12-6 11:45:10 | 只看该作者
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)  
5
发表于 2004-12-6 14:22:42 | 只看该作者
没试出来
麻烦说一下参数吧
iLibraryName
iType
oResult的初始赋值
6
发表于 2004-12-7 13:35:23 | 只看该作者
?
7
发表于 2004-12-7 14:03:21 | 只看该作者
[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;  
}
8
发表于 2004-12-7 19:05:04 | 只看该作者
请问各位大侠有些什么CATIA的二次开发的书籍或资料呀?谢谢
9
发表于 2004-12-9 20:55:25 | 只看该作者
就是阿,谢谢先
10
发表于 2004-12-10 16:59:29 | 只看该作者
程序开发的前期可以用CATIA中的VBA做,后期或者要做比较复杂的对话框就把在VBA中做的模块导入到VB中做吧,可以做的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2024-12-27 04:12 , Processed in 0.028168 second(s), 11 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表