필터 지우기
필터 지우기

Drawing Visio diagram using MATLAB 2018b

조회 수: 27 (최근 30일)
harika kurra
harika kurra 2020년 6월 1일
댓글: Adam Danz 2021년 7월 28일
I have been trying to draw an IO diagram in MS Visio using actxserver function of Matlab(2018b).
I am able to open Visio application and draw a rectangle with text in it using the folllowing code:
appVisio = actxserver('Visio.Application');
appVisio.Visible =1;
doc = appVisio.Documents.Add("Basic Diagram.vst");
pagObj = doc.Pages.Item(1);
stnObj=get(appVisio,'Documents','Basic Shapes.vss');
mast_circ = get(stnObj,'Masters','Rectangle');
pagObj.Drop(mast_circ, 5,5);
But I cannot get the position coordinates of rectangle drawn. If I would get the position coordinates of the rectangle drawn, I can draw the arrows to and from the rectangle showing the inputs and outputs of the block represented by the rectangle.
Note: I am using Microsoft VIsio 2007 and MATLAB 2018b
  댓글 수: 1
Adam Danz
Adam Danz 2021년 7월 28일
With all the software out there that produces these types diagrams, what is the motivation to do this in matlab?
I've been using drawio for a few years. It's free, simple, and fairly flexible. I recommend using that.

댓글을 달려면 로그인하십시오.

답변 (1개)

Luis
Luis 2021년 7월 28일
I was looking for something similar, and came to this example
I wrote a similar example for matlab using the actxserver. To manage the coordinates, it computes the center and top of the page, and then adds shapes based on that origin. I hope it helps
clear;
% Application
appVisio = actxserver('Visio.Application');
appVisio.Visible =1;
% Document
doc = appVisio.Documents.Add("Basic Diagram.vst");
% Page
pg = doc.Pages.Item(1);
% Get the center, top of the page:
pg_cent = pg.PageSheet.CellsU("PageWidth").ResultIU / 2
pg_top = pg.PageSheet.CellsU("PageHeight").ResultIU - 1
% Stencil
stnBasic=appVisio.Documents.OpenEx('Basic Shapes.vss',false);
stnConn=appVisio.Documents.OpenEx('Connectors.vss',false);
stnFlow=appVisio.Documents.OpenEx('BASFLO_M.vssx',false);
% Masters for process and decission
mstProcess = get(stnFlow,'Masters','Process');
mstDecision = get(stnFlow,'Masters','Decision');
conn = get(stnConn,'Masters','Dynamic connector');
%% Example 1: Two elements, one connector
a=pg.Drop(mstProcess, pg_cent,pg_top); %inches from lower left corner
a.Text = 'a';
b=pg.Drop(mstProcess, pg_cent,pg_top-1);
b.Text = 'b';
c=pg.Drop(conn, 0,0);
% Glue to the right side:
c.CellsU('BeginX').GlueTo(a.CellsU('PinX'))
c.CellsU('EndX').GlueTo(b.CellsU('PinX'))
%% Example 2: several elements
dy = .75;
for i = 0:5
new=pg.Drop(mstProcess, pg_cent+2,pg_top-i*dy); %inches from lower left corner
new.Text = sprintf('%d',i);
if i>0
c=pg.Drop(conn, 0,0);
% Glue to the right side:
c.CellsU('BeginX').GlueTo(last.CellsU('PinX'))
c.CellsU('EndX').GlueTo(new.CellsU('PinX'))
end
last = new;
end

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by