Visio Guy

Visio Discussions => Programming & Code => Topic started by: Nepherim on May 04, 2018, 08:01:03 PM

Title: Uniquely Numbering Shapes
Post by: Nepherim on May 04, 2018, 08:01:03 PM
I'm looking to assign unique ID/numbers to each shape in a model.

I thought perhaps "Number Shapes" would get me there, but whilst Number Shapes adds new Properties to each shape, it doesn't add properties to the Shape Master. On the face of it, that's okay, since those fields are added when a master shape is dropped. However, that actually means those fields now become visible to the end user when a DOCMD(1312) dialog is shown, or when the Shapesheet is shown -- since they are visible by default.

So:
I had considered just re-purposing the same mechanisms Number Shapes implements, but it's not at all clear where the 'generate new number on drop' event is firing from, nor where the "add shape numbering fields on drop' event fires from.

Any thoughts?
Title: Re: Uniquely Numbering Shapes
Post by: Paul Herber on May 04, 2018, 08:29:58 PM
http://visguy.com/vgforum/index.php?topic=4870.0
Title: Re: Uniquely Numbering Shapes
Post by: Nepherim on May 06, 2018, 08:13:59 PM
The links I have seen mostly orient around the unique ID part. I'm less concerned about that, and more in how the Number Shapes works, since it's basically what I want with a few things I'd like to change.

- How to prevent Number Shapes "continue numbering on drop" dialog when opening the Visio model?
- Where do 'generate new number on drop' event and 'add shape numbering fields on drop' event fire from?
Title: Re: Uniquely Numbering Shapes
Post by: Nikolay on May 07, 2018, 12:06:12 AM
If you want to hide the numbering properties, you could hide them in the master shape.
Means, you edit the master, set these 3 properties used by the Numbering addon to be "Hidden".

Now, to stop automatic numbering, you right-click the page and uncheck "Number Shapes On Drop".

In general, as far as I can see, the stock solution with numbering is not that customizable from developer's point of view,
you can not add new behaviors to it, you can just use it or not as an user. There are no events like "generate new number" you could handle.
Title: Re: Uniquely Numbering Shapes
Post by: Nepherim on May 07, 2018, 03:07:07 PM
Quote from: Nikolay on May 07, 2018, 12:06:12 AM
If you want to hide the numbering properties, you could hide them in the master shape.
Means, you edit the master, set these 3 properties used by the Numbering addon to be "Hidden".
Unfortunately hiding these properties now makes them un-searchable, which in my case reduces their utility. I have worked around this though -- i have a custom Edit dialog, so can choose to hide those fields.

Quote from: Nikolay on May 07, 2018, 12:06:12 AM
Now, to stop automatic numbering, you right-click the page and uncheck "Number Shapes On Drop".
I actually don't want to allow auto-numbering to be turned off. Even though I can remove this option from the right-click page options, it still pops up when opening the model.

Quote from: Nikolay on May 07, 2018, 12:06:12 AM
In general, as far as I can see, the stock solution with numbering is not that customizable from developer's point of view,
you can not add new behaviors to it, you can just use it or not as an user. There are no events like "generate new number" you could handle.
This is unfortunate. At this point, I'll probably need to return to a fully custom sequencing solution. I'll add a doc property maintaining the sequence upper-bound. The if I check for sequence existence on the on-drop event, on-save, and my custom report-menu options that should get me to a reasonable point of ensuring objects have a UID assigned.