Author Topic: Referring to cells in a subshape from a group shape  (Read 515 times)

0 Members and 1 Guest are viewing this topic.

Visisthebest

  • Full Member
  • ***
  • Posts: 174
Referring to cells in a subshape from a group shape
« on: June 19, 2020, 02:20:40 PM »
Referencing a cell in a subshape in the shape sheet of another subshape in a group works fine, but I get an error referencing a cell in a subshape from the group the shape is a part of.

Say in the Width cell of either a subshape or the group shape itself I add the cell reference:
Box.2!Width

which is a subshape of the group, this works fine from another subshape in the group but not on the group shape itself (Error in formula).

What is the right way to do this? (I tried adding the group shape name as if with a page Sheet.3:Box.2!Width grasping at straws)

Thank you for your help with this beginner question!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: Referring to cells in a subshape from a group shape
« Reply #1 on: June 19, 2020, 07:19:05 PM »
Typically, the references flow down from the parent (group) to the child (sub).   So, in your example, the width cell of the sub = k*width of group.  You cannot set width of group = m * width of sub.  This would just loop back on itself.  However, since each child is dependent on grp width, it's perfectly fine to reference one sibling to another.

Visio 2019 Pro

vojo

  • Hero Member
  • *****
  • Posts: 1528
Re: Referring to cells in a subshape from a group shape
« Reply #2 on: June 19, 2020, 08:45:55 PM »
Yes...in other words, the only way the group could be set by the subshape is if the subshape is not dependent on the group.

Not sure why anybody would do this, but
- define the subshape using shape data
- subshape width = props.width
- group width = 3 *<subshape width or subshape prop.width>
because this bypasses a lot of visio automation around scaling and has corner cases to worry about (prop.width = 0mm)

Note, since visio 3D is clumsy at best, i do something like this
- width = 4mm
- props.x = 10mm
- user.scale = 1mm * props.x/width                          //ratio is maintained by using the selection corners
- geometry1.x1 = user.scale *props.X * cos(30 deg)
- geometry1.y1 = user.scale *props.x * sin(30 deg)
kind of thing....in essence, the X,Y,Z is defined by shape date and width is only used to scale the shape and selection
(to me at least, this approach enables parametric definition and yet lets visio scale...this is  handy for marrying arcs via loctoloc constructs).

Visisthebest

  • Full Member
  • ***
  • Posts: 174
Re: Referring to cells in a subshape from a group shape
« Reply #3 on: June 20, 2020, 03:43:01 AM »
Thank you really good approaches for what I’m trying to achieve!

I agree having shapesheet relations from from group to subshapes for some cells and from subshapes to group level for other cells is not ideal but struggling to solve some things otherwise.

One example of a use case is this:

- A group shape consisting of multiple rectangles that contain multiline text (from shape data) and resize themselves in height based on the text content size (width is set by the group shape and user can widen the group shape which widens the subshapes).

Letting height info flow from the subshapes to the group is much easier (for me) in this case because the ‘height autoresize based on text contents’ is a key feature in the flowcharts in question I want to have shapes with identical widths (unless the user wants to force a different size) but flexible amounts of multine text that are shown on the specific custom flowchart shapes.

I wouldn’t know how to achieve this otherwise.
« Last Edit: June 20, 2020, 03:46:08 AM by Visisthebest »

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: Referring to cells in a subshape from a group shape
« Reply #4 on: June 20, 2020, 08:23:25 AM »
Not at my computer, but, a couple things:
1) you can use guard fcn and a literal value to lock down a sub shape width.
2) if I'm not mistaken, use containers rather than grouping.  The container merely possesses its inhabitants, doesn't control them.  In fact, I believe a container may resize to keep its occupants within its borders.
Visio 2019 Pro

vojo

  • Hero Member
  • *****
  • Posts: 1528
Re: Referring to cells in a subshape from a group shape
« Reply #5 on: June 22, 2020, 03:34:44 PM »
3 subshapes...1 then row of 2

At group level
- get the font size of the 3 subshapes
     - user.row1 = subshape 1 font size
     - user.row = max(subshape2 font size, subshape 3 font size)
     - user.size = (user.row1 + user.row2) * mm/pt conversion         //I forget the pt to mm conversion
- height = guard(user.size).

note, this means you can ONLY widen the group...not arbitrarily make taller.

Now if you want to get real slick
use the setatexpress construct

something like this complicate
 setatref(user.chy,setatrefeval(bound(setatrefexpr(),0, false, height*0.5, height*1),true) + pnt(x,y)

This and some user cells enable a control point to be constrained in an oval

look at visio guys posting about constrain a control point on a circle...I posted on how to extend to an oval


Visisthebest

  • Full Member
  • ***
  • Posts: 174
Re: Referring to cells in a subshape from a group shape
« Reply #7 on: June 22, 2020, 03:42:33 PM »
Thank you Vojo this is a really clever way to solve it will look at this approach! I will take a look at Visioguy's posting about constraining a control point on a circle, also good to get my head around this approach.