找回密码 注册 QQ登录
一站式解决方案

iCAx开思网

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

如何解决VB中使用SelectElement报错?

[复制链接]
跳转到指定楼层
1
发表于 2008-10-20 12:04:33 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
请教各位,我用VB做二次开发,使用Selection.SelectElement3或SelectElement2时系统会提示错误:函数或接口标记为限制的,或函数中使用了VB中不支持的类型。

请问这个情况该怎么解决,本人刚刚学习二次开发不久,请各位多多指教!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 赞一下!赞一下!
4
发表于 2009-3-25 19:04:55 | 只看该作者
DIM Selection AS Selection改为DIM Selection

欢迎光临CAX技术论坛,这里有专业的开发人员为您解答开发问题!~
https://www.caxtech.net.cn/index.asp?boardid=33
3
发表于 2008-11-21 18:33:08 | 只看该作者
write your code like this "dim myselection"
instead of "dim myselection as selection"
2
发表于 2008-10-24 05:31:57 | 只看该作者
Func SelectElement2( CATSafeArrayVariant  iFilterType,
CATBSTR  iMessage,
boolean  iObjectSelectionBeforeCommandUsePossibility) As CATBSTR  

Runs an interactive selection command.
Role: SelectElement2 asks the end user to select a feature (in the geometry or in the specification tree). During the selection, when end user will move the mouse above a feature which maps the given filter, the mouse pointer will be the "hand" cursor, and when end user will move the mouse above a feature which does not map the given filter, the mouse pointer will be the "no entry" cursor.

If iObjectSelectionBeforeCommandUsePossibility is equal to False:
The end user is asked to interactively select an appropriate element. When this is done, the Selection object is cleared, and filled with the selected element.

If iObjectSelectionBeforeCommandUsePossibility is equal to True:
SelectElement2 determines whether the automation objects specified in SelectedElement.Value, for the SelectedElement objects contained in the current selection, or one of the parents of the automation objects (see AnyObject.Parent) is an appropriate element:
If it is the case, no interaction is asked to the end user, the Selection object is cleared, and filled with the appropriate element.
Otherwise, the Selection object is cleared, and the end user is asked to interactively select an appropriate element. When this is done, the selection is filled with the selected element.
Note: During the selection scan to find an automation object, a "Product" string constant specified in iFilterType will imply that SelectElement2 will also look at the possible automation object specified in SelectedElement.LeafProduct .
After a call to SelectElement2, if the return value equals to "Normal", a call to the Count2 method will return one, and a call to Item2(1) will return the selected element.
Note: If the scripting language is Visual Basic for Applications or Visual Basic 6 Development Studio, then, you have to know that the use of an interactive selection method such as this one from a form (dialog box) method requires some constraints regarding the content of an average form method.
If your macro possess a form method which calls the SelectElement2 method, then, the content of an average form method of your macro must begin by a test, which checks that no form method is currently being executed and, otherwise, go out of the method. This constraint enable to prevent that, during the execution of the SelectElement2 method from a form method, when CATIA asks the end user to select a feature:

the users select a dialog object of a form (CATIA going on asking the end user to select a feature)
this selection trigger the corresponding form method
this run CATIA automation objects methods, CATIA going on asking the end user to select a feature
which would lead to unpredictable results.
The code will be the following way:
  - macro module main variables:
    Dim AFormMethodIsBeingExecuted As Boolean
  - form method calling SelectElement2:
    Private Sub FormPossessingOneMethodCallingSelectElement2_Click()
        Dim InputObjectType(0), Status
        AFormMethodIsBeingExecuted = True
        InputObjectType(0)="TriDimFeatEdge"
        Status=Selection.SelectElement2(InputObjectType,"Select an edge",false)
        AFormMethodIsBeingExecuted = False
    End Sub
  - average form method:
    Private Sub AverageForm_Click()
        If (AFormMethodIsBeingExecuted) Then Exit Sub
           . . .
     '     content of the form method itself
           . . .   
    End Sub
Parameters:
iFilterType
An array of strings constants defining the automation object types with which the selection will be filtered. During the selection, when the end user will move the mouse (above the geometry or the specification tree), if the feature under the mouse does not map iFilterType, the cursor will be the "no entry" cursor.
The resulting filter is a logical OR of the supplied strings constants. For instance if the array contains two elements "Point" and "Line", when the end user will move the mouse above the geometry, if there is a feature under a mouse, which is a
HybridShapePointCoord object (you have to know that the Point object is a parent object of the HybridShapePointCoord object ), then, the cursor will be a "hand" cursor. At the opposite, if there is a feature under a mouse, which is neither a Point nor a Line, the cursor will be a "no entry" cursor.
Beside the automation object names, the CATSelectionFilter value names are supported.

iMessage
A string which instructs the user what to select. This string is displayed in the message area located at the left of the power input area.
iObjectSelectionBeforeCommandUsePossibility
Enables the script to support the possibility, for the user, to select a required object before running the script.
If the scripter:

writes a script calling SelectElement2, giving as iFilterType parameter an array containing one string: "Pad"
for the first call to SelectElement2 made by the script, the iObjectSelectionBeforeCommandUsePossibility is set to True
the scripter associates the script to an Icon. He will proceed as following:
in the Tools menu, select the Customize item. A window appears.
select the Commands Tab. The window contains two lists.
in the list on the left, select the Macros value
select the "Show Properties" push button
select the button on the right of the Icon label. A window containing a list of icons appears
select an Icon
select the Close button. The window containing the icon list disappears
in the list on the right, push the key 1 of the mouse, the cursor beeing on the macro to associate to an Icon. Then drag to a desired Toolbar. The Icon has been added to the Toolbar.

Then the user will be able to implement the following scenario:
select a Pad
select the Icon mentioned above. This runs the script.

During the execution of the script, the script will detect that the selected Pad is required as input, and the first call to SelectElement2 will not ask to the user to interactively select a Pad: the Pad selected before the script execution will be taken.
Note:Regarding the features selected by the user (a Pad in the example above), all the automation objects specified in SelectedElement.Value for the current selection SelectedElement objects must be used: if an automation object specified in SelectedElement.Value is not asked by the input filter, the SelectElement2 method will ask the user to interactively select an appropriate element.
A False value for the iObjectSelectionBeforeCommandUsePossibility parameter may be used although the selection is not empty before entering the method. This enables that, during the selection, the selected elements remain highlighted.
Caution: After a call to SelectElement2 , the iObjectSelectionBeforeCommandUsePossibility parameter being set to False, the elements which were selected before the call to SelectElement2 are not any more in the selection (unless the user selected one of them!). Consequently, such a use of the False value for the iObjectSelectionBeforeCommandUsePossibility parameter requires the following code:

save the selection content in save variables
call the SelectElement2 method, the iObjectSelectionBeforeCommandUsePossibility parameter being set to False
copy the selected element to a dedicated variable
merge the selected element with the save variables, and put the result in the selection. This mean:
if the selected element does not belong to the save variables, add the save variables to the selection
otherwise, remove the selected element from the save variables, clear the selection and then, add the save variables to the selection
oOutputState
The state of the selection command once SelectElement2 returns. It can be either "Normal" (the selection has succeeded), "Cancel" (the user wants to cancel the VB command, which must exit immediately), "Undo" or "Redo".
Note:The "Cancel" value is returned if one of the following cases occured:
an external command has been selected
the ESCAPE key has been selected
another window has been selected, the window document beeing another document than the current document
Caution:All scripts should exit (after the necessary cleanings) when the "Cancel" value is returned.
If the script does not exit (beside the cleanings) when the "Cancel" value is returned, but calls another interactive method such as SelectElement2 , and, during execution, the user select an external command (which triggers the return of the "Cancel" value), then, the execution of the other interactive method will display an error message.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

GMT+8, 2024-12-26 04:28 , Processed in 0.034765 second(s), 14 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

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