# encoding: utf-8
# 2020 R2
SetScriptVersion(Version="20.2.221")
system1 = GetSystem(Name="SYS 3")
model1 = system1.GetContainer(ComponentName="Model")
model1.Edit()
system1.Copy(KeepConnections=True)
template1 = GetTemplate(
    TemplateName="Static Structural",
    Solver="ANSYS")
system2 = GetSystem(Name="SYS")
system3 = template1.CreateSystem(
    Position="Right",
    RelativeTo=system2)
geometryComponent1 = system3.GetComponent(Name="Geometry")
geometryComponent2 = system2.GetComponent(Name="Geometry")
geometryComponent1.ReplaceWithShare(
    TargetSystem=system3,
    ComponentToShare=geometryComponent2,
    SourceSystem=system2)
system3.Delete()
system4 = GetSystem(Name="SYS 5")
system4.Delete()
system5 = template1.CreateSystem(
    Position="Right",
    RelativeTo=system1)
geometryComponent3 = system5.GetComponent(Name="Geometry")
geometryComponent4 = system1.GetComponent(Name="Geometry")
geometryComponent3.ReplaceWithShare(
    TargetSystem=system5,
    ComponentToShare=geometryComponent4,
    SourceSystem=system1)
modelComponent1 = system5.GetComponent(Name="Model")
modelComponent1.Refresh()
modelComponent1.Update(AllDependencies=True)
model2 = system5.GetContainer(ComponentName="Model")
model2.Edit()
system6 = GetSystem(Name="SYS 1")
system7 = template1.CreateSystem(
    Position="Right",
    RelativeTo=system6)
geometryComponent5 = system7.GetComponent(Name="Geometry")
geometryComponent6 = system6.GetComponent(Name="Geometry")
geometryComponent5.ReplaceWithShare(
    TargetSystem=system7,
    ComponentToShare=geometryComponent6,
    SourceSystem=system6)
engineeringDataComponent1 = system7.GetComponent(Name="Engineering Data")
engineeringDataComponent2 = system6.GetComponent(Name="Engineering Data")
engineeringDataComponent1.ReplaceWithShare(
    TargetSystem=system7,
    ComponentToShare=engineeringDataComponent2,
    SourceSystem=system6)
engineeringDataComponent3 = system5.GetComponent(Name="Engineering Data")
engineeringDataComponent4 = system1.GetComponent(Name="Engineering Data")
engineeringDataComponent3.ReplaceWithShare(
    TargetSystem=system5,
    ComponentToShare=engineeringDataComponent4,
    SourceSystem=system1)
modelComponent1.Update(AllDependencies=True)
system7.Delete()
model1.Edit()
model2.Exit()
model2.Exit()
model2.Edit()
model1.Exit()
Save(Overwrite=True)
