How to notify the currently selected shape that it is selected (no VBA)

Started by nmxtch, March 22, 2025, 07:17:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nmxtch

This took me literally years to solve so I wanted to share in case someone else is trying to accomplish something like this. It is a bit of a hack because it leverages a feature that isn't accessible any other way (that I am aware of).

Example purpose:
Show, hide, or affect shapes depending on whether a specific shape is actively selected. This works on selections of multiple shapes as well allowing and/or logic. This type of behavior can be seen when using the "Walls, Doors, and Windows" stencil included with Visio -- when you select a wall, its dimensions appear next to it. Then, when that wall is no longer selected, the dimensions disappear.

Prerequisite:
Your document MUST be showing the "PLAN" tab in the ribbon. To activate this tab, open the "Walls, Doors, and Windows" stencil, then drag and drop a wall shape from the stencil onto one of your pages. You should now see the "PLAN" tab in your ribbon at the top. You can delete the wall once the "PLAN" tab exists. Note, dropping the wall shape also automatically creates some extra layers so you may want to remove those to keep things tidy.

How to enable the feature on any shape or group:
Open the target shape's shapesheet and, if it doesn't already exist, insert the "User-defined cells" section, then add the following three rows and values:

User.SolSH         ="{5D50005D-537C-4738-9C46-130C74335A6D}"
User.ShapeType     =44
User.visBESelected =0

That's it! Now, when the target shape is selected, the value in the cell "User.visBESelected" becomes "1". Then, upon deselection or selection change, the value in cell "User.visBESelected" becomes "0".

Use:
Now you can conditionally show, hide, or affect other shapes by setting their Geometry1.NoShow cell to something like:

=NOT(Sheet.36!User.visBESelected)
 See the attached file for a working example.

Cheers!

Yacine

Yacine

Paul Herber

I am envisaging a shape that hides itself when selected but other shapes become visible, maybe at random!


Electronic and Electrical engineering, business and software stencils for Visio -

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

Yacine

Quote from: Paul Herber on March 23, 2025, 07:33:43 AMI am envisaging a shape that hides itself when selected but other shapes become visible, maybe at random!



Right, April first is close. ;)

But joke aside, this is cool for (1) inspection and (2) - if possible - to show control features that go beyond the standard control points and context menus.
For (2), we'd need a mechanism to handle that the main shape loses the selection.

(1) could be extended to show more help than what is possible with the "hint" feature.
Yacine

nmxtch

Quote(1) could be extended to show more help than what is possible with the "hint" feature.

This is exactly what I wanted it for in the first place. I use Visio to create site maps for my CCTV installation projects and wanted to be able to show camera details like focal length and resolution but only when the camera is actively selected to keep the diagrams from being too cluttered.



I also use it to highlight the camera with a glow so I can hide the alignment box and handle everything with control handles.

Yacine

I saw this and instantly thought of this thread. Too accurate not to post.
You cannot view this attachment.
Yacine


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: 258 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1121KB.
Tokens: post-login.
Cache hits: 13: 0.00138s for 26,591 bytes (show)
Cache misses: 2: (show)
Queries used: 17.

[Show Queries]