I'm trying to add a Coincidence Constraint by picking geometry in a product after adding a component. I first recorded a macro and then added a user select to pick a cylindrical face. It creates the Constraint but it has the exclamation point next to it. Below is the code. Any help is appreciated. Obviously I'm new at this
Language="VBSCRIPT"
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim constraints1 As Collection
Set constraints1 = product1.Connections("CATIAConstraints")
Dim reference1 As Reference
'Set reference1 = product1.CreateReferenceFromName("Product2/25-10302-0000.1/!AxisSelection_RSurFaceBrpChamfer1;4);None);Cf11));Chamfer1;Z0;G6719))")
'My Code added to make user selection
Dim oSel as Selection
Set oSel = productDocument1.selection
Dim Filter(0)
Filter(0)="Face"
Dim Result As String
Result=oSel.selectelement2(Filter, " Select Object", False)
Set reference1 =oSel.Item(1).Value
Dim reference2 As Reference
Set reference2 = product1.CreateReferenceFromName("Product2/Part40.1/!AxisSelection_RSurFaceBrpPad.2;0BrpSketch.2;1)));None);Cf11));Pad.2_ResultOUT;Z0;G6719))")
Dim constraint1 As Constraint
Set constraint1 = constraints1.AddBiEltCst(catCstTypeOn, reference1, reference2)
product1.Update
End Sub
Language="VBSCRIPT"
Sub CATMain()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim constraints1 As Collection
Set constraints1 = product1.Connections("CATIAConstraints")
Dim reference1 As Reference
'Set reference1 = product1.CreateReferenceFromName("Product2/25-10302-0000.1/!AxisSelection_RSurFaceBrpChamfer1;4);None);Cf11));Chamfer1;Z0;G6719))")
'My Code added to make user selection
Dim oSel as Selection
Set oSel = productDocument1.selection
Dim Filter(0)
Filter(0)="Face"
Dim Result As String
Result=oSel.selectelement2(Filter, " Select Object", False)
Set reference1 =oSel.Item(1).Value
Dim reference2 As Reference
Set reference2 = product1.CreateReferenceFromName("Product2/Part40.1/!AxisSelection_RSurFaceBrpPad.2;0BrpSketch.2;1)));None);Cf11));Pad.2_ResultOUT;Z0;G6719))")
Dim constraint1 As Constraint
Set constraint1 = constraints1.AddBiEltCst(catCstTypeOn, reference1, reference2)
product1.Update
End Sub