Adds a new layer to the layer collection of the document. Returns a Layer object corresponding to the created layer.
Applies to: Document object
[[Set] layerRet =] object.AddLayer () |
The AddLayer method syntax has these parts:
Part | Description |
object | Required. An expression, that returns a Document object. |
layerRet | Optional. A Layer type variable. |
The layer created by using the AddLayer method is added at the end of the layer collection of the document. All properties of the new layer get the default values. To change the properties of the layer, use the properties and methods of the Layer object.
This example contains a document-level script. It uses the AddLayer method to add a new layer. Then this layer is made active and a complex shape is drawn on it.
' Declare variables Dim new_layer As Layer ' Add new layer to document Set new_layer = thisDoc.AddLayer() ' Display the name of the new layer TRACE new_layer.Name ' Make the layer colored. new_layer.Colored = TRUE ' Set the current layer color to blue. new_layer.Color.SetRGB(0,0,255) ' Make the new layer active thisDoc.ActiveLayer = new_layer.ID ''''''''''''''''''''''''''''''''''''''''''''' ' Draw some figure on the new layer ' The figure takes the color of the layer on which it's being drawn dy = 10 smax = 700 / dy x1 = 0 y1 = 0 x2 = 0 y2 = 0 For i=1 To smax thisDoc.ActivePage.DrawLine( x1,y1,x2,y2 ) y1 = y1 + dy x1 = sqr( y1*200 ) x2 = sqr( y1*600 ) y2 = y1 Next i x1 = 900 y1 = 0 x2 = 900 y2 = 0 For i=1 To smax thisDoc.ActivePage.DrawLine( x1,y1,x2,y2 ) y1 = y1 + dy x1 = 1000 - sqr( y1*200 ) x2 = 1000 - sqr( y1*600 ) y2 = y1 Next i '''''''''''''''''''''''''''''''''''''''''''' |
See Also |
Layer method, LayerByID method, LayerByName method, LayersNum method, RemoveLayer method, RemoveLayerByID method, Layer object |