## start step: dummynls at 02/09/2006-14:02:38
## end step: dummynls at 02/09/2006-14:02:38
== Command done, return code = 0
小弟觉得参数1和参数3有问题,可是论坛里没有这方面的帖子,相关的也只是引用script程序,不是引用CATVba程序,初学不会,见笑了。望高手们明示.....作者: saeba 时间: 2006-2-9 14:50
Nothing to do with the parameters. It is only a link error.
You have to insert the right module name in your make file. (mkmake?).作者: xinghesnak 时间: 2006-2-9 17:01
我的VBA模块名就叫"模块1"啊?没有错误。。。另外seaba兄的英语真好哈^_^作者: silvia 时间: 2006-2-10 11:28
如果你觉得参数1和参数3有问题
那么就加
CATUnicodeString.h+强制cast
试试看be作者: xinghesnak 时间: 2006-2-10 13:35
还是不行啊。。。。作者: saeba 时间: 2006-2-10 17:12
Sorry i don't have Chinese IME installed so I can only type alphabets...
-_-... I mean there is nothing to do with your source.
You error is a link error, say, the linker can not find the good object to link the symbol "ExecuteScript@CATScriptUtilities...".
So you have to tell the linker where to find it.
To do this, you have to add the module name which contains the symbol "ExecuteScript@CATScriptUtilities..." in your makefile (NOT the cpp file!).
(nothing to do with your VBA模块名!!!)
There is a file in the same directory (named src?) of your cpp files which has a name like ***.mkmake or something.
You have to edit this file.
So what to add? You can place your mouse pointer on the word CATScriptUtilities and press Ctrl+F1 so a help window will appear, and in the bottom of the page, there should be the module name.
Sorry I don't have CAA any longer so can't help you more but you can ask anyone who knows how to edit a makefile.
o Subscribe
public int Subscribe( int iSubscribingType,
CATCommand* iToClient,
void* iClientData,
void(*)() UserStaticMethod)
Adds a transaction/idle subscription to a command.
Parameters:
iSubscribingType
The subscribing type.
Legal values: Can be set to CATSubscribeEndTransaction (=1) or to CATSubscribeIdle (=2)
iToClient
The command to call with its UserStaticMethod
iClientData
Data useful to UserStaticMethod
UserStaticMethod
The method to call when the state defined by iSubscribingType is reached.
Returns:
0 if the transaction/idle subscription is successfully added and 0 otherwise
看看callback作者: xinghesnak 时间: 2006-2-17 15:41
callback是什么东东?^_^作者: xinghesnak 时间: 2006-2-20 08:03
还是要顶,真的没有人会吗?作者: saeba 时间: 2006-2-21 14:39
public int Subscribe( int iSubscribingType,
CATCommand* iToClient,
void* iClientData,
void(*)() UserStaticMethod)
iSubscribingType: 1 or 2, you can try both
iToClient: pointer to your(?) command
iClientData: Do you want to pass some data to your command? if no, set it NULL; yes? pointer to your data.
UserStaticMethod: pointer to a method of your command which must be "static", this will be used as a callback. (so if some event happens, system will call this method, this is called "callback")
However I don't think you REALLY want to use this.
Better paste you VBA code and mark where the error occurs, and the error messsages.
So someone familiar with VBA could help you.
I don't think anybody here ever have chance to use this CATApplication::Subscribe().作者: xinghesnak 时间: 2006-2-21 17:01
To saeba:Thank you very much!
VBA code and mark where the error occurs is:
Function GetPart(InfString As String, Optional Product As Product, Optional RootProduct As Product) As Part
Dim TagPrduct, Status
ReDim InputObjectType(0)
InputObjectType(0) = "Product"
LocSel.Clear
Status = LocSel.SelectElement3(InputObjectType, "选择用来存放 " & InfString & " 的 Product:", False, CATMultiSelTriggWhenSelPerf, False) *********错误的就是这行,就是屏幕选取受到限制
.........
end function
how to replace CATApplication::Subscribe() to the first parameter of CATUtilities::executescript()????
where is the return value of CATApplication::Subscribe()??
For example:The path of MyVBA projectis:"d:\1.catvba",two moudle:"11"and "22"--------"Sub main"作者: saeba 时间: 2006-2-21 18:55
what is the error message?
>我看CAA帮助说需要用 CATApplication.Subscribe 来返回第一个参数值
I don't understand why...
Could you paste this part of the document?
>how to replace CATApplication::Subscribe() to the first parameter of >CATUtilities::executescript()????
The first parameter of CATUtilities::executescript() is a UncodeString...作者: xinghesnak 时间: 2006-2-22 08:44
ExecuteScript 的用法:
A short-cut method which runs a function written in a scripting language synchronously. ExecuteScript will return only once the scripted function has finished running.
Note:If the script uses one of the following methods:
Selection.SelectElement2 *************我在VBA中的就是用的这个方法!
Document.Indicate2D
Document.Indicate3D
the current method must be ran on idle, using CATApplication.Subscribe with the CATSubscribeIdle value for the first parameter.
Parameters:
iLibraryName
The library in which the script is contained
iLibraryType
The type of the library
iProgramName
The name of the program in the library
oResult
The value returned by the function (if any)
iFunctionName
The name of the function to invoke
iParameters
An C++ array of parameters for the function
iParamCount
The size of the parameter array.
iAutomaticReplay
Specifies whether the replay is automatic or if it is explicitly done from a user interaction作者: saeba 时间: 2006-2-22 11:20
>the current method must be ran on idle, using CATApplication.Subscribe with the CATSubscribeIdle value for the first parameter.
Ok this is the point.
"the current method must be ran on idle", what is "the current method"?
I guess it could be the Active method of your command, or any method in your command which called ExecuteScript().
So how can I make it "be ran on idle"?
Use CATApplication.Subscribe() to subscribe this method (the above method) run in type of CATSubscribeIdle. I guess you should do this in the constructor of your command.
You may code like this:
CATApplication::Subscribe(CATSubscribeIdle, this, NULL, MyCommand::MyMethod);
(understand why "this"? )
Note, you misunderstood " the first parameter", here it means the first parameter of the method CATApplication.Subscribe(), NOT CATUtilities::executescript()!!!
I don't guarantee this work, it's all based on my understanding/guessing.作者: xinghesnak 时间: 2006-2-23 15:26
To saeba:
Thank you for your help! I always think that " the first parameter" is the first parameter of the method CATUtilities::executescript().Now I try it again! If I still meet some difficult progrem,I hope you can help me,Thank you !!!作者: joetwo 时间: 2006-2-28 14:14
第一个参数"C:\\Documents and Settings\\liguangyi\\Local Settings\\Temp\\VBAProject1.catvba"和第三个参数 "模块1"怎么定义的呀?
为什么不是"C:\\Documents and Settings\\liguangyi\\Local Settings\\Temp“和”VBAProject1.catvba"?
“模块1”是哪里来的?
谢谢!作者: xinghesnak 时间: 2006-2-28 15:04
第一个参数指的是Catvba文件的全路径
第三个参数指的是catvba文件中你所要运行的模块的名称(因为一个catvba文件可以包含多个模块,程序并不知道你要执行哪个,需要你去指定)
joetwo,有不明白的尽管说,没关系的!另外saeba兄,听说你终于装了中文输入法了,可喜可贺啊!!!还有就是你说的参数 MyCommand::MyMethod这块怎么添啊?
是这样?
CATApplication::Subscribe(CATSubscribeIdle,this,NULL,this);
CATScriptUtilities::ExecuteScript("D:\\WORK\\CATIA-VC++\\Program1.catvba", catScriptLibraryTypeVBAProj e ct, "bb", var2, "CATMain", NULL, 0,TRUE);
还是:
CATApplication::Subscribe(CATSubscribeIdle,this,NULL,CATScriptUtilities::ExecuteScript());
CATScriptUtilities::ExecuteScript("D:\\WORK\\CATIA-VC++\\Program1.catvba", catScriptLibraryTypeVBAProj e ct, "bb", var2, "CATMain", NULL, 0,TRUE);
我用的前者,报错如下
D:\WORK\CATIA-VC++\workspace2\.\ASSET\CmdModule.m\src\Test2Cmd.cpp(36) : error C2664: 'Subscribe' : cannot convert parameter 4 from 'class Test2Cmd *const ' to 'void (__cdecl *)(void)'
There is no context in which this conversion is possible