Custom properties

J

Jonathan Spane

I am writing an add-on which dyamically adds custom properties to master
shapes. This is working just fine.

One weird thing I am noticing when I update Dynamic Connector shapes the new
custom properties are not showing up when instace the new shapes on an
existing drawing.

If I start a new drawing and drag the same connector on to it the custom
property shows up. To add more to the confusion other shapes like rectangles
work just fine.

Any thoughts on how the existing drawing will not show the new properties in
new instanced connectors?

Thanks
JP
 
C

Chris Roth [MVP]

Hi JP,

What's your master-modifying code look like? There's a way to do this that
makes sure your changes get pushed to the drawing properly, but it's not
obvious:

Dim mst, mstCopy as Visio.Master

set mst = ThisDocument.Masters("Dynamic connector")
set mstCopy = mst.Open

mstCopy.Shapes(1).AddNamedRow(...)

mstCopy.Close ' push changes!
set mstCopy = Nothing
set mst = Nothing

Or are you already doing this? ; )

--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 
J

John Goldsmith

Hello Jonathan,

What you're discovering is the way in which Visio handles Master/Instance
relationships.

Basically each document has its own "Document Stencil" and local set of
Masters and the first time you drop a Master (from a predefined stencil)
onto the page a copy of that Master is also added to the Document's stencil.
If you then drop another shape onto the page (from the same predefined
stencil) Visio will use the local version of the Master from the document
stencil.

In terms of updating a Master Visio uses two method:

If "Match Master by name on drop" (right-click the Master and then
EditMaster/Master properties) is set to False then updating the original
stencil Master will cause Visio to append the Master name with a unique ID
and in the document stencil you'll effectively end up with multiple Masters
for the same shape. For example you can easily end up with two Masters
named "Circle" and Circle.2" both of which having instance shapes on the
page. Not a great situation in most cases!

If "Match Master by name on drop" is set to true then updating the original
stencil Master will have no apparent effect as Visio will use the existing
named Master in the document's stencil and not your fresh version.

So your choices for existing documents are to update their respective local
Masters as well as your original stencil or to delete the document instances
and the Master and then replace them with the new version. I had this same
situation in a old solution and found that it was easier to write some code
to 'recreate' the legacy documents based on an updated stencil. It was a
system that worked very well for that particular situation and meant that I
was able to make reasonably frequent changes to the original stencil and
then update the documents as and when needed.

So check that your original Masters have their "Match Master by name on
drop" set to true and then decide on your strategy for dealing with legacy
documents.

Hope that helps.

Best regards

John

John Goldsmith
www.visualSignals.co.uk
 
J

Jonathan Spane

I tried usin ghte copy way and it didn't seem to help. Unchecking the Match
Master By Name On Drop works. Which is okay to this will be a very
controlled in-house tool.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top