IpfcBaseSession.ExecuteModelCheck() #2
▣ config.pro 설정 (config.pro settings)
modelcheck_enabled 옵션을 yes로 설정하는 것은 Creo ModelCHECK 기능을 활성화하기 위한 필수 전제 조건입니다.
이 설정이 없으면 ModelCHECK가 기본적으로 비활성화되어 있어, 수동으로 실행하거나 자동화된 프로세스(예: 저장 또는 재생성 시)에서 ModelCHECK를 사용할 수 없습니다.
Setting the modelcheck_enabled option to yes is a prerequisite for enabling the Creo ModelCHECK feature. Without this setting, ModelCHECK is disabled by default, and cannot be run manually or used in automated processes (such as when saving or regenerating).
▣ IpfcBaseSession > Sub SetConfigOption
Sub SetConfigOption(Name as String, Value as String)
Dim BaseSession as IpfcBaseSession
call BaseSession.SetConfigOption("modelcheck_enabled", "yes")
vba 프로그램은 환경 설정을 할 수 있습니다. 이 함수는 주로 프로그램의 동작을 제어하는 설정값을 변경할 때 사용됩니다. 예를 들어, 특정 파일 경로를 설정하거나, 프로그램의 동작 모드를 변경하는 등의 용도로 활용될 수 있습니다.
매개변수:
- Name (문자열): 설정 파일 옵션의 이름입니다. 대소문자를 구분하지 않습니다.
- Value (문자열): 설정 파일에 나타나야 하는 옵션의 값입니다. 만약 해당 옵션이 경로(path)와 같이 여러 값을 가질 수 있는 경우, 이 함수는 기존 값 배열에 새 값을 추가합니다.
VBA programs can set preferences. This function is mainly used to change settings that control the operation of the program. For example, it can be used to set a specific file path or change the operation mode of the program.
Parameters:
- Name (string): The name of the configuration file option. Case-insensitive.
- Value (string): The value of the option as it should appear in the configuration file. If the option can have multiple values, such as a path, this function adds the new value to the existing array of values.
▣ IpfcBaseSession > Function ExecuteModelCheck
ExecuteModelCheck 함수는 외부 응용프로그램에서 Creo Parametric의 ModelCheck 기능을 실행하는 데 사용됩니다. 이 함수는 모델의 품질을 검사하고, 설정된 기준에 따라 결과를 반환합니다.
Function ExecuteModelCheck (Model as IpfcModel, Instructions as IpfcModelCheckInstructions [optional]) as IpfcModelCheckResults
매개변수
1. Model (IpfcModel)
검사하고자 하는 모델 객체입니다. Creo Parametric에서 작업 중인 3D 모델이나 2D 도면 등이 해당될 수 있습니다.
2. Instructions (IpfcModelCheckInstructions, 선택 사항)
ModelCheck 실행 시 사용할 설정(지침)입니다. 예를 들어, 특정 점검 항목이나 기준을 지정할 수 있습니다.
이 매개변수는 선택 사항이며, 지정하지 않으면 기본 설정이 사용됩니다.
반환값
IpfcModelCheckResults: ModelCheck 실행 결과를 요약한 객체입니다.
결과에는 모델의 오류, 경고, 또는 성공적인 점검 항목 등이 포함됩니다.
▷ Example Code 1
모델 체크 프로그램 백그라운드로 실행 합니다. 모델 체크 설정은 VBA 프로그램에서 설정 하지 않았습니다.
Creo 모델 체크 프로그램의 환경 설정을 따릅니다.
Run the model check program in the background. The model check settings are not set in the VBA program. Follow the environment settings of the Creo model check program.
세션에 있는 모든 Part를 백 그라운드로 모델 체크 가능 합니다
All parts in the session can be model checked in the background.
Option Explicit
Sub Modelcheck01()
On Error GoTo RunError
Application.EnableEvents = False
'// Creo Connection
Call CreoVBAStart02.CreoConnt02
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Modelcheck")
Dim model As pfcls.IpfcModel
Dim ModelCheckResults As pfcls.IpfcModelCheckResults
'// Get current model
Set model = BaseSession.CurrentModel
If model Is Nothing Then
MsgBox "No models are currently open.", vbCritical, "Error"
GoTo CleanUp
End If
Set ModelCheckResults = BaseSession.ExecuteModelCheck(model, Nothing)
MsgBox ModelCheckResults.NumberOfErrors, vbInformation, "number of errors"
MsgBox ModelCheckResults.NumberOfWarnings, vbInformation, "number of warnings"
MsgBox ModelCheckResults.WasModelSaved, vbInformation, "model was saved or not"
CleanUp:
'// Clean up Creo connection
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect 2
End If
End If
Set asynconn = Nothing
Set conn = Nothing
Set BaseSession = Nothing
Set model = Nothing
Application.EnableEvents = True
Exit Sub
RunError:
MsgBox "Process Failed: An error occurred." & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Description: " & Err.Description & vbCrLf & _
"Error Source: " & Err.Source, vbCritical, "Error"
GoTo CleanUp
End Sub
Creo Modelcheck 구성 정보 (Creo Modelcheck Configuration Information)
PTC 도움말 센터
사용자의 브라우저에서 DOM 저장소가 비활성화되었습니다. DOM 저장소가 활성화되었는지 확인한 다음 다시 시도하십시오.
support.ptc.com
자동으로 Part, Assembly, Drawing 파일들을 체크할 수 있습니다. 자동으로 모델 체크 프로그램을 사용하기 위해서는, Modelcheck 환경을 구성하는 컨설팅을 수행 해야 합니다. API를 이용하여 모델의 유형에 따라 모델체크 환경 설정 파일 을 자동 선택하여 읽어 올수 있습니다. 모델 체크 결과 Report 파일은 html 파일로 가져옵니다. 프로그램 개발을 통해 자신만의 리포트 양식 포맷으로 만들수 있습니다.
You can automatically check Part, Assembly, and Drawing files. In order to use the model check program automatically, you must perform consulting to configure the Modelcheck environment. You can automatically select and read the model check environment setting file according to the model type using the API. The model check result report file is imported as an html file. You can create your own report form format through program development.
▷ Example Code 2
Option Explicit
Sub Modelcheck01()
On Error GoTo RunError
Application.EnableEvents = False
'// Creo Connection
Call CreoVBAStart02.CreoConnt02
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Modelcheck")
Dim model As pfcls.IpfcModel
Dim createModelCheckInstructions As New pfcls.CCpfcModelCheckInstructions
Dim ModelCheckInstructions As pfcls.IpfcModelCheckInstructions
Dim ModelCheckResults As pfcls.IpfcModelCheckResults
'// Get current model
Set model = BaseSession.CurrentModel
If model Is Nothing Then
MsgBox "No models are currently open.", vbCritical, "Error"
GoTo CleanUp
End If
'// ModelCHECK settings
Set ModelCheckInstructions = createModelCheckInstructions.Create
ModelCheckInstructions.ConfigDir = "G:\MOD\modchk" '// Settings file directory
ModelCheckInstructions.Mode = EpfcModelCheckMode.EpfcMODELCHECK_GRAPHICS '// Interactive mode
ModelCheckInstructions.OutputDir = "G:\MOD\reports" '// Results Report Directory
ModelCheckInstructions.ShowInBrowser = True '// Show results in browser
Set ModelCheckResults = BaseSession.ExecuteModelCheck(model, ModelCheckInstructions)
MsgBox ModelCheckResults.NumberOfErrors, vbInformation, "number of errors"
MsgBox ModelCheckResults.NumberOfWarnings, vbInformation, "number of warnings"
MsgBox ModelCheckResults.WasModelSaved, vbInformation, "model was saved or not"
CleanUp:
'// Clean up Creo connection
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect 2
End If
End If
Set asynconn = Nothing
Set conn = Nothing
Set BaseSession = Nothing
Set model = Nothing
Application.EnableEvents = True
Exit Sub
RunError:
MsgBox "Process Failed: An error occurred." & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Description: " & Err.Description & vbCrLf & _
"Error Source: " & Err.Source, vbCritical, "Error"
GoTo CleanUp
End Sub
by koealionkk@gmail.com
