VBA, VB.NET For Creo
#9 IpfcBaseSession.Select() - Surface
ToolBOX01
2023. 8. 14. 13:03
반응형
■ IpfcBaseSession.Select() 소개
Creo Parametric에서 객체를 대화식으로 선택할 수 있습니다. 선택된 요소를 다루는 데 사용되는 것은 반환된 객체입니다. 선택된 객체에 따라 다양한 작업을 수행할 수 있습니다. 예를 들어, 선택된 요소의 속성을 확인하거나 변경하거나, 요소를 삭제하거나 수정하는 등의 작업이 가능합니다.
[Function] Select (Options as IpfcSelectionOptions, InitialSels as IpfcSelections [optional]) as IpfcSelections [optional]
▷ Options as IpfcSelectionOptions
옵션 키워드 및 허용되는 최대 선택 수를 포함한 선택 옵션. 클래스에는 다양한 속성이 있습니다. 이 속성을 사용하여 선택 작업을 조정하고 사용자 인터페이스를 제어할 수 있습니다. 예를 들어, 특정한 요소 유형만 선택하도록 설정하거나, 다중 선택이 허용되도록 설정하거나, 필요한 속성을 가져올지 여부를 설정할 수 있습니다.
'// Select Filter
Dim SelectionOptionsCreate As New CCpfcSelectionOptions
Dim SelectionOptions As IpfcSelectionOptions
Set SelectionOptions = SelectionOptionsCreate.Create("SURFACE")
'// The maximum number of selections allowed. If this is a negative number,
'// there is an unlimited number of selections.
SelectionOptions.MaxNumSels = -1
위 코드에서 SelectionOptionsCreate.Create("SURFACE") 의미는 CREO 화면에서 "요소"를 클릭 합니다. "대 / 소문자" 구분은 없습니다. 필터링 가능한 문자 입니다.
CpfcSelections 함수 기능?
Mouse로 요소를 선택 합니다. 마우스로 모델의 Surface를 선택 합니다
Dim Selections As CpfcSelections
Set Selections = session.Select(SelectionOptions, Nothing)
▷InitialSels as IpfcSelections
특정 작업을 수행하기 전에 사전에 선택한 항목 또는 요소들을 나타냅니다. 이러한 초기 선택 사항은 수행하려는 작업의 대상이 됩니다. "nothing"으로 처리 합니다
■ mouse로 모델의 서피스선택 하고, 면적을 구하는 코드 입니다
'// Select Filter
Dim SelectionOptionsCreate As New CCpfcSelectionOptions
Dim SelectionOptions As IpfcSelectionOptions
Set SelectionOptions = SelectionOptionsCreate.Create("SURFACE")
'// The maximum number of selections allowed. If this is a negative number,
'// there is an unlimited number of selections.
SelectionOptions.MaxNumSels = -1
'// 마우스로 endity를 선택
Dim Selections As CpfcSelections
Dim Selection As IpfcSelection
Dim Surface As IpfcSurface
Set Selections = session.Select(SelectionOptions, Nothing)
Dim i As Long
For i = 0 To Selections.Count - 1
Set Selection = Selections.Item(i)
Set Surface = Selection.SelItem
MsgBox Surface.EvalArea
Next i
프로그램 실행 결과