Catia坐标点输出程序相关函数及参数(6)

2020-02-22 13:08

depth of the investigation field.

Note: After the execution of the Search method, there may be, among the selected features, some which are not exposed to automation. Example:

The following example searches the objects matching the following criterium in all the document: Part.Sketcher.Color='White' . A selected DMU Navigator URL put into the selection although it is not exposed to automation.

CATIA.ActiveDocument.Selection.Search(\

o

Func

SelectElement2(

, CATSafeArrayVariant iFilterType

CATBSTR

boolean

iMessage,

iObjectSelectionBeforeCommandUsePossibility)

As

CATBSTR

Runs an interactive selection command.

Role: SelectElement2 filters the selection with respect to provided automation types.

? 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:

o If it is the case, no interaction is asked to the end user, the Selection object is cleared,

and filled with the appropriate element.

o 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 \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 \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 during the execution of an interactive selection method such as this one, no form (dialog box) must be displayed, otherwise it would lead to unpredictible results. In a form method, before calling an interactive selection method such as Selection.SelectElement2, you must hide all forms, and, after the call to the method, you must show the forms. Parameters: iFilterType

An array of strings constants to be used as a filter for the kind of element to select. The resulting filter is a logical OR of the supplied strings constants. For instance if the array contains two elements \ and \, the function will return any element which is either a point or a line. 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: \

? 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:

o in the Tools menu, select the Customize item. A window appears. o select the Commands Tab. The window contains two lists. o in the list on the left, select the Macros value o select the \

o select the button on the right of the Icon label. A window containing a list of icons

appears o select an Icon

o select the Close button. The window containing the icon list disappears

o 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.

oOutputState

The state of the selection command once SelectElement2 returns. It can be either \(the selection has succeeded), \(the user wants to cancel the VB command, which must exit immediately), \

Note:The \

? 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 \ If the script does not exit (beside the cleanings) when the \interactive method such as SelectElement2 , and, during execution, the user select an external command (which triggers the return of the \method will display an error message. Example:

The following example asks the end user to select a sketch (see Sketch ) in the current window, and creates a Pad (see ShapeFactory.AddNewPad ). Then, it asks the end user to select an edge of the pad, and creates an edge fillet. Then, is asks the end user to select a 1-D entity whose geometry is rectilinear (see CATSelectionFilter ), such as an edge of the Pad. Then, is asks the end user to select a pad face, and creates a hole at the face selected point, the hole direction being the direction of the 1-D selected entity.

Dim

Document,Part,Selection,ShapeFactory,SketchHasBeenAcquiredAtLeastOnce,EdgeHasBeenAcquiredAtLeastOnce Dim

FaceHasBeenAcquiredAtLeastOnce,MonoDimEntityHasBeenAcquiredAtLeastOnce,FirstExtrudeNotFinished,FilletEdge Dim

PadNotFinished,Status,SketchForPad,Pad,FilletNotFinished,Fillet,MonoDimEntityDeterminationNotFinished Dim

SelectedElement,MonoDimEntity,HoleNotFinished,PadFace,Hole,InputObjectType(0),HoleLocation(2)

Set Document = CATIA.ActiveDocument : Set Part = Document.Part : Set Selection = Document.Selection

Set ShapeFactory = Part.ShapeFactory

SketchHasBeenAcquiredAtLeastOnce = False : EdgeHasBeenAcquiredAtLeastOnce = False FaceHasBeenAcquiredAtLeastOnce = False : MonoDimEntityHasBeenAcquiredAtLeastOnce = False

FirstExtrudeNotFinished = True : PadNotFinished = True : ReDim SelectionAtBeginning(1) 'We save the current selection content

ReDim SelectionAtBeginning(Selection.Count2) for SelectionObjectIndex = 0 to Selection.Count2-1

Set SelectionAtBeginning(SelectionObjectIndex) = Selection.Item2(1).Value next

SelectionAtBeginningLength = Selection.Count2 'Feature creation

do while PadNotFinished

' We propose to the user that he select a sketch InputObjectType(0)=\

Status=Selection.SelectElement2(InputObjectType,\ if ((Status = \' We restore the selection to its initial content Selection.Clear

for SelectionObjectIndex = 0 to SelectionAtBeginningLength-1 Selection.Add SelectionAtBeginning(SelectionObjectIndex) next Exit Sub

elseif (Status = \ ' We do nothing: Redo has no meaning in this context else

if (Status <> \ SketchHasBeenAcquiredAtLeastOnce = True ' We create the Pad

Set Pad = ShapeFactory.AddNewPad(SketchForPad,20.0) Pad.SecondLimit.Dimension.Value = 0.0 : Part.Update PadNotFinished = False Selection.Clear

' We create the fillet and the hole FilletNotFinished = True

do while (FilletNotFinished And Not PadNotFinished) ' We propose to the user that he select an edge InputObjectType(0)=\

Status=Selection.SelectElement2(InputObjectType,\Pad\

if (Status = \

' We remove the pad, restore the selection to its initial content and go out

Selection.Clear : Selection.Add(Pad) : Selection.Delete Part.Update Selection.Clear

for SelectionObjectIndex = 0 to SelectionAtBeginningLength-1 Selection.Add SelectionAtBeginning(SelectionObjectIndex) next Exit Sub

elseif (Status = \ ' We do nothing: Redo has no meaning in this context

elseif (Status = \' We remove the pad

Selection.Clear : Selection.Add(Pad) : Selection.Delete Part.Update

PadNotFinished = True else

if (Status <> \ EdgeHasBeenAcquiredAtLeastOnce = True ' Create the Fillet Set Fillet =

ShapeFactory.AddNewSolidEdgeFilletWithConstantRadius(FilletEdge, catTangencyFilletEdgePropagation,5.0) Part.Update

FilletNotFinished = False Selection.Clear

' Determine the 1-D entity

MonoDimEntityDeterminationNotFinished = True

do while (MonoDimEntityDeterminationNotFinished And Not FilletNotFinished)

' We propose to the user that he select 1-D entity whose geometry is rectilinear

InputObjectType(0)=\

Status=Selection.SelectElement2(InputObjectType, _

\rectilinear\

if (Status = \

' We remove the fillet, the pad, restore the selection to its initial content and go out

Selection.Clear : Selection.Add(Fillet) : Selection.Delete Selection.Clear : Selection.Add(Pad) : Selection.Delete Part.Update Selection.Clear

for SelectionObjectIndex = 0 to SelectionAtBeginningLength-1 Selection.Add SelectionAtBeginning(SelectionObjectIndex) next Exit Sub

elseif (Status = \MonoDimEntityHasBeenAcquiredAtLeastOnce ) then

' We do nothing: Redo has no meaning in this context elseif (Status = \' We remove the fillet

Selection.Clear : Selection.Add(Fillet) : Selection.Delete Part.Update

FilletNotFinished = True


Catia坐标点输出程序相关函数及参数(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:吊索具使用维护作业指导书 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: