Visio.Shape class

Represents the Shape class.

[ API set: 1.1 ]

Extends
OfficeExtension.ClientObject

Properties

comments

Returns the Comments Collection. Read-only.

[ API set: 1.1 ]

hyperlinks

Returns the Hyperlinks collection for a Shape object. Read-only.

[ API set: 1.1 ]

id

Shape's identifier. Read-only.

[ API set: 1.1 ]

name

Shape's name. Read-only.

[ API set: 1.1 ]

select

Returns true, if shape is selected. User can set true to select the shape explicitly.

[ API set: 1.1 ]

shapeDataItems

Returns the Shape's Data Section. Read-only.

[ API set: 1.1 ]

subShapes

Gets SubShape Collection. Read-only.

[ API set: 1.1 ]

text

Shape's text. Read-only.

[ API set: 1.1 ]

view

Returns the view of the shape. Read-only.

[ API set: 1.1 ]

Methods

getBounds()

Returns the BoundingBox object that specifies bounding box of the shape.

[ API set: 1.1 ]

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

toJSON()

Property Details

comments

Returns the Comments Collection. Read-only.

[ API set: 1.1 ]

readonly comments: Visio.CommentCollection;
Property Value

Returns the Hyperlinks collection for a Shape object. Read-only.

[ API set: 1.1 ]

readonly hyperlinks: Visio.HyperlinkCollection;
Property Value

id

Shape's identifier. Read-only.

[ API set: 1.1 ]

readonly id: number;
Property Value
number

name

Shape's name. Read-only.

[ API set: 1.1 ]

readonly name: string;
Property Value
string

select

Returns true, if shape is selected. User can set true to select the shape explicitly.

[ API set: 1.1 ]

select: boolean;
Property Value
boolean

shapeDataItems

Returns the Shape's Data Section. Read-only.

[ API set: 1.1 ]

readonly shapeDataItems: Visio.ShapeDataItemCollection;
Property Value

subShapes

Gets SubShape Collection. Read-only.

[ API set: 1.1 ]

readonly subShapes: Visio.ShapeCollection;
Property Value

text

Shape's text. Read-only.

[ API set: 1.1 ]

readonly text: string;
Property Value
string

view

Returns the view of the shape. Read-only.

[ API set: 1.1 ]

readonly view: Visio.ShapeView;
Property Value

Method Details

getBounds()

Returns the BoundingBox object that specifies bounding box of the shape.

[ API set: 1.1 ]

getBounds(): OfficeExtension.ClientResult<Visio.BoundingBox>;
Returns
OfficeExtension.ClientResult<Visio.BoundingBox>

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: string | string[]): Visio.Shape;
Parameters
option
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns
Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): Visio.Shape - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Visio.Shape - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

Examples

Visio.run(session, function (ctx) {
    var activePage = ctx.document.getActivePage();
    var shapeName = "Sample Name";
    var shape = activePage.shapes.getItem(shapeName);
    shape.load();
    return ctx.sync().then(function () {
        console.log(shape.name );
        console.log(shape.id );
        console.log(shape.Text );
        console.log(shape.Select );
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});
Visio.run(session, function (ctx) {
    var activePage = ctx.document.getActivePage();
    var shape = activePage.shapes.getItem(0);
    shape.view.highlight = { color: "#E7E7E7", width: 100 };
    return ctx.sync();
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

toJSON()

toJSON(): Visio.Interfaces.ShapeData;
Returns