Is there a better way to create multiple layouts with 4 views each with Python?

At the moment I am creating the views with the following script

views = []
views.append(GetActiveViewOrCreate("RenderView"))
views.append(CreateRenderView())
SetActiveView(views[0])
views.append(CreateRenderView())
SetActiveView(views[1])
views.append(CreateRenderView())

Is this the right approach? I does not look clean. Is it possible to create views and then assign them to a specific layout? I tried with Layout.AssignView, but I am struggling with the locationId.

I then assign various views properties

for view in views:
    view.AxesGrid = 'GridAxes3DActor'
    view.OrientationAxesVisibility = 0
    view.StereoType = 0
    view.Background = [0.980392156862745, 0.980392156862745, 0.980392156862745]

this works, but I would like to create multiple layouts for when I have more than 4 variables to show.

Thanks

I’d recommend using the Python trace capability. Just start trace and create new tabs/layouts, split views, and create views as needed. The trace should capture the layout related changes. Here’s sample trace generated script.

# get layout
layout1 = GetLayout()

# split cell
layout1.SplitVertical(0, 0.5)

# Create a new 'Render View'
renderView2 = CreateView('RenderView')
...

# assign view to a particular cell in the layout
AssignViewToLayout(view=renderView2, layout=layout1, hint=2)

CreateLayout('Layout #2')

# Create a new 'Render View'
renderView3 = CreateView('RenderView')
...

# get layout
layout2 = GetLayoutByName("Layout #2")

# assign view to a particular cell in the layout
AssignViewToLayout(view=renderView3, layout=layout2, hint=0)