Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: Visisthebest on February 09, 2023, 01:02:31 PM

Title: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Visisthebest on February 09, 2023, 01:02:31 PM
For turning off Themes, in Visio 2019/2021 I cannot find this option anymore:
https://superuser.com/questions/1109937/how-can-i-remove-a-theme-from-one-shape-of-many-in-visio-2016

However I did stumble on to this different turn-off-the-theme-on-a-shape option, from the documentation from the ISTHEMED() SS function, I understand that setting ColorSchemeIndex = 0 (in the Theme section of the SS), a theme can be completely turned off on a shape.

This works fine and turns off more than just the colors of a theme (also the other styling).

I wonder if this has performance benefits for large diagrams, just completely turning off Themes on shapes that don't need them. Not having to process a shape for where to apply a theme conceivably saves significant CPU time.
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Surrogate on February 09, 2023, 02:09:31 PM
Quote from: Visisthebest on February 09, 2023, 01:02:31 PMHowever I did stumble on to this different turn-off-the-theme-on-a-shape option, from the documentation from the ISTHEMED() SS function, I understand that setting ColorSchemeIndex = 0 (in the Theme section of the SS), a theme can be completely turned off on a shape.
In which of the cells of the ShapeSheet you use this function?
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Surrogate on February 09, 2023, 03:26:27 PM
Quote from: Surrogate on February 09, 2023, 02:09:31 PM
In which of the cells of the ShapeSheet you use this function?
I find answer 8)
(https://i.imgur.com/iklckN2.png)
Quote from: Visisthebest on February 09, 2023, 01:02:31 PMI wonder if this has performance benefits for large diagrams, just completely turning off Themes on shapes that don't need them. Not having to process a shape for where to apply a theme conceivably saves significant CPU time.
IMHO Themes are evil (https://visio.getbb.ru/images/ranks/visio_getbb_ru/huh.gif)!!! The best way is not to use them at all.
(https://habrastorage.org/getpro/habr/upload_files/89e/0f9/ef5/89e0f9ef5976bf23f00943e250fb5d8f.gif)This picture from my article How to deal with "themes" in MS Visio (https://habr-com.translate.goog/ru/post/697172/?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=ru&_x_tr_pto=wapp) drawing
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: wapperdude on February 09, 2023, 05:38:33 PM
This seems to work:  under developer tab> protection => select all the themed entries.

The suggested approach of this topic has a caveat: you need to wrap the value "0" with the guard function.  Note, I only changed the ThemeIndex cell in the shapesheet.
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: wapperdude on February 09, 2023, 09:07:43 PM
A little more investigation reveals:
1)  Locking down the ThemeIndex does not prevent line oriented variations.
2)  To prevent effects changes, the EffectSchemeIndex must also be set to "0".
3)  These changes can be made either in the shape or page shapesheets.
4)  There doesn't seem to be any such entries available in document shapesheet.
5)  Of course there is no such settings at the document level.
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Visisthebest on February 09, 2023, 10:13:24 PM
Excellent investigation Wapperdude, good idea to use GUARD(0) to protect against those evil themes and good to know EffectSchemeIndex also needs to be set to GUARD(0) to protect shapes against theming a user is trying to force on the shape!
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Surrogate on February 09, 2023, 10:16:11 PM
Quote from: wapperdude on February 09, 2023, 09:07:43 PM
A little more investigation reveals:
Three years ago I made many attempts to prevent the application of theme effects to my stencils, the sub-shapes they consist of must always be black and white.
I was helped by the description in this article (https://gist-github-com.translate.goog/Surrogate-TM/895f7464016981182c9467e0f51a3eed?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=ru&_x_tr_pto=wapp#file-themeprotection-md) by Croc (http://visguy.com/vgforum/index.php?action=profile;u=11866).
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: wapperdude on February 10, 2023, 01:18:55 AM
I was somewhat surprised that setting the lock protection worked.  I vaguely remember that there were issues.  But, now when I tried it those settings did work.   :o  That's why I included a file with my last post.  At a minimum, the file provides a means to check out what may or may not work.   Hopefully I didn't do anything wrong.  Testing was intended to be reasonable, but not exhaustive.  This was done on a 64B, Win11, Home Ed laptop.  I did not check it on Win10,  64B  desktop.

Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Surrogate on February 10, 2023, 09:36:40 AM
Quote from: wapperdude on February 10, 2023, 01:18:55 AMThat's why I included a file with my last post.  At a minimum, the file provides a means to check out what may or may not work.
At my side:
Win10, 64B, Visio 2019 Professional
(https://user-images.githubusercontent.com/35092915/218055818-bfef8852-26d0-407c-a9ae-1a651f2d842f.gif)
Line colors are different for different themes: black/grey/brown/etc !
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Surrogate on February 10, 2023, 09:43:57 AM
Quote from: Surrogate on February 10, 2023, 09:36:40 AMLine colors are different for different themes: black/grey/brown/etc !
Just modify your shape
(https://i.imgur.com/KCaEIbr.png)
Now line color dont changed !!!
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Visisthebest on February 10, 2023, 11:24:07 AM
The search for anti-theme teflon settings continues, in the mean time happy with the understanding how to remove theme application off a shape, even if it may be very hard / impossible to prevent a user from reapplying a theme.
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: wapperdude on February 10, 2023, 04:45:48 PM
Fascinating!  I've updated the file to separate the shape based protectionBoth pages have a bent arrow that is drag and dropped.  Same for the 3rd page which uses page settings.  The expectation is the bent arrow will have theme based properties on 1st page, but not on 3rd.

Interesting note to page 3.  I did copy/paste of the 1st page arrow to the 3rd page.  After dropping and arrow still selected, the arrow did respond to page changes.  I do not believe the new page properties had been applied.  Once I deselected and re-selected, the new properties became effective and behavior was as expected.

Bottom line, I don't experience any of the misbehavior that Surrogate has encountered.  Guess I need to try out my Win10 PC.

It would be nice hear from others as to what they experience... My expectation is most will have same result as Surrogate has.  But it would be nice to build a misbehavior profile...impact of Win10 vs Win11, 32 bit vs 64,  what about different Visio verions including the subscription based releases.

You can use my file.  No editing necessary.  Just flip between pages and apply themes.  Either there are changes or not. 
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Visisthebest on February 10, 2023, 05:36:39 PM
Wapperdude I tried your file this does provide an anti-theme teflon coating on the shapes just one thing is missing: also put GUARD(0) in ColorSchemeIndex in the shape, then applying a shape is completely blocked on my Win10 Visio 2019 and 2021 PC's!
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: wapperdude on February 10, 2023, 07:21:40 PM
OK.  Tried this on my desktop, still see proper behavior.  Without doing anmy editing, absolutely no Theme influence except where expected.

Computer:  Win10 Home, 64B.  Same Visio edition as laptop:  V2019 Pro.

Guess I'm just special!   ???  ::)   ;D
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Visisthebest on February 10, 2023, 07:39:20 PM
Wapperdude I have the same behavior, but only one difference compared to your PC: if I do not also put GUARD(0) in ColorSchemeIndex, then the color still changes when I switch themes, but the other styling is blocked just like on your PC.
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: wapperdude on February 11, 2023, 12:21:43 AM
@Visisthebest: Yep.  I understand and understood.  My remark was to confirm that I did not have to do your extra step.  For me, the variation in this behavior for the various responders is very strange.  Historically, the performance has been more like what Surrogate and Croc observe.  I'm surprised it mostly works for you.  The concern is how reliable is this approach?  It strikes me as being less than robust.  At this point, I'd say, "User beware!"
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: Croc on February 11, 2023, 03:45:49 PM
QuoteThe search for anti-theme teflon settings continues, in the mean time happy with the understanding how to remove theme application off a shape, even if it may be very hard / impossible to prevent a user from reapplying a theme.
...prevent a user from reapplying a theme?
I think you can try to hide the theme buttons from the user. No button - no themes :)
Of course this is not a 100% solution, but it should make reapplying a theme more difficult.
Look at this VBS script
UIFile = "C:\Work\RibTheme\NoTheme.xml"
VisFile = "C:\Work\RibTheme\NoTheme.vstx"
'
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile(UIFile,1)
xml = file.ReadAll
file.Close
Set app = CreateObject("Visio.InvisibleApp")
Set doc = app.Documents.Open(VisFile)
doc.CustomUI = xml
doc.Save
app.Quit
and such XML
<mso:customUI xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui">
<mso:ribbon>
<mso:tabs>
<mso:tab idQ="mso:TabDesignVisio">
<mso:group idQ="mso:GroupThemesVisio"
           visible="false"/>
<mso:group idQ="mso:GroupThemeVariants"
           visible="false"/>
</mso:tab>
</mso:tabs>
</mso:ribbon>
</mso:customUI>

This script will remove GroupThemes and GroupThemeVariants from the Visio template. After that, all documents based on this template will not have buttons for changing themes.
A similar effect can be obtained through the Visio Options / Customize Ribbon menu. But then the effect will apply to all Visio drawings. In contrast, the above script only acts on the given template or the given document.
Title: Re: ColorSchemeIndex = 0 is application of themes completely turned off on shape?
Post by: wapperdude on February 11, 2023, 06:54:06 PM
As with all things associated with themes, there are a couple of gotchas.

Merely saving a file with Themes removed from Ribbon will note pass along that inheritance.  Removing Themes from the Ribbon using embedded code is intrusive to other user systems.  Restoring Themes to Ribbon via standard interface, subsequently makes them a customization NOT identical to the original default configuration.

The Ribbon approach seems more ideally suited for personal use, and undesirable as a distributed feature.