반응형
□ Code to get the model's Parameter
Gets the number of parameters the model has.
Gets the parameters name that the model has.
Gets the value of the parameters name that the model has.
Gets the types of parameters that the model has.
□ Main Code
Option Explicit
Sub GetParameter01()
On Error GoTo RunError
'// Module Name : CreoVBAStart
Call CreoVBAStart.CreoConnt01
Dim ParameterOwner As IpfcParameterOwner
Dim BaseParameter As IpfcBaseParameter
Dim Parameters As IpfcParameters
Dim ParameterObject As Object
Dim Parameter As IpfcParameter
Dim ParamValue As IpfcParamValue
Dim i As Integer
Set ParameterOwner = model
Set Parameters = ParameterOwner.ListParams
For i = 0 To Parameters.Count - 1
Set ParameterObject = Parameters.Item(i)
Set ParamValue = ParameterObject.Value
Worksheets("GetParameter01").Cells(i + 6, "A") = i + 1
Worksheets("GetParameter01").Cells(i + 6, "B") = ParameterObject.Name
If ParamValue.discr = 0 Then
Worksheets("GetParameter01").Cells(i + 6, "C") = ParamValue.StringValue
Worksheets("GetParameter01").Cells(i + 6, "D") = "String"
ElseIf ParamValue.discr = 1 Then '// if parameter is real value
Worksheets("GetParameter01").Cells(i + 6, "C") = ParamValue.IntValue
Worksheets("GetParameter01").Cells(i + 6, "D") = "integer"
ElseIf ParamValue.discr = 2 Then '// if parameter is real value
Worksheets("GetParameter01").Cells(i + 6, "C") = ParamValue.BoolValue
Worksheets("GetParameter01").Cells(i + 6, "D") = "Boolean"
ElseIf ParamValue.discr = 3 Then '// if parameter is real value
Worksheets("GetParameter01").Cells(i + 6, "C") = ParamValue.DoubleValue
Worksheets("GetParameter01").Cells(i + 6, "D") = "Double"
End If
Next i
MsgBox "Get Model Parameter Name", vbInformation, "korealionkk@gmail.com"
conn.Disconnect (2)
'// Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set BaseSession = Nothing
Set model = Nothing
RunError:
If Err.Number <> 0 Then
Dim ErrorMessage As String
ErrorMessage = ErrorHandlerModule.MapErrorToMessage(Err.Number) '// 모듈에서 함수 호출
MsgBox "Process Failed: " & vbCrLf & _
"Error No: " & CStr(Err.Number) & vbCrLf & _
"Description: " & ErrorMessage, vbCritical, "Error"
If Not conn Is Nothing Then
If conn.IsRunning Then
conn.Disconnect (2)
End If
End If
End If
End Sub
Dim ParameterObject As Object
Set ParameterObject = Parameters.Item(i)
Worksheets("GetParameter01").Cells(i + 6, "B") = ParameterObject.Name
Creo VBA API does not provide a function to retrieve the parameter names of a model.
However, Parameter.item() returns the value as an object.
'VBA, VB.NET For Creo' 카테고리의 다른 글
CREO VBA API 란? (2) | 2024.10.01 |
---|---|
Select a parameter to delete it from the model (0) | 2024.09.15 |
How to set up and configure modules to use the VBA API (0) | 2024.09.11 |
Get the currently active model name (1) | 2024.09.09 |
VBA : 변수 (Variable) (0) | 2024.09.09 |