Hi @Saikiran_arakeri. Judging from the image you posted above, neither of those two UCS objects are really 'local'. The one named "ASM_Assembly3:1" appears to be defined within the sub assembly named "Assembly20:1". Then the UCS named "ASM_Assembly3" appears to be defined down within a sub assembly named "Assembly3:1" that is within that other sub assembly. This is a pretty complex situation to write a code to solve for you, but I have given it a try for you. Below is an iLogic rule that should create the necessary constraints. Just so you know, the 'UCS to UCS constraint' is not a real thing, there is just an iLogic shortcut snipped name that way for that task. What it actually does is create 3 flush constraints. It creates a flush constraint between a specific WorkPlane within one UCS to the same WorkPlane within the other UCS, and does that for all 3 WorkPlanes within both UCS's. So, that is what this iLogic rule is doing. I am using regular Inventor API code for this task, instead of that iLogic shortcut snippet, because of the complexity of this situation. Let me know how this works for you.
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oOccs As ComponentOccurrences = oADef.Occurrences
Dim oConsts As AssemblyConstraints = oADef.Constraints
'get the first level component that represents the first sub assembly, by name
Dim oSubAsmOcc As ComponentOccurrence = oOccs.ItemByName("Assembly20:1")
'get the UCS defined within the definition of that component
Dim oSubAsmUCS As UserCoordinateSystem = oSubAsmOcc.Definition.UserCoordinateSystems.Item("ASM_Assembly3:1")
'step up the proxy ladder to get the UCS for this in the context of the top assembly (only 1 step needed here)
Dim oSubAsmUCSProxy As UserCoordinateSystemProxy = Nothing
oSubAsmOcc.CreateGeometryProxy(oSubAsmUCS, oSubAsmUCSProxy)
'get the second level component, within the other component, by name
Dim oSubSubAsmOcc As ComponentOccurrence = oSubAsmOcc.Definition.Occurrences.ItemByName("Assembly3:1")
'get the UCS that is defined within the definition of that component
Dim oSubSubAsmUCS As UserCoordinateSystem = oSubSubAsmOcc.Definition.UserCoordinateSystems.Item("ASM_Assembly3")
'step up the proxy ladder 2 steps to get the UCS for this in the context of the top assembly
'first create a variable to hold the proxy object we are about to get
Dim oSubSubAsmUCSProxy1 As UserCoordinateSystemProxy = Nothing
'now set that variable's value using this method of that UCS's owning component
oSubSubAsmOcc.CreateGeometryProxy(oSubSubAsmUCS, oSubSubAsmUCSProxy1)
'that proxy is in the context of its parent component, not the main assembly yet, because it was a second level component
'now create another variable for the next step up proxy object
Dim oSubSubAsmUCSProxy2 As UserCoordinateSystemProxy = Nothing
'now use this method of the parent component to set the value of that variable, using that last lower level proxy as input
oSubAsmOcc.CreateGeometryProxy(oSubSubAsmUCSProxy1, oSubSubAsmUCSProxy2)
'now create the constraints (UCS to UCS constraint is just 3 WorkPlane Flush constraints behind the scenes)
'these constraints are created in the context of the main assembly, so the participants also need to be in that context
Dim oFConst1, oFConst2, oFConst3 As FlushConstraint
oFConst1 = oConsts.AddFlushConstraint(oSubAsmUCSProxy.XYPlane, oSubSubAsmUCSProxy2.XYPlane, 0.0)
oFConst2 = oConsts.AddFlushConstraint(oSubAsmUCSProxy.XZPlane, oSubSubAsmUCSProxy2.XZPlane, 0.0)
oFConst3 = oConsts.AddFlushConstraint(oSubAsmUCSProxy.YZPlane, oSubSubAsmUCSProxy2.YZPlane, 0.0)
oADoc.Update
End Sub
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)