본문 바로가기
  • Welcome!
VBA, VB.NET For Creo

Get the character height value of drawing

by ToolBOX01 2024. 9. 4.
반응형

□ IpfcModel2D

This interface represents a two-dimensional Creo Parametric model.

 

▷ IpfcModel2D.TextHeight

The text height of the model. The model must be in the current window inorderto access this property.

[text height]

1. Session connection code

Option Explicit

Public asynconn As New pfcls.CCpfcAsyncConnection
Public conn As pfcls.IpfcAsyncConnection
Public BaseSession As pfcls.IpfcBaseSession
Public model As pfcls.IpfcModel
Public Sub CreoConnt01()
     
     '// connect creo model
     Set conn = asynconn.Connect("", "", ".", 5)
     Set BaseSession = conn.Session
     Set model = BaseSession.CurrentModel
     
    '// creo model connection check
     If model Is Nothing Then
        MsgBox "There are No Active Creo Models", vbInformation, "korealionkk@gmail.com"
        Exit Sub
     End If
          
End Sub

 

2. Main program code

Option Explicit
Sub Drawing01()
    On Error GoTo RunError

    '// Module Name : CreoVBAStart
    Call CreoVBAStart.CreoConnt01
    
    Dim Model2D As IpfcModel2D
    Set Model2D = BaseSession.CurrentModel
    
    MsgBox Model2D.TextHeight
    
    conn.Disconnect (2)
        
    '// Cleanup
    Set asynconn = Nothing
    Set conn = Nothing
    Set BaseSession = Nothing
    Set model = Nothing
    
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

 

Set Model2D = BaseSession.CurrentModel

Returns the current session model as an "IpfcModel2D".