2.22.2 AddCopy


Description

Add a new layer with data and settings from an existing layer

Syntax

VB: Function AddCopy(Layer As Layer, [ Options As ByVal Object ] ) As Layer
C++: Layer AddCopy(Layer Layer, _variant_t Options )
C#: Layer AddCopy(Layer Layer, var Options )

Return

Remark

Examples

VBA

Dim oApp As Origin.ApplicationSI

Dim myGraphPage As Origin.GraphPage

Dim myGraphPage2 As Origin.GraphPage

Dim myGraphLayer As Origin.Layer

Dim myGraphLayer2 As Origin.Layer

Set oApp = GetObject("", "Origin.ApplicationSI")

oApp.Execute ("doc -mc 1")

'we can create a opj file, this including a graph with two layers
oApp.Load ("c:\\graph.opj")


Const ORIGIN_WINTYPE_GRAPH = 3

Dim name As String, realname As String

'get the second layer
Set myGraphLayer = oApp.GraphPages(0).Layers(1)

'create a new GraphPage
realname = oApp.CreatePage(ORIGIN_WINTYPE_GRAPH, "MyWorksheet2", "Origin")

'get the second GraphPage
Set myGraphPage2 = oApp.GraphPages(1)

'Add and Copy the my GraphLayer
Set myGraphLayer2 = myGraphPage2.Layers.AddCopy(myGraphLayer)</pre>

Python

import OriginExt as O
app = O.Application()

wsheet = app.FindWorksheet('Book1' )
rng = app.NewDataRange()
rng.Add('X', wsheet, 0, 1, -1, 1)
rng.Add('Y', wsheet, 0, 2, -1, 2)

gp1 = app.GraphPages.Add('origin')
gl1 = gp.Layers(0)
dp = gl1.AddPlot(rng,201)

gp2 = app.GraphPages.Add('origin')
gl2 = gp2.Layers.AddCopy( gl1 )

Version Information

8.0SR2

See Also