본문 바로가기
  • 환영 합니다 ! Welcome!
VBA For Creo

regenerate Failed Feature / Component Check

by ToolBOX01 2022. 12. 19.
반응형

[ regenerate Fail ]

. regenerate 실패한 Feature의 번호를 검색 합니다.
. regenerate 실패한 Component의 번호를 검색 합니다.

■ VBA 코드

Option Explicit
Sub Failchek()

Application.EnableEvents = False
On Error GoTo RunError

        Dim asynconn As New pfcls.CCpfcAsyncConnection
        Dim conn As pfcls.IpfcAsyncConnection: Set conn = asynconn.Connect("", "", ".", 5)
        Dim oSession As pfcls.IpfcBaseSession: Set oSession = conn.session
        Dim oModel As IpfcModel: Set oModel = oSession.CurrentModel
        Dim oSolid As IpfcSolid: Set oSolid = oModel
        
        Cells(1, "B") = oModel.Filename     
                
        Dim i As Long
        Dim oFailedFeatures As IpfcFeatures
        Set oFailedFeatures = oSolid.ListFailedFeatures
        Dim oFailedFeature As IpfcFeature
        
        For i = 0 To oFailedFeatures.Count - 1
        
            Cells(i + 4, "A") = i + 1
            Set oFailedFeature = oFailedFeatures.Item(i)
            Cells(i + 4, "B") = oFailedFeature.Number
            Cells(i + 4, "C") = "regenerate Failed"
        
        Next i
 
    conn.Disconnect (2)
    
    'Cleanup
    Set asynconn = Nothing
    Set conn = Nothing
    Set oSession = Nothing
    Set oModel = Nothing
    
RunError:
    If Err.Number <> 0 Then
        MsgBox "Process Failed : Unknown error occurred." + Chr(13) + _
                "Error No: " + CStr(Err.Number) + Chr(13) + _
                "Error: " + Err.Description, vbCritical, "Error"
        If Not conn Is Nothing Then
            If conn.IsRunning Then
                conn.Disconnect (2)
            End If
        End If
    End If


End Sub

 

■ 실행 결과

어셈블 파일에서 번호가 "247"인  Component를 재생성 할수 없습니다.  IpfcSolid.ListFailedFeatures 으로 실패한 Feature / Component를 검색 할수 있습니다. Component는 바로 상위의 어셈블 안에서만 검색 할수 있습니다. 레벨 1 > 레벨 2 > 레벨 3이 있다면, 레벨 1인에서만 검색 할수 있습니다.

[ regenerate 실패 ]

예제 그림은 "~_lower.asm" 파일에 1개의 Component가 "regenerate 실패"가 있다는것을 표시 합니다.