Sub Link_Radius()
Set Document = CATIA.ActiveDocument
Dim oPart As Part
Set oPart = Document.Part
Dim oBody As Body
Set oBody = oPart.Bodies.Item("PartBody")
Dim oSketch As Sketch
Set oSketch = oBody.Sketches.Item("Sketch.1")
Dim oConstraints As Constraints
Set oConstraints = oSketch.Constraints
icount = 0
For i = 1 To oConstraints.Count
Set Cst = oConstraints.Item(i)
If Cst.Type = catCstTypeRadius Then
Dim sName As String
sName = Cst.Name
Dim Dime As Object
Set Dime = Cst.Dimension
Dim sParam As String
sParam = Dime.Name
Dim lValue As Double
lValue = Dime.Value / 25.4
icount = icount + 1
Link_Parameter_to_Dimension sName, sParam, lValue, icount
Else
End If
Next i
End Sub
Function Link_Parameter_to_Dimension(sName As String, sParam As String, lValue As Double, ByVal icount As Integer)
Dim oPart As Part
Set oPart = CATIA.ActiveDocument.Part
Dim D1Name As Object
Set D1Name = oPart.FindObjectByName(sName)
Dim D1 As RealParam
If icount = 1 Then
Set D1 = oPart.Parameters.CreateReal("Radius", lValue)
Else
End If
Dim oRelations As Relations
Set oRelations = oPart.Relations
Dim Param As Parameters
Set Param = oPart.Parameters.SubList(D1Name, True)
Dim sBodyFormula As String
sBodyFormula = "(" & "Radius" & "*1in)"
Dim oFormula As Formula
Set oFormula = oRelations.CreateFormula("", "", Param.Item(1), sBodyFormula)
End Function