Hi @ndillner343SKL. Yes, that is possible, but it can be fairly complicated behind the scenes. I actually created a custom function some time back just for retrieving assigned names from various possible objects that may have been assigned a name using the built-in NamedEntities interface. The entities you will get from the EntityOne or EntityTwo of an assembly constraint will almost always be a proxy of some sort, that only exists within the context of the assembly, so they won't have the name assigned directly to them. The name will be assigned to the 'native' object that the proxy was a copy of (the actual geometry within the context of a part). Of course it is possible that one side of your constraint was to one of the assemblies own work features, in which case it will not be a proxy though. Either way, you can feed the object you get from that EntityOne to this function, and the function will either return its name, or an empty String. You would just have to check the returned value to make sure it is not empty, before trying to use it for anything important.
Keep in mind, to use this function, your other iLogic rule code would need to be within the Sub Main...End Sub boundaries, then this whole function below, would be placed below the End Sub somewhere. Then somewhere within your Sub Main area, you just need to declare a String type variable and set its value by calling this function to run, and put that object as its input variable.
Here is that function's code:
Function GetEntityName(oEntity As Object) As String
Dim oType As String = TypeName(oEntity)
Dim oDoc As Document = Nothing
Dim oFace As Face = Nothing
Dim oEdge As Edge = Nothing
Dim oVertex As Vertex = Nothing
Dim oNativeObject As Object = Nothing
Select Case oType
Case "Face"
oFace = oEntity
oDoc = oFace.Parent.ComponentDefinition.Document
Case "FaceProxy"
Dim oFaceProxy As FaceProxy = oEntity
If TypeOf oFaceProxy.NativeObject Is FaceProxy Then
GetEntityName(oFaceProxy.NativeObject)
Else
oFace = oFaceProxy.NativeObject
End If
oNativeObject = oFace
oDoc = oFace.Parent.ComponentDefinition.Document
Case "Edge"
oEdge = oEntity
oDoc = oEdge.Parent.ComponentDefinition.Document
Case "EdgeProxy"
Dim oEdgeProxy As EdgeProxy = oEntity
If TypeOf oEdgeProxy.NativeObject Is EdgeProxy Then
GetEntityName(oEdgeProxy.NativeObject)
Else
oEdge = oEdgeProxy.NativeObject
End If
oNativeObject = oEdge
oDoc = oEdge.Parent.ComponentDefinition.Document
Case "Vertex"
oVertex = oEntity
oDoc = oVertex.Parent.ComponentDefinition.Document
Case "VertexProxy"
Dim oVertexProxy As VertexProxy = oEntity
If TypeOf oVertexProxy.NativeObject Is VertexProxy Then
GetEntityName(oVertexProxy.NativeObject)
Else
oVertex = oVertexProxy.NativeObject
End If
oNativeObject = oVertex
oDoc = oVertex.Parent.ComponentDefinition.Document
End Select
If IsNothing(oDoc) Then Return ""
Dim oNEs As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
Dim oName As String
If IsNothing(oNativeObject) Then
oName = oNEs.GetName(oEntity)
Else
oName = oNEs.GetName(oNativeObject)
End If
Return oName
End Function
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)