I honestly haven't gone that extra step deep in an assembly when creating constraints between named faces before, so you may have to test the code out yourself to make sure it will work for you. I believe you have to create the Proxy type object from a top level component's CreateGeometryProxy method for any objects that are at that level or below, so that the Proxy object will be available in to the main assembly.
You can try this: (you will need to change the variable values near the top, or just eliminate them if pasting into your existing larger code)
'code to replace the following:
'Constraints.AddMate("Door_YZ" & MateNumber, {DoorName, "Stile:1" }, YZFace, "", "YZ Plane", XOffset)
'these seem to be variables, because they aren't in quotes in your example line of code
Dim DoorName As String = "My Door:1"
Dim YZFace As String = "YZFace"
Dim XOffset As Double = 0
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
'get the FaceProxy of the NamedFace in the sub-component
Dim oSubAsm As ComponentOccurrence = oADef.Occurrences.ItemByName(DoorName)
Dim oSubComp As ComponentOccurrence = oSubAsm.Definition.Occurrences.ItemByName("Stile:1")
Dim oNE As NamedEntities = iLogicVb.Automation.GetNamedEntities(oSubComp.Definition.Document)
Dim oNamedFace As Face = oNE.TryGetEntity(YZFace)
Dim oNFaceProxy As FaceProxy
oSubAsm.CreateGeometryProxy(oNamedFace, oNFaceProxy)
Dim oYZPlane As WorkPlane = oADef.WorkPlanes.Item("YZ Plane")
Dim oConst As MateConstraint = oADef.Constraints.AddMateConstraint(oNFaceProxy, oYZPlane, XOffset)
Here's a tested and working example iLogic code that creates a mate constraint between named faces in two top level part type components.
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oComp1 As ComponentOccurrence = oADef.Occurrences.ItemByName("TestPart1:1")
Dim oC1NEs As NamedEntities = iLogicVb.Automation.GetNamedEntities(oComp1.Definition.Document)
Dim oC1NFace As Face = oC1NEs.TryGetEntity("Top Face")
Dim oC1NFaceProxy As FaceProxy
oComp1.CreateGeometryProxy(oC1NFace, oC1NFaceProxy)
Dim oComp2 As ComponentOccurrence = oADef.Occurrences.ItemByName("Part3:1")
Dim oC2NEs As NamedEntities = iLogicVb.Automation.GetNamedEntities(oComp2.Definition.Document)
Dim oC2NFace As Face = oC2NEs.TryGetEntity("Bottom Face")
Dim oC2NFaceProxy As FaceProxy
oComp2.CreateGeometryProxy(oC2NFace, oC2NFaceProxy)
Dim oConst As MateConstraint = oADef.Constraints.AddMateConstraint(oC1NFaceProxy, oC2NFaceProxy, 0)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)