# Feature request: Clone renderView

**URL:** https://discourse.paraview.org/t/feature-request-clone-renderview/2370
**Category:** Feature Requests
**Created:** [August 6, 2019, 3:14pm UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370 "2019-08-06T15:14:37Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [August 6, 2019, 3:14pm UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/1 "2019-08-06T15:14:38Z")

</div>

I am setting up a state which holds multipe renderViews, so that I can have a batch job render all these views for a particular dataset. I often want these views to show the same scene but viewed from different angles and/or just slightly modified.  
However, when creating a new renderView I have to reconfigure all display properties all over again which is tedious.  
Here it would be helpful to have a “clone a renderView” option.

---

<div class="post-metadata">

### Author: ![farhaddaei](https://discourse.paraview.org/user_avatar/discourse.paraview.org/farhaddaei/32/7044_2.png) [@farhaddaei](https://discourse.paraview.org/u/farhaddaei)
#### Post date: [October 8, 2020, 4:51pm UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/2 "2020-10-08T16:51:28Z")

</div>

I have a similar situation and I also think “clone renderView” can be a very helpful feature, however, maybe it is possible to manipulate the saved state file and duplicating some lines, but it would be very messy.

---

<div class="post-metadata">

### Author: ![theodorebaltis](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/t/e480ec/32.png) [@theodorebaltis](https://discourse.paraview.org/u/theodorebaltis)
#### Post date: [October 8, 2020, 5:36pm UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/3 "2020-10-08T17:36:44Z")

</div>

I agree this would be a nice built-in feature, but I’ve made some macros to do this (sorry @bastian, I didn’t see your original post!).

They are not super-thoroughly tested but generally seem to do what I want.

**MirrorH.py**

```python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''Macro to split and mirror current view
Splits horizontally
'''

from paraview.simple import *

# Get initial view
renderView1 = GetActiveView()

# Get initial layout
layout1 = GetLayout()

# Split cell
layout1.SplitViewHorizontal(renderView1)

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

# Assign to layout (needed in ParaView 5.7.0+)
pv_ver = GetParaViewVersion()
if pv_ver >= 5.7:
    AssignViewToLayout(renderView2, layout1, hint=2)

# Get sources
sources = GetSources()

# Copy view properties
for prop in renderView1.ListProperties():
    if prop == 'Representations': # representation cannot exist in two views
        continue

    propval = renderView1.GetPropertyValue(prop)
    try:
        renderView2.SetPropertyWithName(prop, propval)
    except Exception as ex:
        try:
            renderView2.SetPropertyWithName(prop, propval.GetData())
        except (AttributeError, RuntimeError):
            #print(prop, propval, type(propval))
            #print(' {}'.format(type(ex)))
            pass

# Copy representation properties
for source in sources.values():
    rep1 = GetRepresentation(proxy=source, view=renderView1)
    rep2 = GetRepresentation(proxy=source, view=renderView2)

    props = rep1.ListProperties()
    for prop in props:
        propval = rep1.GetPropertyValue(prop)

        try:
            rep2.SetPropertyWithName(prop, propval)
        except Exception as ex:
            try:
                rep2.SetPropertyWithName(prop, propval.GetData())
            except RuntimeError:
                pass

UpdateScalarBars(renderView2)

# Explicitly copy camera properties
camera_props = ['Position', 'FocalPoint', 'ViewAngle', 'ViewUp', 'ParallelProjection', 'ParallelScale']
for prop in camera_props:
    eval_str = 'renderView2.Camera{0} = renderView1.Camera{0}'.format(prop)
    exec(eval_str)

Render(renderView2)

```

**MirrorV.py**

```python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''Macro to split and mirror current view
Splits vertically
'''

from paraview.simple import *

# Get initial view
renderView1 = GetActiveView()

# Get initial layout
layout1 = GetLayout()

# Split cell
layout1.SplitViewVertical(renderView1)

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

# Assign to layout (needed in ParaView 5.7.0+)
pv_ver = GetParaViewVersion()
if pv_ver >= 5.7:
    AssignViewToLayout(renderView2, layout1, hint=2)

# Get sources
sources = GetSources()

# Copy view properties
for prop in renderView1.ListProperties():
    if prop == 'Representations': # representation cannot exist in two views
        continue

    propval = renderView1.GetPropertyValue(prop)
    try:
        renderView2.SetPropertyWithName(prop, propval)
    except Exception as ex:
        try:
            renderView2.SetPropertyWithName(prop, propval.GetData())
        except (AttributeError, RuntimeError):
            #print(prop, propval, type(propval))
            #print(' {}'.format(type(ex)))
            pass

# Copy representation properties
for source in sources.values():
    rep1 = GetRepresentation(proxy=source, view=renderView1)
    rep2 = GetRepresentation(proxy=source, view=renderView2)

    props = rep1.ListProperties()
    for prop in props:
        propval = rep1.GetPropertyValue(prop)

        try:
            rep2.SetPropertyWithName(prop, propval)
        except Exception as ex:
            try:
                rep2.SetPropertyWithName(prop, propval.GetData())
            except RuntimeError:
                pass

UpdateScalarBars(renderView2)

# Explicitly copy camera properties
camera_props = ['Position', 'FocalPoint', 'ViewAngle', 'ViewUp', 'ParallelProjection', 'ParallelScale']
for prop in camera_props:
    eval_str = 'renderView2.Camera{0} = renderView1.Camera{0}'.format(prop)
    exec(eval_str)

Render(renderView2)

```

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [November 27, 2020, 10:40am UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/4 "2020-11-27T10:40:16Z")

</div>

Awesome, this is what I was looking for.

The scripts seem to work well. I only found two tweaks necessary:

- I removed `UpdateScalarBars(renderView2)` for this had colorbars show that were disabled in `renderView1`.
- I added `paraview.simple._DisableFirstRenderCameraReset()` which I found is needed to make the view-cloning work without first manually changing the view via the GUI.

For convenience I merged the two scripts into one:

[RenderViewCloning.py](https://discourse.paraview.org/uploads/short-url/cbH47cK8fErRBHMiTYllHfO0a1G.py) (4.1 KB)

When run in ParaView the new script defines the functions `split_right()` and `split_down()`. By calling one of these two functions one achieves the splitting of the current layout with a new `renderView` being created, just like your scripts did.

I added a new function `clone_to_new_layout()` which obviously creates a new Layout and then clones the current RenderView into this new Layout.

This script should be maintained in some GIT repository though. Is there a dedicated repository for ParaView-scripts?

---

<div class="post-metadata">

### Author: ![lhofmann](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@lhofmann](https://discourse.paraview.org/u/lhofmann)
#### Post date: [January 20, 2021, 8:43am UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/5 "2021-01-20T08:43:47Z")

</div>

This is really useful and I’m using that all the time!

I have fixed a few bugs

- use `vtkSMProxyClipboard` for copying the properties (that’s what is used by the copy/paste buttons in ParaView); this should correctly handle all types of properties (among others, I get a segfault when assigning `None` to `OSPRayMaterial`)
- support for sources with multiple output ports (using the result of `GetSources()` only affects the first output ports)
- representations are only created for ports that are visible
- the `AutomaticRescaleRangeMode` of color transfer functions is temporarily set to `Never`, preventing them from getting rescaled upon calling `GetRepresentation`
- I’ve also replaced the `eval` call by `getattr`/`setattr` (not a bug fix, just makes me sleep better at night)

> <https://gist.github.com/lhofmann/2ca7befb0bb0037fb9397c87c5936619>

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [May 18, 2021, 8:37am UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/6 "2021-05-18T08:37:43Z")

</div>

This iteration of the script is a great improvement and I am using it all the time, too.

There is one glitch one may want to know about:

Once the RenderView is cloned, changing the Color Palette only ever affects the first RenderView and it seems to be impossible to change the Color Palette active in the clones.  
So bear in mind that if you plan on changing the Color Palette, do so before cloning the RenderView.

---

<div class="post-metadata">

### Author: ![stephanmg](https://discourse.paraview.org/user_avatar/discourse.paraview.org/stephanmg/32/6538_2.png) [@stephanmg](https://discourse.paraview.org/u/stephanmg)
#### Post date: [May 21, 2021, 8:49am UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/7 "2021-05-21T08:49:51Z")

</div>

Hi, for me this does not copy the color palette and also not the font sizes of my (text annotations).

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 21, 2021, 8:52am UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/8 "2021-05-21T08:52:18Z")

</div>

Should we move this to “Feature request” category @cory.quammen ?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [May 21, 2021, 7:32pm UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/9 "2021-05-21T19:32:41Z")

</div>

Sure. Moved.

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [September 8, 2021, 9:13am UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/11 "2021-09-08T09:13:15Z")

</div>

> [@stephanmg](#):
>
> Hi, for me this does not copy the color palette

For me it does copy the color palette (Paraview version 5.9.1)

---

<div class="post-metadata">

### Author: ![bastian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bastian/32/7513_2.png) [@bastian](https://discourse.paraview.org/u/bastian)
#### Post date: [September 8, 2021, 12:11pm UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/12 "2021-09-08T12:11:55Z")

</div>

I have added the following features:

- clone additional lights
- clone scalarbar properties

I no longer observe this issue in Paraview 5.9.1:

> [@bastian](#):
>
> Once the RenderView is cloned, changing the Color Palette only ever affects the first RenderView and it seems to be impossible to change the Color Palette active in the clones.  
> So bear in mind that if you plan on changing the Color Palette, do so before cloning the RenderView.

> <https://gist.github.com/baloe/a6ccd18e6380dbcae094566f50e26d45>

---

<div class="post-metadata">

### Author: ![DAN](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dan/32/5881_2.png) [@DAN](https://discourse.paraview.org/u/DAN)
#### Post date: [February 24, 2022, 12:32am UTC](https://discourse.paraview.org/t/feature-request-clone-renderview/2370/13 "2022-02-24T00:32:23Z")

</div>

Thank you very much. It was very useful.
