xPAIVAx
Industrial
- Jul 12, 2023
- 21
Hello guys,
How can i connect two parameters "Espessura_8" and "Espessura_C8" with a formula, create a formula in the relations tab, i already have this code
Option Explicit
Dim CATIA As Object ' Declare CATIA as Object
Sub RelateParameters()
On Error Resume Next
' Define the CATIA application
Set CATIA = GetObject(, "CATIA.Application")
If CATIA Is Nothing Then
MsgBox "CATIA is not running. Please start CATIA and try again.", vbExclamation, "Error"
Exit Sub
End If
Dim partDocument As Object ' Change data type to Object
Set partDocument = CATIA.ActiveDocument
Dim product As Object ' Change data type to Object
Set product = partDocument.Product
Dim parameter8 As Object ' Change data type to Object
Set parameter8 = product.Parameters.Item("Espessura_8")
If parameter8 Is Nothing Then
MsgBox "Parameter 'Espessura_8' not found.", vbExclamation, "Parameter Not Found"
Exit Sub
End If
Dim parameterC8 As Object ' Change data type to Object
Set parameterC8 = product.Parameters.Item("Espessura_C8")
If parameterC8 Is Nothing Then
MsgBox "Parameter 'Espessura_C8' not found.", vbExclamation, "Parameter Not Found"
Exit Sub
End If
' Store the value of Espessura_8 in a variable
Dim valueToPass As Double ' Change the data type to match the parameter type
valueToPass = parameter8.Value
' Relate the parameters by setting the value of Espessura_C8 to the stored value
parameterC8.Value = valueToPass
MsgBox "Parameters related successfully. Value passed: " & valueToPass, vbInformation, "Success"
End Sub
How can i connect two parameters "Espessura_8" and "Espessura_C8" with a formula, create a formula in the relations tab, i already have this code
Option Explicit
Dim CATIA As Object ' Declare CATIA as Object
Sub RelateParameters()
On Error Resume Next
' Define the CATIA application
Set CATIA = GetObject(, "CATIA.Application")
If CATIA Is Nothing Then
MsgBox "CATIA is not running. Please start CATIA and try again.", vbExclamation, "Error"
Exit Sub
End If
Dim partDocument As Object ' Change data type to Object
Set partDocument = CATIA.ActiveDocument
Dim product As Object ' Change data type to Object
Set product = partDocument.Product
Dim parameter8 As Object ' Change data type to Object
Set parameter8 = product.Parameters.Item("Espessura_8")
If parameter8 Is Nothing Then
MsgBox "Parameter 'Espessura_8' not found.", vbExclamation, "Parameter Not Found"
Exit Sub
End If
Dim parameterC8 As Object ' Change data type to Object
Set parameterC8 = product.Parameters.Item("Espessura_C8")
If parameterC8 Is Nothing Then
MsgBox "Parameter 'Espessura_C8' not found.", vbExclamation, "Parameter Not Found"
Exit Sub
End If
' Store the value of Espessura_8 in a variable
Dim valueToPass As Double ' Change the data type to match the parameter type
valueToPass = parameter8.Value
' Relate the parameters by setting the value of Espessura_C8 to the stored value
parameterC8.Value = valueToPass
MsgBox "Parameters related successfully. Value passed: " & valueToPass, vbInformation, "Success"
End Sub