vsdx Key Classes

There are a few key classes in the vsdx package that relate to elements of a vsdx file

vsdx.VisioFile

class vsdx.VisioFile(filename, debug: bool = False)

Represents a vsdx file

Parameters:
  • filename (str) – filename the VisioFile was created from

  • pages (list of Page) – a list of pages in the VisioFile

  • master_pages (list of Page) – a list of master pages in the VisioFile

__init__(filename, debug: bool = False)

VisioFile constructor

Parameters:
  • filename (str) – the vsdx file to load and create the VisioFile object from

  • debug (bool, default to False) – enable/disable debugging

add_page(name: str | None = None) Page

Add a new page at the end of the VisioFile

Parameters:

name (str, optional) – The name of the new page

Returns:

Page object representing the new page

add_page_at(index: int, name: str | None = None) Page

Add a new page at the specified index of the VisioFile

Parameters:
  • index (int) – zero-based index where the new page will be placed

  • name (str, optional) – The name of the new page

Returns:

Page object representing the new page

copy_page(page: Page, *, index: int | None = PagePosition.AFTER, name: str | None = None) Page

Copy an existing page and insert in VisioFile

Parameters:
  • page (Page) – the page to copy

  • index (int or PagePosition) – the specific int or relation PagePosition location for new page

  • name (str) – name of new page (note this may be altered if name already exists)

Returns:

the newly created page

get_page_by_name(name: str)

Get page from VisioFile with matching name

Parameters:

name (str) – The name of the required page

Returns:

Page object representing the page (or None if not found)

jinja_render_vsdx(context: dict)

Transform a template VisioFile object using the Jinja language The method updates the VisioFile object loaded from the template file, so does not return any value Note: vsdx specific extensions are available such as {% for item in list %} statements with no {% endfor %}

Parameters:

context (dict) – A dictionary containing values that can be accessed by the Jinja processor

Returns:

None

remove_page_by_index(index: int)

Remove zero-based nth page from VisioFile object

Parameters:

index (int) – Zero-based index of the page

Returns:

None

save_vsdx(new_filename=None)

save the VisioFile object as new vsdx file

Parameters:

new_filename (str) – path to save vsdx file

vsdx.VisioFile.Page

vsdx.VisioFile.Shape

vsdx.VisioFile.Cell

vsdx.VisioFile.Connect