Hi @Saikiran_arakeri. As a test on my end, I created two parts that loosely look like a UCS, to make ethier orientation visibly obvious. Then I created a UCS within each of those two nearly identical parts that was aligned with the origin planes of the parts. Then I created a new assembly, and placed one of each of those two parts into the assembly, in different orientations. Below is a screen capture of that assembly.

As you can see, both parts are identical, but have slightly different file names, and are in different orientations, and neither one has been grounded or constrained in any way yet. And I have two internal iLogic rules there for creating the UCS to UCS constraint in the two different orders. My first couple tries, where both codes were just the one line of code, but in reversed order, they were working perfect, but then they stopped working as expected. At first, one rule would cause the first part to align with the second perfectly, then the other rule would cause the second part to align with the first part perfectly, but then they both started acting the same (both were aligning the second part with the first part). So, I slightly changed the second rule to first ground the component I did not want to move, then create the constraint, then update the document, then remove the grounded status, and that worked like a charm.
Below are the contents of those two rules:
Add UCS to UCS Constraint 1
Constraints.AddUcsToUcs("UCS to UCS 1", "Coordinates Part:1", "UCS1", "Coordinates Part 2:2", "UCS1", 0, 0, 0)
Add UCS to UCS Constraint 2
Component.InventorComponent("Coordinates Part 2:2").Grounded = True
Constraints.AddUcsToUcs("UCS to UCS 2", "Coordinates Part 2:2", "UCS1", "Coordinates Part:1", "UCS1", 0, 0, 0)
iLogicVb.DocumentUpdate
Component.InventorComponent("Coordinates Part 2:2").Grounded = False
When I run the first rule, this is the result:

Then I undo what that rule did, and run the second rule, and this is the result of that second rule:

So in this case, since this is sort of a compound constraint (actually creates 3 constraints, not just one), you simply have to ground (or otherwise fully constrain) the one you do not want to move first, then apply the constraint, then update the assembly (important), then remove the grounded state from the one component after the document has been updated. If I left out the update step, it would not work right, and it would update the model after the rule was done (after the grounded state was removed), which would cause the second part to move, instead of the first part. But this was the simplest way I found to do this process. There are surely other ways to do this too, but this way just seems to require the least code, and takes advantage of the iLogic shortcut snippets.
Wesley Crihfield

(Not an Autodesk Employee)