Code:
'###################################
' Script um zwei Elemente/Objekte in einen Join zusammenzufassen.
' Dieser Join wird an einer auszuwählenden Stelle angelegt.
'###################################
Language="VBSCRIPT"
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
Dim selection2 As Selection
Set selection2 = partDocument1.Selection
Dim selection3 As Selection
Set selection3 = partDocument1.Selection
Dim strFilter(0)
Dim ref1 as Reference
Dim ref2 as Reference
Dim sObject1 as Object 'first Object to select
Dim sObject2 as Object 'Second Object to select
Dim sObject3 as Object 'GeoSet to select
Set sObject1 = selection1
Set sObject2 = selection2
Set sObject3 = selection3
'####################
' Objekte selektieren
'####################
strFilter(0) = "AnyObject"
'####################
' Erstes Objekt
'####################
sObject1.SelectElement2 strFilter, "Bitte selektiere etwas",False
Set ref1 = part1.CreateReferenceFromObject(sObject1.Item(1).Value)
msgbox(ref1.displayname)
'####################
' Zweites Objekt
'####################
sObject2.SelectElement2 strFilter, "Bitte selektiere etwas",False
Set ref2 = part1.CreateReferenceFromObject(sObject2.Item(1).Value)
MsgBox(ref2.displayname)
'####################
' creating Join
'####################
Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim hybridShapeAssemble1 As HybridShapeAssemble
Set hybridShapeAssemble1 = hybridShapeFactory1.AddNewJoin(ref1, ref2)
hybridShapeAssemble1.SetConnex 0
hybridShapeAssemble1.SetManifold 0
hybridShapeAssemble1.SetSimplify 0
hybridShapeAssemble1.SetSuppressMode 0
hybridShapeAssemble1.SetDeviation 0.001000
hybridShapeAssemble1.SetAngularToleranceMode 0
hybridShapeAssemble1.SetAngularTolerance 0.500000
hybridShapeAssemble1.SetFederationPropagation 0
'######################
' Selektion des GeoSet für den Join
'######################
sObject3.SelectElement2 strFilter, "Bitte selektiere GeoSet für Join",False
Dim hybridBody1 as HybridBody
Set hybridBody1 = sObject3.item(1).value
hybridBody1.AppendHybridShape hybridShapeAssemble1
part1.InWorkObject = hybridShapeAssemble1
part1.Update
End Sub