Visio - How to access a shape parent's custom property? - visio

I have grouped 3 shapes (simple square boxes) together. In each of those shapes, I would like to add a field that will display the value of a custom property defined in the "parent" shape (ie: the group).
I know that if the property was directly bounded to the shape I was adding the field to, the formula for that field would simply be: "=prop.MyProperty".
I've looked for something like: "=parent.prop.MyProperty" with luck. Any clue?

Although there nothing like "parent", you can use shape id directly. You need to find the ID (NNN) of the parent shape (i.e. of the group shape), and then use it in the child shape using the syntax like this:
=Sheet.NNN!Prop.MyProperty
The ID of the shape can be found using drawing explorer window (it displays shapes with ids), or "Shape Name" button on the "Developer" tab, ID() shape sheet function on the group (parent) shape, or shape.ID property VBA code.

If you are using VBA there is a Parent property.
IF VSOShp1 contains VSOShp2 and VSOShp2
Debug.Print VSOShp2.Parent
will show the name of the parent VSOShp1.
Debug.Print VSOShp2.Parent.ID
will show the sheet id of VSOShp1.
John...

Related

Visio - How to use the same shape property for many shapes

I have created one master shape with many properties. In the "Define Shape Data" windows of the master shape (of the document stencil), one of the properties (masterProp) is a variable list (so with a list of allowed values).
Is it possible to re-use the list of values allowed for this property (masterProp) to define the format of another property of type variable list in another master shape so that the list of values has to be maintained only once ?
Maybee is there a way to set up "lists" in Visio and link the expected/allowed values (format field) of a property to this list (without using excel) ?
Thanks for your advises,
Is it possible to use the same property (masterProp) in another master
shape to inherit the same allowed values? Or is it possible to link
the values of another property of type fixed list in another master
shape to the values of this masterProp property ?
You mean mastershape in document stencil or in external stencil ?
You can refer to some cell of mastershape in document stencil
To reference a cell of
Use this syntax
Example
A master
Masters[MasterName]!SheetName!CellReference
Masters[Gear]!Shaft!Geometry1.X1
About Cell References
Well, Thanks to #Surrodate, this is the correct way of doing this:
Add a user-defined cell in the ShapeSheet of the document (or the page)
Open the master shape for editing
In the master shape, open the shapesheet of the master shape and go to the section of the Shape Data
In the Format column, refer to your user-defined cell. Begin typing with a "=" otherwise it takes your entry as text (even if it recognise your data ...). To refer to the document, begin with =TheDoc!User... if your data are in the page, begin with ThePage!User... Do not forget to set the type of data to 1 or 4 (in case of list).
Ok, I found the shapeSheet of the Page-1. I added a user-defined
section, then a cell named "User.Softwares". I set the value to
="Soft1;Soft2;Soft3". Correct for list ? Then in the field "Format" of the "Define Shape Data" windows in have written
"Page-1!User.Softwares". Is that the correct way to refer to the
page-1 ? When I click on the property of a shape, it proposes the text
"Page-1!User.Softwares" and not the value of the user-defined cell in
Page-1 ... What is the mistake ?
You must also change Type field ! If in this cell stores 0, it mean "String". if cell value is 1 it mean Fixed list.
You must write Page-1!User.Softwares, without quotation marks !

Shape property which references documentsheet property doesn't get updated when documentsheet property changes

I have the following case:
I defined a user property ("User.DocProp") at the documentsheet level. I want to reference this property in a shape property cell ("Prop.SomeProp") and display the shape property as text on the shape.
This is working (I inserted a field into the shape text which points to my shape data). The value of the document property is correctly displayed on the shape.
And when I change the document property the shape's text gets updated. Awesome!
BUT this (update of the shape's text after change of the document property) doesn't work anymore when I have multiple pages each with the same kind of shape as before. When I now change the property on the documentsheet only those shapes get updated which lay on pages that I have navigated to before (since I opened the drawing). On all other pages the shape text will show the old value of the document property. Only when I directly enter the cell in the shapesheet by pressing F2 and leave with ENTER the text will get updated.
I tried several formulas in the shape property with no avail:
=TheDoc!User.DocProp
=SETATREF(TheDoc!User.DocProp)
=SETATREF(TheDoc!User.DocProp,SETATREFEVAL(SETATREFEXPR()))
I can't find a method to force recalculation of formulas neither. What am I missing here?
Screenshot from test drawing

Visio: Creating Automatic Numbered Label

I'm currently working on creating a new stencil for several components I use in Visio and I'm stuck at the point of providing proper labels. If you use a resistor from Visio stencil it automatically generates a label "R1" (for first resistor) and "Rk" for the kth resistor. How can I do something similar for my own stencil ?
1- I need to generate a label "ABCD #" (# number automatically generated based on instance count)
2- How can I position the location of this field?
PS:
1- Visio components have a custom defined field which allows for this (which I don't know how to create)
2- For capacitor for example the shapesheet shows an interesting entry
=SETF(GetRef(User.Label),"""C""&"&ThePage!User.AccumulatorCount)&SETF(GetRef(ThePage!User.AccumulatorCount),ThePage!User.AccumulatorCount+1)
which supposedly is how the count and name are generated (I'm not sure how the AccumulatorCount is defined it differs from element to element).
Thank You!
The EventDrop ShapeSheet cells for various electrical shapes have formulas similar to the one you have discovered:
SETF(GetRef(User.Label),"""C""&"&ThePage!User.AccumulatorCount)&SETF(GetRef(ThePage!User.AccumulatorCount),ThePage!User.AccumulatorCount+1)
The ShapeSheet for the page has a cell: User.AccumulatorCount for capacitors. Other User cells will be added as other shapes are dropped. You can set up your own system by adding a User cell to the page, say: User.Widget. Then you place the "Widget" version of the "SETF" formula into your own shapes.
You can create user cells by:
Open the ShapeSheet for the Page (right-click blank area of page, Show ShapeSheet)
Right-click in ShapeSheet and choose Add Section
Add a User-defined cells section
Find the User-defined cells section and similarly add rows to it via
right-clicking
You change the row names by typing over the red, row-name text on the left.
You enter values and formulas in the cells as you would in Excel.
You can toggle viewing formulas vs. viewing values by pressing F5
while in the ShapeSheet.
You have to make the User cell in the page first, so that your shape can reference it. Once your shape references the page cell, you can drag your shape into a stencil, and it will "drag the page User cell along too". So now, you can drop your Widget shape into a new document, and it will create the page User cell on the fly.
The system is basic and fragile. The count only goes up, and never down. If you have shapes with 1, 2, 3, 4 and you delete 1 and 2, the next shape will still be 5.

Don't draw parent content

Let's say I have a text object filled with dots (............). Let's also say that I create another text object as a child of the first text object, with the content foo.
Between each space in the letters of foo, there are clearly visible the dots of the parent. Is there a way I could filter the content of the parent?
Example:
I'd like to keep the semi-transparent white scroll panel and the hexagon background image, but I'd like to remove the dots behind the numbers 4500.
I would suggest using a Horizontal layout group instead
Parent (object with only the HorizontalLayoutGroup)
Child Object 1 : contains your ....
Child Object 2 : Contains your "foo" or numbers
The parent will have the total size of your current parent object (total width)
When setting Child2's text it will resize automatically, which will effectively hide the extra "dots".
No special hacks required
Link to get you started : https://docs.unity3d.com/Manual/script-HorizontalLayoutGroup.html

How to hide the label of a diagram link in Enterprise Architect using Add-in?

In Enterprise Architect, user can hide/show the labels of links (connectors) on a diagram. Concerning extension (add-in) development for EA, is there a function that calling it can set the visibility of a label on the diagram(s)?
Or in another more general word, how is it possible to retrieve the list of the labels of a connector programmatically?
You need to manipulate the diagramLinks.Geometry property. When you have a label this string will contain something like
LMT=CX=6:CY=13:OX=42:OY=9:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:DIR=0:ROT=0;
LMT is the part for the middle label which contains the name. LMB is for the stereotype and other L-attributes are for roles and cardinality.
Now you need to change HDN=0 to HDN=1 to make the label invisible.