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

Feature의 상태를 표시

by ToolBOX01 2024. 3. 24.
반응형

□ 모델의 Feature 상태를 표시 합니다

IpfcFeature.status : 숫자로 표시 합니다.

enumerated type  설명 실행 결과
EpfcFEAT_ACTIVE 일반적인 기능 0
EpfcFEAT_INACTIVE 억제되지는 않지만 현재 다른 이유로 사용되지 않는 기능입니다. 1
EpfcFEAT_FAMILY_TABLE_SUPPRESSED 패밀리 테이블 기능에 의해 억제된 기능입니다. 2
EpfcFEAT_SIMP_REP_SUPPRESSED 단순화 표현 기능에 의해 억제된 피쳐입니다. 3
EpfcFEAT_PROGRAM_SUPPRESSED Pro/PROGRAM 기능에 의해 억제된 기능입니다. 4
EpfcFEAT_SUPPRESSED feature suppressed 5
EpfcFEAT_UNREGENERATED 활성 상태이지만 수정되지 않은 재생성 실패로 인해 재생성되지 않는 기능입니다. 이 재생성 실패는 이전 피쳐로 인해 발생할 수 있습니다. 6
EpfcFeatureStatus_nil   null

 

□ Part가 종속 하는 참조 모델의 이름을 표시 합니다

프로그램 실행 결과

□ 코드

Option Explicit
Sub Feature_ref()
    On Error GoTo RunError
    
    Application.EnableEvents = False
    
    '// Check if "Program11" worksheet exists
    If Not WorksheetExists("Program01") Then
        MsgBox "Worksheet 'Program01' not found.", vbExclamation, "Error"
        Exit Sub
    End If
    
    Dim asynconn As New pfcls.CCpfcAsyncConnection
    Dim conn As pfcls.IpfcAsyncConnection
    
    '// Check Creo Connect
    Set conn = asynconn.Connect("", "", ".", 5)
    
    If conn Is Nothing Then
        MsgBox "An error occurred while starting a new Creo Parametric Session", vbInformation, "www.idt21c.com"
        Exit Sub
    End If

    Dim BaseSession As pfcls.IpfcBaseSession
    Dim model As pfcls.IpfcModel

    Set BaseSession = conn.Session
    Set model = BaseSession.CurrentModel
               
               
    '// Current Model Information
    Worksheets("Program01").Cells(2, "D") = BaseSession.GetCurrentDirectory
    Worksheets("Program01").Cells(3, "D") = model.filename
    
    '// Check feature dependency status
    
    Dim Dependencies As IpfcDependencies
    Dim Dependency  As IpfcDependency
    Dim ModelDescriptor As IpfcModelDescriptor
    
    Set Dependencies = model.ListDependencies
    
    Dim i As Long
    
    If Dependencies.Count > 0 Then
    
            For i = 0 To Dependencies.Count - 1
            
                   Set Dependency = Dependencies.item(i)
                   Set ModelDescriptor = Dependency.DepModel
                   
                   Cells(i + 6, "B") = i + 1
                   Cells(i + 6, "C") = ModelDescriptor.GetFileName
            
            Next i
            
            MsgBox "검색을 완료 했습니다."
    
     Else
     
             MsgBox "종속이 없는 모델 입니다."
    
    End If

    conn.Disconnect (2)
    
    ' Cleanup
    Set asynconn = Nothing
    Set conn = Nothing
    Set BaseSession = Nothing
    Set model = Nothing
    
Exit Sub

RunError:
    If Err.Number <> 0 Then
        MsgBox "Process Failed: An error occurred." & vbCrLf & _
               "Error No: " & CStr(Err.Number) & vbCrLf & _
               "Error Description: " & Err.Description & vbCrLf & _
               "Error Source: " & Err.Source, vbCritical, "Error"
        If Not conn Is Nothing Then
            If conn.IsRunning Then
                conn.Disconnect (2)
            End If
        End If
    End If
End Sub

Function WorksheetExists(shtName As String) As Boolean
    On Error Resume Next
    WorksheetExists = Not Worksheets(shtName) Is Nothing
    On Error GoTo 0
End Function

 


영업문의 : lionkk@idt21c.com
카카오 채널 : http://pf.kakao.com/_fItAxb