Hi Guys, I have one large assembly and consist of 10 sub assemblies. I need to check to distance between two selected product. I attached my code here. The struggling on reference conversion position.
Dim productdocument1 As Document
Set productdocument1 = CATIA.ActiveDocument
Dim selection1
Set selection1 = productdocument1.Selection
Dim part1 As Produccatia api
Set part1 = productdocument1.Product
Dim InputObjectType(0)
InputObjectType(0) = "AnyObject"
Dim status As String
status = selection1.SelectElement2(InputObjectType, "Select the Product", False)
If status <> "Normal" Then
Exit Sub
End If
Dim surface1 As object
Set surface1 = selection1.Item(1).Value
Dim s As String
s = surface1.Name
selection1.Clear
Dim status1 As String
status1 = selection1.SelectElement2(InputObjectType, "Select the Product", False)
If status1 <> "Normal" Then
Exit Sub
End If
Dim surface2 As Object
Set surface2 = selection1.Item(1).Value
Dim sur As String
sur = surface2.Name
selection1.Clear
Dim spa As SPAWorkbench
Set spa = productdocument1.GetWorkbench("SPAWorkbench")
Dim ref As Reference
Set ref = part1 .CreateReferenceFromName(surface1.Name)
Dim ref1 As Reference
Set ref1 = part1.CreateReferenceFromName(surface2.Name)
Dim themeas As measurable
Set themeas = spa.GetMeasurable(ref)
Dim meas As Double
meas = themeas.GetMinimumDistance(ref1)