Implementing a Parent - Child relationship with stencil shapes.

Started by MyrddinE, May 05, 2022, 03:36:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MyrddinE

I'm attempting to create a new stencil for a project and running into difficulty with what I thought would be something straightforward. I want to make the stencil masters inherit from each other to make adjustments easy but the method of referencing another master doesn't seem to work as documented.

I created an example stencil with just two shapes, Parent and Child. I want to reference a Parent field's value in the Child shape.



The reference is correct, but Visio tells my my formula has errors. What am I doing wrong? Is there a workaround?

I want to be able to make changes in one place and have those changes reflected in all the relevant shapes in the stencil.

MyrddinE

If you would like a little StackOverflow karma, you could answer my question there as well.

Paul Herber

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

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

MyrddinE

I think we're still talking about different shapesheets Paul, though I do appreciate your trying to help.








I want to have multiple shapes in a stencil all work from a central set of measurements; ideally the measurements of a parent stencil. It doesn't appear that stencil Masters are allowed to refer to other stencil Masters.

Is there another way to accomplish this goal (one source of adjustable values embedded in the Stencil) using a different approach?

wapperdude

Unless I'm missing something, happened back in 1849,  :o, seems like there's a fundamental flaw with your approach.  Soom as you drag either shape onto a drawing page, the link will be broken.

Assuming that's correct, I would setup the two shapes as desired on a drawing page.  Then select both and drag n drop onto the stencil.  They will be "grouiped".  Then, when you drag n drop back to a drawing page, it is OK to ungroup.  For additional child shapes, just duplicate the existing child.  The link to the parent will be copied.  I think that's the easiest, most efficient way to do this.
Visio 2019 Pro

Paul Herber

And when the stencil is closed then any link is broken. I think the term "Masters" is being misunderstood. Yes, the term Masters can mean to shapes within the stencil, but Masters within the shapesheet refers to the shapes in the Document Stencil, i.e shapes that have already been instantiated within a document. Shapes cannot refer back to the file of stencils. Not at all.

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

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

MyrddinE

Now that you have a better understanding of my question, can you improve the answer you have over on StackOverflow Paul? Because your current post doesn't actually answer the question.

Perhaps a workaround that solves my question a different way? Rather than having all the stencil shapes refer to another stencil shape, can they refer to a custom table that gets created on the Page automatically when they're dragged onto it? I don't understand this post, but it sounds a bit like something that could be used to auto-create a custom table of dimensions that my shapes can refer to.

The biggest thing I don't want is to change how shapes are added to a sheet; I don't want to make my stencil confusing for others in the company to use (which rules out having a weird mega-shape in the stencil like wapperdude suggested).

Yacine

Quote from: MyrddinE on May 09, 2022, 11:01:28 PM
... can they refer to a custom table that gets created on the Page automatically when they're dragged onto it? I don't understand this post, but it sounds a bit like something that could be used to auto-create a custom table of dimensions that my shapes can refer to...


That's right. You can use the current page's prop section as central storage place.


Very easy to implement:
- Add the desired props to the page and reference them in the shape that will become your master. (Shape is still on the page, not in the stencil).
  eg: Width = thepage!prop.width (with or without guard or setatref, etc.)
- Then drop the shape onto the stencil to make it a master.
- Next time you use the master - EVEN on a page that has not the prepared prop field (prop.width), the field will be created and the formula stays in the newly created instance of the master.
Yacine

vojo

I am not sure its this straight forward as presented.
1) this table has to be a known name on the page (probably means by name....not sheet.1)
2) sure you can use props, but you would need to define all the props names ahead of time so the drop can find its entry
    (imagine 2 squares to be dropped, Square 1 looks for props <square 1>....square 2 looks for props <square 2>
    There is no shapesheet function to add a row in the shapesheet....so the props section needs to be fully articulated.
3)you cant do this as a shape on the page since the shape name is variable and there is no such thing as 1 shape
    discovering another shape dynamically without VBA
    (back in 2003, visio guides called out that the shape name  (e.g. sheet.2468) can change do to shapes added and deleted.)
4)probably want to look at the setexpreat*** functions so that if you update the shape, the changes are pushed back to the
   page props.
5) if there is plans for more than a few shapes, you probably want to do this in VBA (or even python).
6) you may be able to leverage the document stencil to trick/spoof the behavior you want.

wapperdude

As Vino points out,
Quotediscovering another shape dynamically without VBA
.  That is part of the reason for grouped shape on stencil.  Formulas in Visio shapes to other shapes always break when the referenced shape is deleted.  There is no "automatic" feature to restore the formula. 

If you have a dedicated reference, could be a "master" shape on the document stencil, or data in a table or data in a page shapesheet, then you can have code that triggers on drop to find the needed references. 

Adding deleting rows is also a problem, because the slave shapes do not understand such operations wrt to their own needs to include or exclude those changes.  Again, code would be required to scan the source and then update the slaves.
Visio 2019 Pro