Visio.Shape class

Represents the Shape class.

[ API set: 1.1 ]

Extends

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.

load(propertyNames)

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

load(propertyNamesAndPaths)

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

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

toJSON()

Property Details

comments

Returns the Comments Collection. Read-only.

[ API set: 1.1 ]

readonly comments: Visio.CommentCollection;

Property Value

Visio.CommentCollection

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

Visio.ShapeCollection

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?: Visio.Interfaces.ShapeLoadOptions): Visio.Shape;

Parameters

option
Visio.Interfaces.ShapeLoadOptions

Returns

Visio.Shape

Remarks

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

load(option?: string | string[]): Visio.Shape - Where option is a comma-delimited string or an array of strings that specify the properties to load.

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));
    }
});

load(propertyNames)

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

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

Parameters

propertyNames
string | string[]

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

Returns

Visio.Shape

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: { select?: string; expand?: string; }): Visio.Shape;

Parameters

propertyNamesAndPaths
{ select?: string; expand?: string; }

Where propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

Visio.Shape

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.ShapeUpdateData, options?: OfficeExtension.UpdateOptions): void;

Parameters

properties
Interfaces.ShapeUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

Remarks

This method has the following additional signature:

set(properties: Visio.Shape): void

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Visio.Shape): void;

Parameters

properties
Visio.Shape

Returns

void

toJSON()

toJSON(): Visio.Interfaces.ShapeData;

Returns

Visio.Interfaces.ShapeData