News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Edit a master shape using C#

Started by razydroid, December 29, 2012, 06:10:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

razydroid

Hi All,

I am new to Visio & C#. I am trying to create a visio document & add a master shape from a stencil. The shape is a group of 4 rectangles. I want to know how can I get each element in this group programatically using C#.

So far I am able to bring the shape to the Visio file. But Since its a group I am not able to get any property of the individual elements in that group. I want to set text for each rectangles with different values.

So far my code looks like the following.


Visio.Document doc = application.Documents.Add(@"\example.vst");
Visio.Page page = application.Documents[1].Pages[1];
Visio.Documents vdocs = application.Documents;
Visio.Document visioStencil = vdocs.OpenEx(@"\sample.vss", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);
Visio.Page visioPage = application.ActivePage;
Visio.Shapes visShapes = visioPage.Shapes;
//the following shape in the setensil is the group of 4 rectanle I was referring
Visio.Master visioConvMaster = visioStencil.Masters.get_ItemU(@"Conveyance");
Visio.Shape visioConvShape = visioPage.Drop(visioConvMaster, 4.25, 5.5);
//try to ungroup to get each -- but this also not helping.
visioConvShape.Ungroup();


Any idea how I should proceed further? If I could get the individual elements from this group or some way if I can iterate throught the master shape, then i should be able to read & set the values for each element . I am using Visual Studio 2012 professional & Visio 2010 Premium

Thanks in advance. 

Paul Herber

Rule 1: never ungroup!

Get the group shapes count from visioConvShape.Shapes.Count
Iterate through them as visioConvShape.Shapes[n]
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 154 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1078KB.
Tokens: post-login.
Cache hits: 12: 0.00103s for 26,766 bytes (show)
Cache misses: 1: (show)
Queries used: 14.

[Show Queries]