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

Drawing View List

by ToolBOX01 2021. 3. 8.
반응형

Drawing View List 표시

 

 

Drawing View List

 

Source Code

Sub view_name_list()
        Dim asynconn As New pfcls.CCpfcAsyncConnection
        Dim conn As pfcls.IpfcAsyncConnection
        Dim session As pfcls.IpfcBaseSession
    
    On Error GoTo RunError
        Set conn = asynconn.Connect("", "", ".", 5)
        Set session = conn.session
                     
        Dim drawingFilename As IpfcModel
        Set drawingFilename = session.CurrentModel
        Cells(3, "C") = drawingFilename.Filename
           
        Dim Model2D As IpfcModel2D
        Set Model2D = session.CurrentModel
        Dim View2Ds As IpfcView2Ds
        Set View2Ds = Model2D.List2DViews()
              
        For i = 0 To View2Ds.Count - 1
            Cells(i + 7, "b") = View2Ds(i).Name
            
        Next i
              
    conn.Disconnect (2)
    
    'Cleanup
    Set asynconn = Nothing
    Set conn = Nothing
    Set session = Nothing
    Set model = 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

 

Drawing View List.xlsm
0.03MB

 

 

Business inquiries : lionkk@idt21c.com