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

Shape color based on Shape data value

Started by Nlevesque, February 28, 2024, 06:59:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nlevesque

Hi Guys. I have been using Visio for a couple years but I don't know anything about coding. About everything I can do with shapesheets I learned here.

I've been trying for a couple of days to have a shape that's part of a group to change it's color based on the value of a shape data in the group. The shape data in questions is a variable list with five possible values to it. Those values are: LAN, POE LAN, WAN, 1G adn 10G. Here's what the groupe Shapesheet formula looks like:



Now on the shape I want to change colors, I created both a table of the 3 colors I want and a set of conditionals that would be supposed to set the forground color of the shape based on that statut of the groups shape data. Here's what the shapesheet looks like.



It seems to me like the validation of the value of the variable list doesn't work. If so, how can I fix it.

Thanks in advance, desperate for answers.

The problem is that, of course it doesn't work" tried to pinpoint what part of the setup doesn't work. I even created in the group shapesheet a simple conditionnal that supposed to change it's value to 1 if the variable list shape data is a specific value and change it to 2 if it's not and it still dosen't work.

Surrogate

#1
Quote from: Nlevesque on February 28, 2024, 06:59:06 PMI have been using Visio for a couple years but I don't know anything about coding. About everything I can do with shapesheets I learned here.
Please look at same thread.

UPDATED: 3 hours ago...
Please read acticle Indexed colors across languages in Visio by John Goldsmith.

Thomas Winkel

#2
And here an example as I do it in my shapes.
Simple and maintainable using lists with INDEX / LOOKUP.
The SUBSTITUTE / LISTSEP is necessary because Visio`s list separator depends on the language (e.g. ',' ';'), also see Surrogates link.

Yacine

@Thomas,
you can further improve your solution by putting the semi-colon separated lists in props of the page. This way you can edit the settings. It is not hard wired in the shapes.
Even if you paste those shapes on a page, that is not prepared, Visio will create the fields, you only need to put the strings in the props of the page again.
Yacine

Thomas Winkel

You mean like so (user field of document)?
FillForegnd=SUBSTITUTE(INDEX(LOOKUP(Prop.Signal,Prop.Signal.Format),TheDoc!User.FillColors),",",LISTSEP())
Then you can store default settings in the document template.

I use this technique to define fixed lists of shape properties in context of the document:
Prop.CrossSection.Format=TheDoc!User.CrossSections
So it's easy to switch between metric or AWG notation, for example.

Surrogate

Quote from: Thomas Winkel on February 28, 2024, 08:39:17 PMThe SUBSTITUTE / LISTSEP is necessary because Visio`s list separator depends on the language (e.g. ',' ';')
That's why I prefer to use system color palette! No RGB/HSL colors...

Thomas Winkel

Yes, elegant and simple. But is this reliable?

Where can I find this color palette in Visio 2019?

Yacine

@Thomas 1: Yes document wide is better. Caveat you need to access it via the drawing explorer. Having it on the page, you see it in the props window, when nothing is selected. Both versions are good.
@Thomas 2: You can build up the display of the palette, by writing a shape whose color depends on a field (user or prop).
In the ondrop event field, write SETF(Getref(prop.colornum), prop.colornum+1)
Then duplicate the shape 24 times (or more) and you'll have the complete palette displayed.
Yacine

Thomas Winkel

Quote
Caveat you need to access it via the drawing explorer. Having it on the page, you see it in the props window, when nothing is selected.
Ah, got your point. That's true.
We have these options in a settings dialog that is available via custom ribbon tab.
More complex, but the only way to present document properties to the user in a good usability.

Quote
You can build up the display of the palette
Yes, but I wonder if the user can change the palette in the menu from Surrogates screenshot.
If so, then it is certainly not reliable.

Surrogate

#9
I make screenshot with palette in Visio 2003, in Visio 2019 we can't see it...
I write VBA-code for make this table


0RGB(0,0,0)   Color0
1RGB(255,255,255)   Color1
2RGB(255,0,0)   Color2
3RGB(0,255,0)   Color3
4RGB(0,0,255)   Color4
5RGB(255,255,0)   Color5
6RGB(255,0,255)   Color6
7RGB(0,255,255)   Color7
8RGB(128,0,0)   Color8
9RGB(0,128,0)   Color9
10RGB(0,0,128)   Color10
11RGB(128,128,0)   Color11
12RGB(128,0,128)   Color12
13RGB(0,128,128)   Color13
14RGB(192,192,192)   Color14
15RGB(230,230,230)   Color15
16RGB(205,205,205)   Color16
17RGB(179,179,179)   Color17
18RGB(154,154,154)   Color18
19RGB(128,128,128)   Color19
20RGB(102,102,102)   Color20
21RGB(77,77,77)   Color21
22RGB(51,51,51)   Color22
23RGB(26,26,26)   Color23

Quote from: Thomas Winkel on February 29, 2024, 01:38:36 PM
Yes, but I wonder if the user can change the palette in the menu from Surrogates screenshot.
If so, then it is certainly not reliable.
Yes, user CAN change RGB-color components for ActiveDocument.Colors collection!

Sub ChangeSystemColors()
Dim clr As Color, clrs As Colors
Set clrs = ActiveDocument.Colors
For i = 0 To 23
    Set clr = clrs.Item(i)
    clr.Green = 1
Next
End Sub
' next code was borowed at https://visio-getbb-ru.translate.goog/viewtopic.php?p=7221&sid=4ee669ac9372a53aaa1389de55711ad4&_x_tr_sl=ru&_x_tr_tl=en&_x_tr_hl=ru&_x_tr_pto=wapp#p7221
Sub CheckSystemColors()
    For i = 0 To 23
        Debug.Print i & " = " & ToRGB(ActiveDocument.Colors(i))
    Next
End Sub
Function ToRGB(ByVal c As Color) As String
    ToRGB = "RGB(" & CStr(c.Red) & "," & CStr(c.Green) & "," & CStr(c.Blue) & ")"
End Function


Nlevesque

Wow! Thanks to everybody for all the answers!

Quote from: Thomas Winkel on February 28, 2024, 08:39:17 PM
And here an example as I do it in my shapes.
Simple and maintainable using lists with INDEX / LOOKUP.
The SUBSTITUTE / LISTSEP is necessary because Visio`s list separator depends on the language (e.g. ',' ';'), also see Surrogates link.

@Thomas Winkel, I think you bascially just made did my work for me!!!

Thomas Winkel

#11
Attached an example with central color definition in Document ShapeSheet.
Easy access using SETF / GetRef in "setting" shapes that can be placed multiple times (to bypass the problem, Yacine stated above).

inshead

This sounds an awful lot like what I originally had it mind a few years ago that started my whole bumpy journey with Visio.

I've had luck figuring it out then when I need to use the same concept in a new diagram I have to learn to walk all over again.

This was the use case on my last attempt. http://visguy.com/vgforum/index.php?topic=10200.0

Browser ID: smf (possibly_robot)
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: 548 (show)
Files included: 35 - 1407KB. (show)
Memory used: 1267KB.
Tokens: post-login.
Cache hits: 15: 0.00346s for 26,722 bytes (show)
Cache misses: 5: (show)
Queries used: 17.

[Show Queries]