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

**URL:** https://discourse.paraview.org/t/is-there-a-better-way-to-create-multiple-layouts-with-4-views-each-with-python/2272
**Category:** ParaView Support
**Created:** [July 22, 2019, 7:42am UTC](https://discourse.paraview.org/t/is-there-a-better-way-to-create-multiple-layouts-with-4-views-each-with-python/2272 "2019-07-22T07:42:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Rojj](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rojj/32/1409_2.png) [@Rojj](https://discourse.paraview.org/u/Rojj)
#### Post date: [July 22, 2019, 7:42am UTC](https://discourse.paraview.org/t/is-there-a-better-way-to-create-multiple-layouts-with-4-views-each-with-python/2272/1 "2019-07-22T07:42:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [July 23, 2019, 11:21am UTC](https://discourse.paraview.org/t/is-there-a-better-way-to-create-multiple-layouts-with-4-views-each-with-python/2272/2 "2019-07-23T11:21:38Z")

</div>

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.

```python
# 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)

```
