Show custom attributes based on Layer

Started by wmd, May 27, 2009, 01:42:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wmd

I am trying to create a stencil shape that has custom properties that I only want to show based on the visibilty setting of a layer.  The specific shape is a connector with a custom property of "transport".  I want the custom property to only show when the "Physical" Layer is visible.  The following works if I update the shapesheet once the shape is on the drawing page: =IF(ThePage!Layers.Visible[2],Prop.transport,"").  However, this does not work for a stencil shape as it has no reference to a page.  Is there a way to do this with Shapesheet formulas and stay away from macros or .NET code?

Appreciate any help or suggestions.

wapperdude

Well, will try for the easy solution 1st.  Is this text, the only text associated with this shape?  ???  If so, why not use the custom property to either hide or show the text in the Miscellaneous section of the shapesheet?   ::)

Wapperdude
Visio 2019 Pro

wmd

Thanks for the quick reply.  I apologize in advance for my long message below.

The are 2 custom properties defined for the connector shape.  Thanks for the tip on the Miscellaneous setting but I think I still have the issue trying to reference the Page Layer Visibility settings.

Let me provide some additional details.

I am using Visio 2003 Professional.

I have a stencil with a number of shapes that represent various software elements.  These include an application software component(e.g. GetCustomer, Update Customer, Calculate Tax), runtime environment (e.g WAS, WebLogic, IIS, .NET), technical adapter (e.g. MQ Client, JDBC Driver), etc.  The shapes are created with custom attributes and the user is prompted to enter the custom attrbitutes (the examples given in the previous statement would be the types of things entered in the custom attributes.

What I want to do is assign the application components and connectors that show the links between them in a "Logical" Layer on the page and then all the other items like runtime environment and technical adapter in the "Physical" Layer.  This will allow for the diagram to be show as a logical representation of the application software components or as a physical diagram once the technology decisions on how the application is going to be implemented.  Either view (logical or physical) will be able to be represented just by changing the turning the Physical layer visibility on and off.

When I create the logical layer I drop application component shapes and connect them with the connector.  At the point I start adding physical layer shapes (runtime environment, technical adapter).  As part of create the physical view I now populate the custom attributes of the connector.  The connector that I mentioned in the previous post has 2 custom attributes; Transport (e.g. MQ, HTTP) and Format (e.g. XML, Fixed Format, Delimited).

Back to the issue.  I only want the custom attributes to show in the text of the connector when the "Physical" Layer is visible but not show when the visibility of the physical layer is turned off.  The issue I ran into was that my custom shape on the stencil can not reference the layers on the page since it has not been dropped on the page yet.  Once a shape is on the page using the =IF(ThePage!Layers.Visible[2],Prop.x,"") in the Text Field Value cell works.  Obviously this defeats the purpose as it would require manual updating of all connector shapesheets where the custom values are needed for the physical representation. 

I am pretty sure this could be easily accompished with a macro that would update all connector shapes with the formula but I was trying to keep the template macro free.



wapperdude

You could try adding your formula in the Events section, EventDrop cell.   


HTH
Wapperdude
Visio 2019 Pro

wmd

The issue all revolve around the ability to reference a page.
I was searching around and saw about setting a document level User field.  So I created a user field called User.ViewType with values of "P" or "L" for physical and logical. 

I then tried putting the following formula without success:
=IF(STRSAME(TheDoc!User.ViewType,"P"),Prop.MessageFormat,"")

By pure accident I came across the following post when I did a search on Visio TheDoc.
blogs.msdn.com/visio/archive/2006/07/14/664948.aspx

I noticed that it was using a reference to TheDoc and followed the instructions provided and it worked.  This lead to the question of why couldn't I put the formula in the shape on my stencil.
The key item in the document that lead me to a solution was the viewing of the Document Stencil.  As I am sure you are aware Visio keeps a master of every shape that was ever dropped on the drawing page even if you delete it. 

With this knowledge I opened my template and associated stencil,  dropped the connector shape on the form,  updated the shapesheet to include the formula (as shown above),  dragged and dropped the updated shape back to the stencil, deleted the shape from the template drawing page, saved the stencil and template.  Now the formula works. 

The reason it works (deductive reasoning) is there is now a relationship of the master shape to the document.  The hole in this reasoning is that I can go into Drawing Explorer and delete the master and it does not break the formula.

The bottom line is that I chalk this up to taking an existing template and shapes.  Sometimes it is better to start with a clean slate.

One other thing I did was to concatenate the two custom attributes in one formula.  I can now use the HideText as you suggested earlier.
Thanks again for your replies to my post.   

HelenJames

I think this topic was discussed loads of time before at this forum