iObjectSelectionBeforeCommandUsePossibility) As CATBSTR
[url=]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.[/url]
[url=]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.[/url]
[url=]If iObjectSelectionBeforeCommandUsePossibility is equal to True:
SelectElement2 determines whether the automation objects specified in[/url]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 SubParameters: 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.作者: oliverpp 时间: 2008-11-13 11:42 标题: 顶一下 16x 16x 16x作者: fineday513 时间: 2008-11-18 20:59 标题: 顶!!看贴!! 顶!!看贴!!作者: fineday513 时间: 2008-11-18 21:04 标题: 顶!!看贴!! 顶!!看贴!!顶!!看贴!!顶!!看贴!!顶!!看贴!!顶!!看贴!!顶!!看贴!!顶!!看贴!!顶!!看贴!!顶!!看贴!!作者: engwu 时间: 2008-11-19 12:16
速度好慢啊作者: 7cmm 时间: 2008-11-30 10:09
顶~~~~~~~~~~~~~~~~~~~~~~~作者: osfang 时间: 2008-12-9 20:01
fghfghfghgfh作者: osfang 时间: 2008-12-9 20:02
好东西,看看作者: wydcn_1226 时间: 2008-12-10 17:05
十分谢谢!作者: hzhou 时间: 2008-12-12 09:17
本帖隐藏的内容需要积分高于 1 才可浏览作者: tom_jerry 时间: 2008-12-16 14:10
很好的东西啊,很有用,谢谢楼主了作者: damo2008 时间: 2009-1-6 16:29
本帖附件需要回复才可下载或查看作者: meiping218301 时间: 2009-1-7 09:36 作者: tebise70 时间: 2009-1-7 16:28
,谢谢分享...作者: tebise70 时间: 2009-1-7 16:32
谢谢你的教程作者: tebise70 时间: 2009-1-7 16:34
集思广益,受益了作者: aloneinthedark 时间: 2009-1-9 23:59
新手报道。淘宝来了作者: aloneinthedark 时间: 2009-1-9 23:59
12x 新手报道。淘宝来了作者: zza1008 时间: 2009-2-4 17:32
顶了再看!嘿嘿作者: gjf60331 时间: 2009-2-10 00:55 标题: 谢了 非常感谢!作者: sa3wolf 时间: 2009-2-10 16:31
good stuff~作者: toseywl 时间: 2009-2-13 09:38
nihao ,xuexi yixia作者: jinrongking 时间: 2009-2-14 11:26
学习一下。。。作者: wolfshura 时间: 2009-2-15 18:52
很需要的东西呢作者: yu780626 时间: 2009-2-18 15:38
应该是好东西吧作者: catia666 时间: 2009-4-12 12:40
看看啊啊谢谢作者: wolfshura 时间: 2009-4-16 23:00
顶起来啊~~~~作者: llsp521 时间: 2009-4-21 23:22
看看是什么作者: chaferzealot 时间: 2009-5-12 16:15 1#