Model Parameter change ,Drawing Parameter connection is broken
□ Functional Testing
1. Change the parameter value using a VBA program and save it.
2. Check the status of 3D Parameters placed in the drawing.
▷reference : IpfcBaseParameter
Describes the base parameter, which can be a Creo Parametric parameter or dimension.
Directly inherited classes:
1. IpfcParameter: Represents a Creo parameter.
2. IpfcBaseDimension: Represents a Creo dimension.
1. Property Summary
1) IsDesignated (Boolean)
Description: Indicates whether the parameter is designated for use with Windchill.
Values:
- True: The parameter is designated.
- False: It is not designated.
Exceptions:
- IpfcXToolkitFound: The parameter you are attempting to designate already exists.
- IpfcXToolkitNotFound: The parameter you are attempting to designate cannot be found.
2) IsModified (Boolean)
Description: Indicates whether the parameter has been modified.
Sets to True if the parameter has been modified, but the "owner' has not yet been regenerated.
Values:
- True: Modified.
- False: Not modified.
Exceptions:
- IpfcXToolkitNotFound: Owner not found.
In Creo Parametric, an "owner" refers to a model object (e.g., a part, assembly, feature, etc.) that is associated with a particular parameter or dimension.
The relationship between owner and regenerate in IsModified
Even if a parameter is modified, the model (owner) does not change or update immediately.
The model must go through the regenerate process for the changes to be applied and the geometry or data of the model to be newly calculated.
At this time, the owner is the target that must reflect the changed parameter.
Example:
1. Before modification:
The part model has a dimension called D1, and the value of this dimension is set to 50.
After modification (before regeneration):
The value of D1 was changed from 50 to 60, but the model (owner) has not yet reflected the change.
In this case, IsModified = True is displayed.
2. After regeneration:
The model is regenerated and the changed value (60) is reflected.
After that, IsModified = False is changed.
The Role of Regenerate
"Regenerate" is the process by which Creo Parametric recalculates the model and applies any changes.
If parameters or dimensions change, the geometry or relationships of the model are updated during the regeneration process.
The owner accepts the changes through this regeneration process.
3) IsRelationDriven (Boolean)
Description: Indicates whether the parameter or dimension is driven by a "Relation".
Values:
- True: Driven by a Relation.
- False: Not Driven by a Relation.
4) Value (IpfcParamValue)
Description: Represents the current value of the parameter.
Value type: The value is represented as an IpfcParamValue object.
Dim ParameterOwner As IpfcParameterOwner
Dim BaseParameter As IpfcBaseParameter
Dim ParamValue As IpfcParamValue
Set ParameterOwner = Model
'// String Type Parameter
set BaseParameter = ParameterOwner.GetParam("PART_NO")
set ParamValue = BaseParameter.Value
Msgbox ParamValue.StringValue
Exceptions:
- IpfcXToolkitBadContext: If the input dimension is provided as a reference only.
- IpfcXToolkitNotFound: The owner cannot be found.
2. Methods
1. ResetFromBackup()
Description: Initializes the parameters to the backup values before they were last set. Usage: When you want to restore the parameters to their previous values.
Exception:
- IpfcXToolkitNotFound: Owner not found.
▷ Test 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(Null, Null, Null, Null)
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
Sub Param3DDrawing01()
On Error GoTo RunError
Application.EnableEvents = False
'// Module Name : CreoVBAStart
Call CreoVBAStart.CreoConnt01
MsgBox Model.fileName
Dim ParameterOwner As IpfcParameterOwner
Dim BaseParameter As IpfcBaseParameter
Dim ParamValue As IpfcParamValue
Set ParameterOwner = Model
Set BaseParameter = ParameterOwner.GetParam("PART_NO")
Set ParamValue = BaseParameter.Value
MsgBox ParamValue.StringValue
Dim PartNoParameter As String
Worksheets("Paramerter_drawing").Range("B5").Select
PartNoParameter = ActiveCell.Value
Dim ParamObject As New CMpfcModelItem
Set ParamValue = ParamObject.CreateStringParamValue(PartNoParameter)
BaseParameter.Value = ParamValue
Model.Save
MsgBox "Changed the PARAMETER value of the model.", 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
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
▷ Program execution results
When a parameter of a 3D model changes, the parameter values of the same name in the Drawing are automatically updated.
Before using the program | |
After using the program | |