Why Masters get duplicated in the document stencil?

Started by Yacine, May 19, 2017, 04:58:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

I did observe that some of the masters I drop from stencils onto my drawings get duplicated in the document stencil.
Whilst the duplication is not a big issue per se, when you want to modify the master so the already dropped shapes get modified as well you get a problem. You will need to modify each instance in the document stencil.

Any idea why this is happening and how I could avoid it?
Yacine

wapperdude

Bet you didn't expect me to reply...no, I'm still at V2007.  But, which version?

By any chance have you made any previous modifications?  Perhaps Visio thinks there's been a change between the source stencil master and the document stencil master?

I'll go back to my rocking chair now.

Cheers.
Wapperdude
Visio 2019 Pro

Yacine

This happens both in V2007 and V2013.
The instances of the masters (the shapes dropped) get formatted and modified, but I never touch the masters in the doc stencil.
What happens however, is that the document gets edited without the stencils being loaded. So I open the stencils afterward. Perhaps Visio interprets these stencils not by their names but kind of sessions IDs?
Yacine

Croc

As it seems to me, Visio does not rely on names, but on the UniqueID of the masters.
Each master has a UniqueID.
If the UniqueID of the master in the external stencil and in the document stencil do not match, Visio will place a new master in the document stencil.
If a master with this name already exists, a new name with a dot is created.

Yacine

Would this imply that the unique ID is created dynamically??? (My stencils don't change)
Yacine

Croc

Maybe there were some implicit, unintended  changes. For example, renaming a stencil. Or adding program code to the stencil ...
I do not know in which cases Visio changes the UniqueID of the master-shape. But without a reason, it should not do this.

Nikolay

#6
Quote from: Yacine on May 20, 2017, 08:28:28 AM
Would this imply that the unique ID is created dynamically??? (My stencils don't change)
Please note that this applies to both document stencil and "external" stencil.
Means, if you edit a master in the document stencil, Visio will also change it's "UniqueID".
Then when you drop a master from external stencil (with old id), UniqueIDs will mismatch (because the new one in the doc stencil already has a new one), and you'll get a new master in the document stencil.

Means basically this behavior is correct, and makes sense, given that you want to be able to still open diagram when stencil used to create it is not available. However the problem is how to keep all diagrams consistent. I have seen many customers who wanted to edit a master in a stencil, and then update all diagrams to use that new shape. For example, they change "corporate color" according to the new marketing department idea, and now on all diagrams the shapes they use (custom shapes) should  have slightly different tint of red (means, all of those 500 old diagrams they have created over the time of the last 10 years should be auto-updated). And yes, one more thing - now on all diagrams there should be a logo in the top-right corner in the form of a kitten :)

As of my understanding, Visio suggest to deal with this with themes. But the problem is, that it's next to impossible for an average user to create custom shapes that properly support themes. Well, they just draw the way they can.. Asking to support themes is like asking to study astro-navigation. Even on this forum, we regularly get questions like "why my shape changes when I upgrade to 201x" or "how do I protect a shape from themes". What's more important, not every aspect of a shape can be controlled by themes - what if (for example) I want my shape to have some additional geometry items, like lines or circles, or what if I want to change some formula logic..

In P4B, where I worked before, that was solved with "diagram update wizard". That "wizard" when run basically replaced all (or named) shapes on all customer's diagrams with their "newer" versions from the given stencils. This is actually unbelievably hard- think of keeping shape connections (different set of connection points in the "newer version" for example, connectors that tend to re-route wildly), keeping z-order, position (think you have "3 circles" instead of "one flat rectangle"), custom properties/user data, keeping data recordset bindings, auto-sizing pages and bloody swim-lane containers, etc, etc. I would say that is one hell of a work - for some modifications (turn 2-d square into an 1-d arrow - real life example) it may be even impossible to properly "update", one can just go with "good enough".

The magic user expects - you edit a master shape in a stencil, then from the right-click menu select "update everywhere", and - boom - it gets updated in current, and all other diagrams, where it's used - does not seem to be always possible. "Replace shape" introduced in Visio 2013, unfortunately does not solve the problem - "mass automatic update" from stencils.

Yea, there is one more solution to avoid duplication, an easy one: do not edit stencils :)
Or you can "fake" it (make Vision forget about modifications) - open file as plain-text XML, and reset the UniqueID property to what you want it to be.

Another option, more reasonable - script your changes for a single shape, and they apply that "update script" to every shape/diagram, instead of directly modifying the master

wapperdude

#7
Interesting... just did quick test.
1>Placed a triangle shape on drawing.  Duplicated.  Doc Sten (DS) shows Triangle
2>Edit shape on drawing (color, line wt, etc).  Duplicate.  DS still shows just Triangle
3>Drop new triangle from Basic Shapes onto drawing.  DS still unchanged.
4>Edit DS triangle master.  Update.  Shapes from 2> not affected.  Shape from 3> updated.  Note, DS still has just the 1 master.
5>Drop new triangle from BS stencil onto drawing.  DS now has two masters: Triangle, Triangle.2

I thought editing a doc shape would have triggered a new master in the DS.  Apparently not.

Wapperdude.

Edit update:
6>Saved and exited Visio, restarted Visio and opened doc.  DS now shows:  Triangle, Triangle.6  The shape from step 5> was the 6th instance of triangle shape on the drawing page.
Visio 2019 Pro

Nikolay

#8
Quote from: wapperdude on May 20, 2017, 02:26:32 PM
I thought editing a doc shape would have triggered a new master in the DS.  Apparently not.

As far as I know, it shouldn't have - that what the masters are for, no? One master in DS can be used for multiple shapes, right - the shapes contain only "difference" from the master (so that Visio does not need to save every property of every shape, but just differences to the master). That reduces file size and allows you to change all "instances" by editing master in DS.

But- if some property (ex: fill color) has been already explicitly set in the instance, editing it in the master won't have any effect on the shape where it was changed, but will update all other shapes where it was not.

Check is easy:
- drop two triangles. Paint one red
- modify master in the DS (set fill color to blue). Only one triangle on the drawing will change color to blue. The other one stays red.

Technically, there is a "bit" per the ShapeSheet cell, that indicates if cells really has value in the shape. If the cell does not have value, then for calculations Visio takes the value from shape's matching master cell. When you edit master, visio does not physically update any "instance" shape (it just literary updates master). The "instance" shapes change their appearance not because they got really modified, but just because of this logic - "no value - take master".

Interestingly, ShapeSheet explicitly shows cells which were overwritten in the shape using blue text color (ones that come from the master are black)

Yacine

Thank you all for your contributions, but ... YEAH, CHAKAAA, I found it!

Though it was well hidden: https://msdn.microsoft.com/en-us/library/office/ff766298.aspx

When you prepare a master in a standalone stencil, RMC on the master, chose EDIT MASTER ... MASTER PROPERTIES and set "Match master by name on drop" to checked.
Now - having a "modified" master in the doc stencil - when you drop the master from the external stencil, the one in the doc stencil is used as master and the master is not recreated.

Note this may lead to confusing results: I renamed the triangle master to square, then dropped the square master from the external "Basic Shapes" stencil on the drawing and got instead the triangle from my doc stencil. Basically that's exactly what I wanted.

Thanks again at all,
Y.

PS: will probably need to batch modify all the masters in my external stencils now.
PPS: If the master is a single shape, replacing it will generate a new instance of the master. If the master is a group, then you can freely replace sub-shapes or create new ones.
PPPS: changing a master from 2D to 1D will also trigger the generation of a new master.
Yacine

Nikolay

#10
Actually this flag may  be "considered harmful" :)
If you set it, Visio will never update master in the drawing, even in case when the master in the stencil is updated.
It will just use the one from the drawing (matching by name)

This may lead to a confusing behavior, when you edit a master in the stencil, then drop it,
and then - boom- a completely different shape got dropped (or the old version, like you haven't edited it) :)

Yacine

#11
I agree with you.
In my personal case, where I very seldom modify the masters of the doc stencils, but need to handle the fact that the doc will often be opened with and without the external stencil, this is probably the best solution I can get for free.

I did already consider the solutions you named:
- XML --> ugly because it requires to be done "outside" the doc. On the other hand, possibly the robustier solution. --> lot of work.
- M$'s shape replacement. Well, I get some crashes from time to time and it does not handle 1D/2D conversions. Otherwise it's a declared standard and probably worth investigating more in depth.
- replacement script. Probably the best solution so far. But no real batch, rather a shape by shape "slower" conversion.

Desired, but not supported: the over-writing of the .master property of a shape.

PS: The kitten is a very classical one. Knew it already, but enjoyed watching again. Thx.
Yacine