Use .vss stencil file to generate shapes by python code (use .vdx?)

2024/10/6 18:24:59

I want to have my python program generate visio drawings using shapes from a stencil (.vss) file. How can I do that? I think I could generate the xml formatted .vdx file, but there isn't a lot of documentation on the .vdx format.

EDIT: the computer has visio installed.

Answer

If you have Visio installed, then you can use Visio API and Python CLR or COM bindings to make it do the things for you. Here are some similar SO questions (visio and python):

Reading the contents of Microsoft Visio (2010) doc in IronPython

Cannot open Visio document with Python

Check out Visio SDK and the free "Developing Visio Solutions" book in MSDN to start with.

Anyways, some code to start with (opens a standard "basic shapes" .VSS stencil then drops a rectangle shape and then saves as .VDX):

import win32com.clientvisio = win32com.client.Dispatch("Visio.Application")
doc = visio.Documents.Add("")
stn = visio.Documents.Open("BASIC_M.VSS")page = doc.Pages.Item(1)master = stn.Masters.Item("Rectangle")
rect = page.Drop(master, 0, 0)doc.SaveAs("C:\\<some directory>\\file.vdx")
doc.Close()visio.Quit()
https://en.xdnf.cn/q/118919.html

Related Q&A

How can I capture detected image of object Yolov3 and display in flask

I am working on Real Time Object Detection using YOLOv3 with OpenCV and Python. Its works well. Currently I try to capture detected image of object and display in flask. Do someone know how to implemen…

ValueError: Shapes (2, 1) and () are incompatible

I have to use Tensorflow 0.11 for this code repo and this is the error I get:(py35) E:\opensource_codes\gesture_recognition\hand3d-master>python run.py Traceback (most recent call last):File "r…

Subtotals for Pandas pivot table index and column

Id like to add subtotal rows for index #1 (ie. Fruits and Animal) and subtotal columns for columns (ie. 2015 and 2016).For the subtotal columns, I could do something like this, but it seems inefficient…

Create two new columns derived from original columns in Python

I have a dataframe, df, that contains two columns that contain quarter values. I would like to create two more columns that are the equivalent "long dates". Data ID Quarter Delivery A …

In dataframe: how to pull minutes and seconds combinedly(mm:ss) from timedelta using python

i have already tried these but by this we can only get hour/minute/second but not both minute and second In[7]: df[B] = df[A].dt.components[hours] df Out[7]:A B0 02:00:00 2 1 01:00:00 1from this tim…

Understanding python numpy syntax to mask and filter array

Please help me understand how the lines below are working.How does a pair of parentheses create an array and then individual elements go through logical condition check and create a new array? How doe…

How to get the proper link from a website using python beautifulsoup?

When I try to scrape roster links, I get https://gwsports.com/roster.aspx?path=wpolo when I open it on chrome it changes to https://gwsports.com/sports/mens-water-polo/roster. I want to scrape it in p…

tkinter frame propagate not behaving?

If you uncomment the options_frame_title you will see that it does not behave properly. Am I missing something? That section was just copied and pasted from the preview_frame_title and that seems to h…

python modules installing Error Visual c++ 14.0 is required [duplicate]

This question already has answers here:pip install ecos errors with "Microsoft Visual C++ 14.0 is required." [duplicate](1 answer)Error "Microsoft Visual C++ 14.0 is required (Unable to …

How to render Flask Web App with Javascript [duplicate]

This question already has answers here:Return JSON response from Flask view(15 answers)How to append ajax html response to next to current div(5 answers)Closed 5 years ago.Edit: Hi Ive checked the dupl…