Hello Gilgamesh99,
Here below you may find some code to start with.
The user shall create a polyline as a path in the Geometrical Set.1 and then run the macro.
Sub CATMain(dBendRadius, dDiameter, dThickness)
Dim oActivePartDoc: Set oActivePartDoc = CATIA.ActiveDocument
Dim oPart As Part: Set oPart = oActivePartDoc.Part
Dim Selection: Set Selection = CATIA.ActiveDocument.Selection: Selection.Clear
Dim varFilter(0) As Variant: varFilter(0) = "HybridShape"
Dim HSPolyline As HybridShapePolyline
Dim HSPElement(1 To 4) As Reference
Dim HSPRadius(1 To 4) As Length
Dim i As Long
Dim HSCircle3D As HybridShapeCircleCtrRad
'Select a Polyline as Path
strReturn = Selection.SelectElement2(varFilter, "Select the Pipe Center Line (a Polyline):", False): If (strReturn = "Cancel") Then Exit Sub
Set HSPolyline = Selection.Item2(1).Value
Set HSCircle3D = HSCCRCreateProfile(HSPolyline, 0.5 * CDbl(dDiameter)) 'Create a 3DCircle for Profile
Call CreatePipe(HSPolyline, HSCircle3D, CDbl(dThickness)) 'Create Rib for Pipe
oPart.Update 'Update Part
Call SetAllRadius(HSPolyline, CDbl(dBendRadius)) 'Set Radius
Call HideObject(HSCircle3D) 'Hide Auxilliary Elements
Call HideObject(HSPolyline)
oPart.Update
End Sub
Function HSCCRCreateProfile(hspPath As HybridShapePolyline, dRadius As Double) As HybridShapeCircleCtrRad
Dim oActivePartDocument As PartDocument: Set oActivePartDocument = CATIA.ActiveDocument
Dim oPart As Part: Set oPart = oActivePartDocument.Part
Dim oHSFactory As HybridShapeFactory: Set oHSFactory = oPart.HybridShapeFactory
Dim oHBodies As HybridBodies: Set oHBodies = oPart.HybridBodies
Dim oHBody As HybridBody: Set oHBody = oHBodies.Item("Geometrical Set.1") 'In Geometrical Set.1
Dim oHShapes As HybridShapes: Set oHShapes = oHBody.HybridShapes
Dim oHSPolyline As HybridShapePolyline: Set oHSPolyline = oHShapes.Item(hspPath.Name) 'Input 1 oHSPolyline=hsPolyline
Dim rRefPath As Reference: Set rRefPath = oPart.CreateReferenceFromObject(oHSPolyline)
Dim lBendRadius As Length
Dim rRefCenterPt As Reference: oHSPolyline.GetElement 1, rRefCenterPt, lBendRadius
Dim HSPlaneNormal As HybridShapePlaneNormal: Set HSPlaneNormal = oHSFactory.AddNewPlaneNormal(rRefPath, rRefCenterPt)
oHBody.AppendHybridShape HSPlaneNormal
Call HideObject(HSPlaneNormal)
oPart.InWorkObject = HSPlaneNormal
Dim rRefSupport As Reference: Set rRefSupport = oPart.CreateReferenceFromObject(HSPlaneNormal)
Dim HSCircle3D As HybridShapeCircleCtrRad
Set HSCircle3D = oHSFactory.AddNewCircleCtrRad(rRefCenterPt, rRefSupport, False, dRadius) 'Input 2
HSCircle3D.SetLimitation 1
oHBody.AppendHybridShape HSCircle3D
oPart.InWorkObject = HSCircle3D
Set HSCCRCreateProfile = HSCircle3D
End Function
Sub CreatePipe(HSPolyline As HybridShapePolyline, HSCircle3D As HybridShapeCircleCtrRad, dThickness As Double)
Dim oPart As Part
Dim oShapeFactory As ShapeFactory
Dim oBody As Body
Dim oReference1, oReference2 As Reference
Dim oRib As Rib
Dim oParameters As Parameters
Dim lenLenght As Length
Set oPart = CATIA.ActiveDocument.Part
Set oBody = oPart.Bodies.Item("PartBody")
oPart.InWorkObject = oBody
Set oShapeFactory = oPart.ShapeFactory
Set oReference1 = oPart.CreateReferenceFromObject(HSCircle3D)
Set oReference2 = oPart.CreateReferenceFromObject(HSPolyline)
Set oRib = oShapeFactory.AddNewRibFromRef(oReference1, oReference2)
oRib.IsThin = True
Set oParameters = oPart.Parameters
Set lenLenght = oParameters.Item(oPart.Name & "\PartBody\" & oRib.Name & "\ThickThin2")
lenLenght.Value = dThickness
Set lenLenght = oParameters.Item(oPart.Name & "\PartBody\" & oRib.Name & "\ThickThin1")
lenLenght.Value = 0#
oPart.Update
End Sub
'UTILITIES
Sub HideObject(obj As Variant)
Dim Selection As Selection
Set Selection = CATIA.ActiveDocument.Selection
Selection.Add obj
Selection.VisProperties.SetShow catVisPropertyNoShowAttr
End Sub
Sub ShowObject(obj As Variant)
Dim Selection As Selection
Set Selection = CATIA.ActiveDocument.Selection
Selection.Add obj
Selection.VisProperties.SetShow catVisPropertyShowAttr
End Sub
Sub SetAllRadius(HSPolyline As HybridShapePolyline, dBendRadius As Double)
Dim HSPNoOfElements As Long
HSPNoOfElements = HSPolyline.NumberOfElements
For i = 2 To HSPNoOfElements - 1
HSPolyline.SetRadius i, dBendRadius
Next i
End Sub
I Hope it helps.
-GEL
Imposible is nothing.