Chapter-2- Visio automation with Python-Code

Chapter-2


In chapter-1 we discussed on the relevant audience and available solution for Visio design, in this chapter we will see some code and it's output. Please don't get upset if below code doesn't work on your system. I would request you to keep your patience and continue your reading and you will learn how to make below code work.

Example-1.0

from hld_exp import Visio
visio = Visio()
app = visio.open('Visio')
doc = visio.documents('Basic Diagram.vst')
stn = visio.stencils('HP Devices updated.vssx')
mstobj = visio.mastobj('HP 5900 AF')
page = visio.selectpage(1)
coresw1 = visio.drawobject(mstobj,4.0,6.0)
coresw2 = visio.drawobject(mstobj,8.0,6.0)
active = visio.activedocument().Masters(1).Name
contool1 = visio.connect()
connect1 = page.Drop(contool1,0,0)
connect2 = page.Drop(contool1,0,0)
connect1.Cells('BeginX').GlueTo(coresw1.Cells('PinX'))
connect1.Cells('EndX').GlueTo(coresw2.Cells('PinX'))
visio.close('HP Devices updated.vssx')

With help of above code following diagram was drawn on Visio.

Figure 1.0


We will discuss the code in upcoming chapters.

Comments

Popular posts from this blog

Chapter-3 Visio automation with Python-Code

Chapter-1 Visio automation with Python