Add a new Layer in the Visio Diagram in Ruby

Aspose.Diagram - Add a new Layer

To Add a new Layer using Aspose.Diagram Java for Ruby, simply invoke AddNewLayer module. Here you can see example code.

Ruby Code

 data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'

\# Create instance of Diagram

diagram = Rjb::import('com.aspose.diagram.Diagram').new(data_dir + "Basic_Shapes.vsd")

\# get Visio page

page = diagram.getPages().getPage(0)

\# initialize a new Layer class object

layer = Rjb::import('com.aspose.diagram.Layer').new

\# set Layer name


\# set Layer Visibility


\# add Layer to the particular page sheet


\# add a new shape

shape_id = page.addShape(3.0, 3.0, 0.36, 0.36, "Circle")

\# get the Shape object

shape = page.getShapes().getShape(shape_id)

\# assign this new Layer


\# Save diagram + "AddNewLayer.vdx", Rjb::import('com.aspose.diagram.SaveFileFormat').VDX)

puts "Added a new Layer in the Visio Diagram."

Download Running Code

Download Add a new Layer in the Visio Diagram (Aspose.Diagram) from any of the below mentioned social coding sites: