본문 바로가기
  • Welcome!
VBA For Creo

PTC VB 코드를 VBA로 변환

by ToolBOX01 2023. 12. 31.
반응형

모델의 Feature들 ID를 로그 파일에 저장 하는 방법  

□ VBA 코드

Dim BaseSession As pfcls.IpfcBaseSession
Dim curDir As String
Dim Feature As pfcls.IpfcFeature
Dim logFile As Object

curDir =  BaseSession. GetCurrentDirectory()
Set logFile = CreateObject("Scripting.FileSystemObject").CreateTextFile(curDir & "IDT-VBA20221231.log")

Dim Selections As pfcls.IpfcSelections
Dim i As Integer

For i = 0 To features.Count - 1
    Set feature = Selections.Item(i).SelItem
    If Not feature Is Nothing Then
        If feature.IsVisible Then
            Set featSelection = CreateObject("MGCPCtl.Select").CreateModelItemSelection(features.Item(i), Nothing)
            logFile.WriteLine "Selection created for feature with ID: " & feature.Id
            logFile.Flush
        End If
    End If
Next i

logFile.Close
Set logFile = Nothing