본문 바로가기
  • Welcome!
VBA 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".

'VBA For Creo' 카테고리의 다른 글

Get the IDs of dimensions included in a drawing view  (0) 2024.09.04
Get Creo drawing view name and location values  (4) 2024.09.04
Get Creo File Names In Your Workfolder  (0) 2024.09.03
connection to Creo  (2) 2024.09.03
Setting Up Creo VBA API  (0) 2024.09.03