Read Visio Files



Adding a New Shape in Visio

  1. How To Read Visio Files
  2. Read Visio Files On Mac
  • Use the Visio Viewer This is the straightforward method, if all you don't need to make any changes to the Visio file. Just download Microsoft's free Visio Viewer software, and run it to install the viewer on your computer. This free software will let you open and view Visio files without Visio. However, you won't be able to make any changes.
  • Visio Viewer allows you to view Visio drawings inside their Microsoft Internet Explorer Web browser. When we double click to open.vsd then Internet Explorer will open, and Visio Viewer will render the drawing in the browser window. So, you may not get Visio Viewer application to set as default application under Default apps list.

Aspose.Diagram for .NET allows you to manipulate Microsoft Visio diagrams in different ways. One of the things you can do is add new shapes to a diagrams. Aspose.Diagram for .NET lets you to add a new shape to a diagram. The added shape can also be customized using Aspose.Diagram for .NET.

This topic describes how to add a new rectangle shape to a diagram.

Use Aspose.Diagram for .NET API to create new shapes and then add these shapes to a diagram’s shapes collection.

To add a new shape:

Previewing Visio files in Outlook The Visio Viewer also allows users to preview Visio drawings in Microsoft Outlook. In Outlook, you can simply single-click on a Visio drawing sent as an attachment and the viewer will display it in Outlook. You can pan and zoom the drawing, and switch to different pages.

  1. Find the page - Each Visio diagram contains a collection of pages. Developers may retrieve the page by page ID or Name and store the required page in the Page class object.
  2. Add the require Master of a Shape - Each Visio diagram contains a collection of masters. Developers may add a Master (by ID or Name) from the existing stencil file (by direct path or file stream).
  3. Add shape in the Visio diagram - Developers can place a new shape in the Visio diagram by page index (starting from 0), master name, PinX, PinY, height (optional) and width (optional).
  4. Set shape properties - AddShape method of the Diagram class returns the shape ID. Developers can retrieve shape from a Visio diagram by using this ID, and then set its properties, e.g. color, position, alignment and text.

The input diagram

The diagram with a shape added

Add Programming Sample

The code snippet below shows how to do each step.

Freeware
We welcome your queries and suggestions at Aspose.Diagram Forum. We’ll reply promptly.

Retrieving Shape Information

Working with Diagrams explains how to create diagrams, add shapes and connectors, and then how to retrieve information about diagram elements such as pages, masters, connectors and fonts. This article looks at how to retrieve information about shapes in a diagram. Ie5 for mac.

Each shape in a diagram has an ID and a name. The ID is important when programming with Visio: it is the main method for accessing a shape. Each shape also retains information about what master (stencil) it is made from.

A Shape is an object in a Visio drawing. The Shapes property, exposed by the Page class, supports a collection of Aspose.Diagram.Shape objects. The Shapes property can be used to retrieve information about a shape.

In the console window below, for example, you can see information output for a diagram that contained four shapes: two terminators, a process and a dynamic connector. Each has a unique ID as well as the name of the master (stencil) shape.

A console window showing shape information
To retrieve Visio page information:
  1. Loads a diagram.
  2. Sets up a foreach loop to loop through all the shapes in the diagram.
  3. Displays shape information.

Retrieve Programming Sample

The following piece of code retrieve the shape information from a Visio diagram.

Read Visio Files

Copy Shapes from an Existing Visio

Aspose.Diagram for .NET API allows developers to copy shapes from the source Visio page to the new Visio diagram page. It also supports copying group shapes. This article describes how to copy all shapes from the the source diagram page.

To copy shapes, developers should also copy source PageSheet and source Visio themes to preserve shape fill style and other formatting properties.

This example work as follows:

  1. Load a source Visio.
  2. Initialize a new Visio
  3. Add masters and themes from the source Visio.
  4. Get page from the source Visio.
  5. Copy its PageSheet to the new Visio Page.
  6. Iterate through the shapes of the source Visio page.
  7. Set its new id and add to the new Visio page.
  8. Save the new Visio in the local storage.

Copy Programming Sample

We welcome your queries and suggestions at Aspose.Diagram Forum. We’ll reply promptly.

Copy a Visio Shape to another Shape instance

The Copy method of the Shape class takes a shape instance to clone.

Reading Visio Shape Data

The Props collection exposed by the Shape class supports the Aspose.Diagram.Prop object. The property can be used to read a shape’s data (custom properties).

Read All Shape Properties

To identify custom properties in Microsoft Visio:

  1. In a diagram, right-click a shape.
  2. Select Data, then Shape Data from the menu.Any existing properties are listed in the dialog.
A shape’s data, as seen in Microsoft Visio.**
A console window showing the shape data output.**

Read Programming Sample

The code snippets below reads shape data (custom properties).

Read a Shape Property by Name

The code snippet below reads a shape property by name (custom property).

Read by Name Programming Sample

Read InheritProps of Shape

The code snippet below reads InheritProps of a shape.

Add and Connect Visio Shapes

Aspose.Diagram for .NET allows you to add customized shapes and connect them in diagrams you create.

Adding and Connecting Shapes

The code in the samples below show how to:

  1. Create a diagram.
  2. Add and customize shapes (rectangle, star, hexagon).
  3. Connect the star and hexagon shapes to the rectangle.
  4. Save the diagram.

Adding and Connecting Shapes Programming Sample

Read

Use Connection indexes to connect shapes

Aspose.Diagram for .NET API already allows developers to add new connecting points on the shape, and developers can now connect shapes using connection indexes.

Use Connection indexes to connect shapes

The ConnectShapesViaConnectorIndex member exposed by the Page class can be used to connect shapes using connection indexes. The following code shows how to connect shapes:

  1. Initialize a new drawing.
  2. Place four rectangle shapes
  3. Add two additional connection points, so that there would be three connection points on the bottom border line
  4. Connect first shape from each bottom connection to other three rectangle shapes from Top with dynamic connectors
  5. Save drawing

Use connection indexes to connect shapes Programming Sample

Use the following code in your .NET application to connect shapes using connection indexes with Aspose.Diagram for .NET API.

C#

Retrieve the Parent Shape of a Sub-Shape

Aspose.Diagram for .NET allows developers to retrieve the parent shape of a sub-shape.

Get the Parent Shape

Files

How To Read Visio Files

The Shape class offers ParentShape property to retrieve the parent shape.

Read Visio Files On Mac

Get the Parent Shape Programming Sample