Author Topic: Is there a quick way to make the same change to multiple ShapeSheets?  (Read 21135 times)

0 Members and 1 Guest are viewing this topic.

haggis999

  • Jr. Member
  • **
  • Posts: 22
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #15 on: June 02, 2013, 03:55:03 AM »
After some searching, I found out that if I changed the .vsdx filename extension to .zip I could then view the XML contents using software called EditPad Pro 7 (I don't know where that came from) or in Visual Studio 2012.

While inspecting the XML code, it seemed that making selective font size changes would be very difficult. I could not see how I could find only the font size settings for a specific set of textboxes on a complex Visio page. I therefore went back to Visio and moved the relevant items to a separate page. I also made sure that all my existing textboxes had exactly the same font size.

I then did a search and replace on the XML file as follows (the new text was based on the result of one of my previous manual changes):

ORIGINAL TEXT:    <Cell N='Size' V='0.05555555555555555' U='PT'/>

REPLACED TEXT:   <Cell N='Size' V='0.04134486114774413' U='PT' F='5PT*ThePage!PageScale/ThePage!DrawingScale*Height/0.177'/>
 
I then saved this XML file, renamed my .zip back to .vsdx and reopened it in Visio. Unfortunately, none of my textboxes on the affected page had been updated to use my formula! I will try again tomorrow...

David

Before attempting to pursue a potentially more complex VBA-based solution, I made another attempt to use the above referenced procedure. This time it worked!

I had been editing the relevant page XML file while it was still stored inside a zip file. When I saved this modified page a WinZip dialogue box popped up asking me to confirm that I wished to update the zip file with my changes. I hadn't seen this popup during my first attempt to edit the XML code outside Visio, probably because there was a small delay before it appeared and it was obscured by a lot of other open windows.

David

JohnGoldsmith

  • Sr. Member
  • ****
  • Posts: 349
    • John Goldsmith's visLog
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #16 on: June 02, 2013, 04:29:38 AM »
Bear in mind also that not all changes to the file will be reflected in the drawing after a change.  Have a look at this post (tip 5) which deals with forcing recalculation:

http://blogs.office.com/b/visio/archive/2013/01/29/10-tips-for-developers-working-with-the-visio-vsdx-file-format.aspx

Best regards

John

[Update - sorry, just noticed that @kennyj posted that link already]
« Last Edit: June 02, 2013, 04:31:09 AM by JohnGoldsmith »
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

haggis999

  • Jr. Member
  • **
  • Posts: 22
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #17 on: June 02, 2013, 05:09:09 AM »
Yes, I had already read that warning, which seemed to suggest a potential need to delve deep into various complicated coding scenarios.

However, in one of the associated references I read the comment "you can often change a shape's text without needing to recalculate the document". This seems to be the situation in my case, as my external edits to replace a fixed text size with a formula for text size all appear to have been implemented immediately in my Visio drawing.

David   

haggis999

  • Jr. Member
  • **
  • Posts: 22
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #18 on: June 02, 2013, 06:28:36 AM »
I am rather confused by the differences between the Character section of a ShapeSheet as viewed within Visio and what I am assuming is the matching Character definition in the associated XML page file.

For example, a simple textbox containing a single character I have set to 12pt Arial Narrow in Visio contains the following data in the Character section of its ShapeSheet as viewed via Visio:
Character0
Font4
Size12 pt
Scale100%
Spacing0 pt
Color0
TransparencyNo Formula
Style0
Case0
Pos.0
StrikethruFALSE
DoubleULineFALSE
OverlineFALSE
DoubleStrikethroughFALSE
AsianFont0
ComplexScriptFont0
ComplexScriptSize-100%
LangID2057


In contrast, the XML code for this same Character section is as follows:
<Section N='Character'><Row IX='0'><Cell N='Font' V='Arial Narrow'/><Cell N='Size' V='0.08517847225260369' U='PT'/></Row></Section>

Can anyone explain why these descriptions are so different? In particular, I am interested in how a 12 pt setting is converted into a size value of 0.08517847225260369.

David

Yacine

  • Hero Member
  • *****
  • Posts: 2708
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #19 on: June 02, 2013, 06:13:42 PM »
Quote
I'm sure your kids will understand the need to lock them up while you get on with such important work  :)
  :o ;D ::) ;D
Yacine

JohnGoldsmith

  • Sr. Member
  • ****
  • Posts: 349
    • John Goldsmith's visLog
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #20 on: June 03, 2013, 04:05:10 AM »
Hello David,

The difference that you're seeing between the number of properties (cells) in the ShapeSheet and the small number of corresponding elements in the xml reflects how Visio makes use of inheritance. 

If you look at the ShapeSheet image below you'll see the Font and Size cells are blue and the rest are black.  Blue represents a local formula and black an inherited one.  So remember that the xml file is just a way of persisting the data and so only the local formulae are present in the page shape xml. 

You'll find the values for the rest of the cells in other locations in the package depending on where the shape is inheriting that cell from.  This might be from a master or a style.  If it's the former then it will be in the respective master_n.xml file under Package(zip)/visio/masters and if it's a style then it will be in document.xml under Package(zip)/visio (see the stylesheets element). 

Bear in mind that a shape can inherit from a master which may also inherit some of its values from a style and, since styles can inherit from other styles, potentially other styles further up the tree.

In code, you can test whether a particular shape's cell is local or not by accessing the Cell.IsInherited property and there's an equivalent ShapeSheet function called LOCALFORMULAEXISTS.

In terms of why the 12pt value get's persisted as a decimal number, this is because Visio uses inches internally  as its default unit and 12pt = 0.08517847225260369, or there abouts.  You can see that the U attribute keeps a note of the actual units displayed in the ShapeSheet.

Returning to your original question though, I would have thought that code would be a better approach.  How many unique shape types are you dealing with?  Do you have one AV amplifier type and then multiple copies?  Are you likely to reuse the shapes?

Do you have a sample document possibly including the Illustrator file you could share?  Either as an attached file or email if you'd prefer not to broadcast it.

Hope that helps.

Best regards

John
 
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

haggis999

  • Jr. Member
  • **
  • Posts: 22
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #21 on: June 03, 2013, 07:45:44 AM »
...Visio uses inches internally as its default unit and 12pt = 0.08517847225260369, or thereabouts... 


Hi John,
Only 17 places of decimals? With such a casual approach to accuracy, I doubt if you could ever hang a picture straight  :).

That aside, many thanks for providing that very useful clarification. I'm off on holiday very soon and may not have much time to play with Visio before I leave (my wife doesn't have computing issues high on her list of priorities over the next few days). However, I will delve a little deeper on my return.

David

JohnGoldsmith

  • Sr. Member
  • ****
  • Posts: 349
    • John Goldsmith's visLog
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #22 on: June 03, 2013, 09:48:19 AM »
My pleasure.

I'll have you know that not one of the pictures in my house is straight, at least that what my micrometer says.  :)

If you're off on holiday then now is the perfect time to convince your wife of the positive impact that Visio can have on your life and of course there's lots of great books she can read while relaxing.

Enjoy your holiday.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: Is there a quick way to make the same change to multiple ShapeSheets?
« Reply #23 on: June 05, 2013, 05:13:33 AM »
I hope this document may be a help.
"How to: Manipulate the Visio 2013 file format programmatically"
http://msdn.microsoft.com/en-us/library/office/jj649391%28v=office.15%29.aspx
Best Regards,

Junichi Yoda
http://june.minibird.jp/