Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: Soundstorm on July 28, 2022, 02:02:15 PM

Title: Reference group cell from shape
Post by: Soundstorm on July 28, 2022, 02:02:15 PM
Hi

I'm probably overlooking something, as I've made this work in the past. But I already spent 3 hours trying different things and searching around, without any luck... I can no longer access the shapes I made with these features, so I hope I can get some help here.

So I need a shape that has a context menu to show/hide certain elements. The menu is done on the group shape, there are a couple of user defined objects with true/false. So now I go into the shapesheet of each shape that I want to hide/show, but whatever I use I either get a faulty formula, of a formula that returns no value.

The HH_Label is the one I was using to test the formula, as this is an easy one.
In the Miscellaneous section, I want the HideText object to be linked to User.AlarmLevelHH from the group shape.
I would normally use: NOT(GetVal("PLC_Connection_Group!User.AlarmLevelHH")
But that is not working.

How can I reference these user objects?

Thanks!
Title: Re: Reference group cell from shape
Post by: Surrogate on July 28, 2022, 03:26:57 PM
Quote from: Soundstorm on July 28, 2022, 02:02:15 PM
I would normally use: NOT(GetVal("PLC_Connection_Group!User.AlarmLevelHH")
But that is not working.
Hi ! Try change formula PLC_Connection_Group to Sheet.XXX, where XXX is PLC_Connection_Group shape ID.
Title: Re: Reference group cell from shape
Post by: wapperdude on July 28, 2022, 03:31:48 PM
See this reference:  https://docs.microsoft.com/en-us/office/client-developer/visio/about-cell-references (https://docs.microsoft.com/en-us/office/client-developer/visio/about-cell-references)

At the very bottom is syntax for non-standard shape names.
Example:
shape, page, master, document, or style with a nonstandard name.      'Sheetname'!CellName  "1-D'!LineColor
Title: Re: Reference group cell from shape
Post by: Soundstorm on July 28, 2022, 04:49:16 PM
Quote from: Surrogate on July 28, 2022, 03:26:57 PM
Quote from: Soundstorm on July 28, 2022, 02:02:15 PM
I would normally use: NOT(GetVal("PLC_Connection_Group!User.AlarmLevelHH")
But that is not working.
Hi ! Try change formula PLC_Connection_Group to Sheet.XXX, where XXX is PLC_Connection_Group shape ID.
Where do I get the ID?
I'm doing all this in the master shape edit, is that maybe the problem?

Quote from: wapperdude on July 28, 2022, 03:31:48 PM
See this reference:  https://docs.microsoft.com/en-us/office/client-developer/visio/about-cell-references (https://docs.microsoft.com/en-us/office/client-developer/visio/about-cell-references)

At the very bottom is syntax for non-standard shape names.
Example:
shape, page, master, document, or style with a nonstandard name.      'Sheetname'!CellName  "1-D'!LineColor
I tried
'PLC_Connection_Group'!User.AlarmLevelHH
"'PLC_Connection_Group'!User.AlarmLevelHH"

Still doesn't work.
Title: Re: Reference group cell from shape
Post by: Surrogate on July 28, 2022, 05:04:09 PM
Quote from: Soundstorm on July 28, 2022, 04:49:16 PM
Where do I get the ID?
View the ID of a Shape (https://docs.microsoft.com/en-us/office/client-developer/visio/change-the-name-and-view-the-id-of-a-shape)
Quote from: Soundstorm on July 28, 2022, 04:49:16 PM
I'm doing all this in the master shape edit, is that maybe the problem?
Probably ! The reference by name works if both figures are on the same level. Both on the same page or within the same group
Title: Re: Reference group cell from shape
Post by: wapperdude on July 28, 2022, 05:52:19 PM
Is 'PLC_Connection_Group'!User.AlarmLevelHH boolean? 

If so, you don't need the getval fcn.  In the HideText cell, just enter the cell reference.  Visio will bring the value by default.  That is, the HideText entry would literally be  'PLC_Connection_Group'!User.AlarmLevelHH or if you want opposite case: NOT('PLC_Connection_Group'!User.AlarmLevelHH)
Title: Re: Reference group cell from shape
Post by: Soundstorm on July 28, 2022, 06:00:51 PM
Quote from: Surrogate on July 28, 2022, 05:04:09 PM
Quote from: Soundstorm on July 28, 2022, 04:49:16 PM
Where do I get the ID?
View the ID of a Shape (https://docs.microsoft.com/en-us/office/client-developer/visio/change-the-name-and-view-the-id-of-a-shape)
Quote from: Soundstorm on July 28, 2022, 04:49:16 PM
I'm doing all this in the master shape edit, is that maybe the problem?
Probably ! The reference by name works if both figures are on the same level. Both on the same page or within the same group
I tried both in the master shape and if inserted on a page, no luck.

Quote from: wapperdude on July 28, 2022, 05:52:19 PM
Is 'PLC_Connection_Group'!User.AlarmLevelHH boolean? 

If so, you don't need the getval fcn.  In the HideText cell, just enter the cell reference.  Visio will bring the value by default.  That is, the HideText entry would literally be  'PLC_Connection_Group'!User.AlarmLevelHH or if you want opposite case: NOT('PLC_Connection_Group'!User.AlarmLevelHH)
Yes, it's a bool. Leaving the getval out doesn't help.
Title: Re: Reference group cell from shape
Post by: wapperdude on July 28, 2022, 06:55:18 PM
When you set the shapesheet to show values rather than Formulas, what result does the hide text cell indicate?  Should be a True or false or possibly 1 or 0.
Title: Re: Reference group cell from shape
Post by: wapperdude on July 28, 2022, 07:00:35 PM
I just noticed, that this is done in a stencil file...vssx.  Can you drag and drop this to a normal drawing page?  I prefer getting everything working on a drawing page before moving it to stencil.  Others may disagree.
Title: Re: Reference group cell from shape
Post by: vojo on July 29, 2022, 02:37:22 PM
why the single quotes for the sheet ID?  'PLC_Connection_Group'!User.AlarmLevelHH

should it be more like    <some child cell> = NOT(PLC_Connection_Group!user.alarmLevelHH)

the other way you could try this is

group shape ID is     sheet.xx
child shape ID is       sheet.yy

sheet.yy!user.testcell = NOT(sheet.xx!user.alarmLevelHH)

Title: Re: Reference group cell from shape
Post by: wapperdude on July 30, 2022, 01:05:48 AM
After trying a variety of syntax options, it looks like using shape names is broken.  Using sheet identifier works.  You can find the ID of a shape by selecting it, then go to Developer tab.  Select rename shape.  A popup form shows the ID in the first line entry.  Fortunately, Visio will update the shape references each time a new one is dropped onto the page.
Title: Re: Reference group cell from shape
Post by: wapperdude on July 30, 2022, 03:36:32 PM
I decided to run a simple test case...just two shapes.  Unfortunately, it was late, so testing is incomplete.  Using custom shape name vs sheet.ID was fine and then broke, sometime after grouping.  My procedure was as follows:
1) when doing the grouping, I made 1st shape the group.  See Ribbon>Developer>shape design section>Shape Name.  This brinfgs up a form that shows ID, present name, e.g., Sheet.1, and other info.  This will be used this to change shape name.
2) in shape 2's shapesheet, created a single Shapedata entry, for convenient reference and value changes.  Named the data entry "MyVal".
Then,  added DOCMD(1312) in the Event double click cell
3) back to shape 1's shapesheet, I set this formula in the height cell: =Sheet.2!Prop.MyVal
4) no grouping at this point.

This works as expected.  double click shape 2, brings up Shapedata entry form.  Setting different values causes shape 1's height to change.  Next step, change shape w2's name,  something simple, like Sqr2.  All still works.  Open sheet.1 shapesheet, and in the height cell the formula now shows =Sqr2!Prop.MyVal.  Visio updated the formula to reflect name change.  (Note, subsequent, additional name changes will not get pushed into this formula and are ignored.).

At this point, converted sheet.1 to group and added sheet.2 to the group.  The sheet.2 is still named Sqr2 as no other renaming was performed.  Changing Sqr2 prop data still works.  That's as far as I've progressed.

Edit: 
Things left to explore...
1) more complex shape names
2) impact, if any, doing a more traditional grouping approach.

My suspicions are...
1) The subshapes may have been renamed multiple times.  If so, that's a problem.  See http://visguy.com/vgforum/index.php?topic=8417.msg36441#msg36441 (http://visguy.com/vgforum/index.php?topic=8417.msg36441#msg36441)
2) Grouping might be a factor, but I wouldn't think so.  Unless M$ introduced a bug/feature that doesn't accept custom shape names.

Title: Re: Reference group cell from shape
Post by: wapperdude on July 30, 2022, 11:59:51 PM
Turns out this is a grouping related issue.  Non-grouped shapes behave as expected.  Grouped shapes, whether traditional grouping or shape converted to group, will not accept shape names.  Not Custom names.  Not complex names.  Formula references only accept standard sheet.ID syntax.  The restriction happens when the shape gets added to or is a member of a group.  A group member shape may reference a shape external to the group.  The referencing may be by ID or by name.
Title: Re: Reference group cell from shape
Post by: Soundstorm on August 03, 2022, 07:10:12 AM
Thanks for looking into this!
The only reason I changed the shape name, was because there was a typo in its original name... When I found out you could change names, I changed all of them, because a name makes more sense than an ID.

I will try and recreate the shape without changing any names. I'll report back afterward!
Title: Re: Reference group cell from shape
Post by: Soundstorm on August 03, 2022, 08:26:48 AM
Ok, ungrouping, copy-paste and regroup did some magic to give everything a proper name. The group name changed back to sheet.5 and all shapes inside the group retained their custom name, but were given an ID as well.
I was able to reference all shape names like it should be. Perfect!

Only thing I'm running into now, is the fact that the 'bounding box' is around all items of the group, instead of just around the main shape.
How can I change that part? The shape master is only 6x6mm, but the bounding box is 9x12mm. If I change the group dimensions, it resizes all shapes inside the group.
Title: Re: Reference group cell from shape
Post by: Surrogate on August 03, 2022, 08:58:55 AM
All sub-shapes into group have width/height which related to group shape's width/height
width=sheet.5!width*7/40
You can overwrite these cells, for prevent resize of sub-shapes
Title: Re: Reference group cell from shape
Post by: Soundstorm on August 03, 2022, 10:57:57 AM
Thanks. I forgot the shape lost all the absolute values I used when ungrouping and starting all over again.
Title: Re: Reference group cell from shape
Post by: wapperdude on August 03, 2022, 02:17:51 PM
QuoteOnly thing I'm running into now, is the fact that the 'bounding box' is around all items of the group, instead of just around the main shape.
There are two ways, each requires 1 additional step.
1) before grouping, move at least 1 shape to be within borders of the parent shape, then group.  Extra step: open shapesheet of group and scroll to...I think Misc section.  On right side of the listings will be LockCalcWH.  Select (check) this entry.  This locks the recalculation of the bounding box.  Now you can add shapes to group without the change.

2) before grouping, select your parent shape.  Goto Developer tab, and click on Grouping.  Select Change to group.  Extra step:  open the parent shapesheet and do same extra step as above.  Add shapes to group as normally done.