The Debug.Print will print the result to the Immediate window(use Ctrl+G to show the window). Below is updated VBA code to highlight the features in top assembly for the assembly constraint:
Sub GetConstraintRefFeatureInfo()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oConstraint As AssemblyConstraint
Set oConstraint = oDoc.SelectSet(1)
oDoc.SelectSet.Clear
Debug.Print "The constraint: " & oConstraint.Name
Debug.Print "The 1st referenced feature is: " & oConstraint.OccurrenceOne.Name & "->" & GetRefFeatureName(oConstraint.EntityOne, oDoc)
Debug.Print "The 2nd referenced feature is: " & oConstraint.OccurrenceTwo.Name & "->" & GetRefFeatureName(oConstraint.EntityTwo, oDoc)
End Sub
Function GetRefFeatureName(oEntityProxy As Object, oTopDoc As AssemblyDocument) As String
Dim oNativeFeature As PartFeature
Dim oOccu As ComponentOccurrence
If oEntityProxy.Type = kFaceProxyObject Or _
oEntityProxy.Type = kEdgeProxyObject Then
Set oOccu = oEntityProxy.ContainingOccurrence
Set oNativeFeature = oEntityProxy.NativeObject.CreatedByFeature
Call HighlightFeatureInTopDoc(oNativeFeature, oTopDoc, oOccu)
GetRefFeatureName = oNativeFeature.Name
End If
End Function
Sub HighlightFeatureInTopDoc(oFeature As PartFeature, oDoc As AssemblyDocument, oOccu As ComponentOccurrence)
Dim oFeaProxy As PartFeature
Dim bStop As Boolean
bStop = False
Do
oOccu.CreateGeometryProxy oFeature, oFeaProxy
Set oFeature = oFeaProxy
If oOccu.ParentOccurrence Is Nothing Then
bStop = True
Else
Set oOccu = oOccu.ParentOccurrence
End If
Loop Until bStop
oDoc.SelectSet.Select oFeaProxy
End Sub
Hope it helps.
If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.
Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.