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

2020-02-22 13:08

Set Edge(EdgeIndex) = Selection.Item2(1).Value : EdgeCount = EdgeCount+1 next else

Selection.Clear end if

'We loop onto interactive selections AllEdgesHaveBeenSelected = false

do while (Not AllEdgesHaveBeenSelected)

' We increase the allocation of EdgeSet if necessary if (EdgeCount = AllocatedEdgeCount) then

AllocatedEdgeCount = AllocatedEdgeCount + 10 : ReDim Edge(AllocatedEdgeCount-1) end if

' We propose to the user that he select an edge

Status=Selection.SelectElement2(InputObjectType,\ if (Status=\ Selection.Clear : Exit Sub end if

' We save the selected edge

Set SelectedEdge = Selection.Item2(1).Value

' We determine if the edge already belongs to the Edge array EdgeIndex2 = 0 Found = False

do while ((EdgeIndex2 < EdgeCount) And (Not Found)) if (Edge(EdgeIndex2).Name=SelectedEdge.Name) then Found = True

AlreadySelectedEdgeIndex = EdgeIndex2 end if

EdgeIndex2 = EdgeIndex2 + 1 loop

' We add the selected edge to Edge or remove the selected edge from Edge if (Found) then

' The edge already belongs to Edge. We suppress it from Edge for EdgeIndex2 = AlreadySelectedEdgeIndex to EdgeCount-2 Set Edge(EdgeIndex2) = Edge(EdgeIndex2+1) next

EdgeCount = EdgeCount - 1 else

' The edge does not already belong to Edge. We add the it to edge

Set Edge(EdgeCount) = Selection.Item2(1).Value : EdgeCount = EdgeCount + 1 end if

' We fill Selection with all the selected edges Selection.Clear

for EdgeIndex = 0 to EdgeCount -1 Selection.Add Edge(EdgeIndex)

next

' We ask the end user if the edge selection is finished

OtherEdgeAnswer = msgbox (\Definition\

if (OtherEdgeAnswer = 2) then Exit Sub

if (OtherEdgeAnswer = 7) then AllEdgesHaveBeenSelected = true loop

'We create a new fillet based onto the current selection content

Set Fillet = ShapeFactory.AddNewEdgeFilletWithConstantRadius(Edge(0), 1, 5.0) Fillet.EdgePropagation = 1

for EdgeIndex = 1 to EdgeCount -1

Fillet.AddObjectToFillet Edge(EdgeIndex) next

Part.Update

o Func FindObject( CA TBSTR iObjectType) As CATIABase

Finds an object in the current selection and deletes it from the selection.

Role: Determines the first automation object specified in SelectedElement.Value (for the

SelectedElement objects contained in the current selection), or which is a Parent (see AnyObject.Parent ) of the automation object specified in SelectedElement.Value , which type is equal to

the type specified in input. It returns directly the automation object and deletes the corresponding

SelectedElement object from the current selection.

Note: If the string specified in input is he \string, the possible automation object specified in SelectedElement.LeafProduct is also looked at. Example:

This example searches a Pad object in the current selection and puts it into FoundObject.

Dim FoundObject As AnyObject

Set FoundObject = CATIA.ActiveDocument.Selection.FindObject(\

o (

Func

iMessage,

IndicateOrSelectElement2DCATBSTR

CATSafeArrayVarianiFilterType,

t

boolean boolean boolean boolean

iObjectSelectionBeforeCommandUsePossibility,

iTooltip,

iTriggeringOnMouseMove, oObjectSelected,

oDocumentWindowLocation) As CATBSTR

CATSafeArrayVariant

Runs an interactive command enabling both indication and selection, 2D version.

Role: IndicateOrSelectElement2D runs an interactive command into a 2D document window, asking to the user to select a location into the window, or to select an object. See

Document.Indicate2D and SelectElement3.

Parameters: iMessage

A string which instructs the user that he must select a location into the document window or select an object. iFilterType

An array of strings constants to be used as a filter for the kind of element to select. iObjectSelectionBeforeCommandUsePossibility

Enables the script to support the possibility, for the user, to select a required object before running the script. See

SelectElement2 .

iTooltip

Displays a tooltip as soon as an object is located under the mouse without being selected. iTriggeringOnMouseMove

Triggers as soon as a mouse move event is detected. This option beeing set, oOutputState may be valued to \ oObjectSelected

Flag pr閏ising if the user choosed the selection or the indication. oDocumentWindowLocation

An array made of 2 doubles: X, Y - coordinates array of the location the user specified in the document window. This parameter is valuated only if oObjectSelected equals to false. oOutputState

The state of the interactive command once IndicateOrSelectElement2D returns. The possible values are the same than the values described regarding the oOutputState parameter of the SelectElement2 method, except that the \value can also be returned. Example:

The following example suppose a drawing is currently edited. It creates a point (see Point2D ), and asks the end user to click to define the circle center.

When it is done, as the mouse moves without clicking the left button, the script determines the location into the drawing window, and the script creates a temporary circle as a feedback.

A click into the document window or the selection of a point creates definitively the circle (see

Circle2D ) located at the specified location (whether the location is a location into the drawing window

or whether it is the existing point location).

Dim

Document,Selection,DrawingSheets,DrawingSheet,DrawingViews,WindowLocation(1),DrawingView,Factory2D,Radius,Circle2D Dim

HardCodedPoint,Status,XCenter,YCenter,InputObjectType(0),TempCircleHasBeenCreatedAtLeastOnce,ExistingPoint Dim ObjectSelected

Set Document = CATIA.ActiveDocument : Set Selection = Document.Selection : Set DrawingSheets = Document.Sheets

Set DrawingSheet = DrawingSheets.ActiveSheet : Set DrawingViews = DrawingSheet.Views Set DrawingView = DrawingViews.ActiveView : Set Factory2D = DrawingView.Factory2D

'We create a point

Set HardCodedPoint = Factory2D.CreatePoint(700.,400.)

HardCodedPoint.ReportName = 1 : HardCodedPoint.Construction = False 'We propose to the user to click to define the circle center

Status=Document.Indicate2D(\ if (Status = \ XCenter = WindowLocation(0) : YCenter = WindowLocation(1)

'We propose to the user that he specify a location into the drawing window or a point InputObjectType(0)=\

Status = \

Status=Selection.IndicateOrSelectElement2D(\circle radius point\

InputObjectType,false,false,true, _ ObjectSelected,WindowLocation) ' We loop onto mouse moves without click do while (Status = \

if (TempCircleHasBeenCreatedAtLeastOnce) then Selection.Add Circle2D : Selection.Delete end if

Radius = Sqr(((WindowLocation(0)-XCenter)*(WindowLocation(0)-XCenter))+ _ ((WindowLocation(1)-YCenter)*(WindowLocation(1)-YCenter))) Set Circle2D = Factory2D.CreateClosedCircle(XCenter,YCenter,Radius) TempCircleHasBeenCreatedAtLeastOnce = 1

Status=Selection.IndicateOrSelectElement2D(\a point or click to locate the circle radius point\

InputObjectType,false,false,true, _ ObjectSelected,WindowLocation) loop

'We go out if necessary

if (Status = \ if (TempCircleHasBeenCreatedAtLeastOnce) then

Selection.Add Circle2D : Selection.Add HardCodedPoint : Selection.Delete end if Exit Sub end if

'We determine the possible selected point coordinates if (ObjectSelected) then

Set ExistingPoint = Selection.Item2(1).Value : ExistingPoint.GetCoordinates WindowLocation : Selection.Clear end if

'We clean-up the temporary circle

if (TempCircleHasBeenCreatedAtLeastOnce) then Selection.Add Circle2D : Selection.Delete end if

'We create the circle

Radius = Sqr(((WindowLocation(0)-XCenter)*(WindowLocation(0)-XCenter))+ _ ((WindowLocation(1)-YCenter)*(WindowLocation(1)-YCenter)))

Set Circle2D = Factory2D.CreateClosedCircle(XCenter,YCenter,Radius) : Selection.Add Circle2D

o Func

iPlanarGeometricObject, iMessage, iFilterType,

iObjectSelectionBeforeCommandUsePossibility,

iTooltip,

iTriggeringOnMouseMove, oObjectSelected,

IndicateOrSelectElement3DCATIABase (

CATBSTR CATSafeArrayVariant

boolean boolean boolean boolean

CATSafeArrayVarianoWindowLocation2D,

t

CATSafeArrayVariant

oWindowLocation3D) As CATBSTR

Runs an interactive command enabling both indication and selection, 3D version.

Role: IndicateOrSelectElement3D runs an interactive command into a 3D document window, asking to the user to select a location into the window, or to select an object. See

Document.Indicate3D and SelectElement3.

Parameters:

iPlanarGeometricObject A planar geometric object.

iMessage

A string which instructs the user that he must select a location into the document window or select an object. iFilterType

An array of strings constants to be used as a filter for the kind of element to select. iObjectSelectionBeforeCommandUsePossibility

Enables the script to support the possibility, for the user, to select a required object before running the script. See

SelectElement2 .

iTooltip

Displays a tooltip as soon as an object is located under the mouse without being selected. iTriggeringOnMouseMove

Triggers as soon as a mouse move event is detected. This option beeing set, oOutputState may be valued to \ oObjectSelected


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

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

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

马上注册会员

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