Reference group cell from shape

Started by Soundstorm, July 28, 2022, 02:02:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Soundstorm

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!

Surrogate

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.

wapperdude

#2
See this reference:  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
Visio 2019 Pro

Soundstorm

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

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.

Surrogate

Quote from: Soundstorm on July 28, 2022, 04:49:16 PM
Where do I get the ID?
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

wapperdude

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)
Visio 2019 Pro

Soundstorm

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
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.

wapperdude

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.
Visio 2019 Pro

wapperdude

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.
Visio 2019 Pro

vojo

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)


wapperdude

#10
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.
Visio 2019 Pro

wapperdude

#11
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
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.

Visio 2019 Pro

wapperdude

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.
Visio 2019 Pro

Soundstorm

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!

Soundstorm

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.