Hello Philip
Here is an example I use to test to add a page in Visio.
Hope it can help
Göran
#Need to install requests package for python
import requests
import json
import jpype
import inspect
from jpype import java
import asposediagram
jpype.startJVM()
from asposediagram.api import *
import the License class
from asposediagram.api import License
license = License()
license.setLicense(“Aspose.Diagram.Product.Family.lic”)
visiostencil = “bpmn.vsdx”
with open(“bpmn.vsdx”, “rb”) as f:
bpmn = Diagram.createDiagramFromBytes(f.read(), loadOptions=LoadFileFormat.VSDX,LayoutDirection=LightRigDirectionType)
Create the Visual file
Create a filer called SNBPMN.vsdx from a template called BPMN.vsdx
Teh file BPMN.vsdx is a template file that contains the BPMN shapes and a process flow template.
def create_visual_file():
bpmn.save(“SNBPMN.vsdx”, SaveFileFormat.VSDX)
# end of function
#
Create a new page in Visio
Create a new page in the file SNBPMN.vsdx
The page is created from the template BPMN.vsdx
def create_new_page(newpage):
print (newpage)
# Create a new page
# Set the name of the new page
bpmn.getActivePage().setName(newpage)
# Add the new page to the collection
bpmn.getPages().add(newpage) # gives the error
# Save the Visio diagram
bpmn.save("SNBPMN.vsdx", SaveFileFormat.VSDX)
def create_visual_shape():
bpmn.addMaster(visiostencil, "Start Event")
bpmn.addShape(2.0, 2.0, "Start Event", 0)
bpmn.addMaster(visiostencil, "Pool / Lane")
#bpmn.addShape(0.0,0.0, "Pool / Lane", 0)
bpmn.addShape(4.0,2.0, "Gateway", 0)
bpmn.addMaster(visiostencil, "Task")
bpmn.addShape(6.0, 2.0, "Task", 0)
bpmn.save("SNBPMN.vsdx", SaveFileFormat.VSDX)
snbm = create_visual_file()
test =“rrrr”
snbmn = create_new_page(test)
snbmn = create_visual_shape()