Sum/count/access member shapes of container

Started by Noisy Cricket, June 10, 2015, 06:28:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Noisy Cricket

Hi all,

Working on a Visio solution that should allow dynamic/repetitive modelling of vessel load-out operations i'm looking to using containers to act as "skid tracks" (look that up) which in turn are used by "skid shoes" to run across. Essentially the skid shoes will be shapes (or groups of shapes) and the skid tracks would be containers. Using containers would allow me to use the categories function to only allow skid shoes to be placed within/on top of them.

Question is: can containers dynamically be updated to sum/count shape data of the shapes inside the container (skid shoes) or would this, by default require running a VBA macro?

(for comparative purposes: say you have a container being a "store" and the shapes inside being boxes containing a number of apples, pears and oranges. (someone wasn't taking care while putting fruit in the boxes and it's all mixed up). nonetheless, I want the container shape to tell me how many oranges, apples or pears are inside and update when boxes are added/removed.)


Just Wondering.

Nikolay

As far as I know, this will require some code, but can be done automatically (i.e. you wont need to run a macro by hand every time)
With shapesheet-only approach, I think the best that can be done is counting shapes in container using CONTAINERSHAPECOUNT() function, but no filtering by shape type is foreseen.

There are 2 related VBA events:

- ContainerRelationshipAdded
- ContainerRelationshipDeleted

Noisy Cricket

#2
And then the idea would be to loop through the shapes in the container and extract the respective data?
I've not worked with containers and underlying command yet so it'll take some time to "get my head around it".

I'll look into those two events.

Found this: ContainerProperties.GetMemberShapes Method (Visio)
Returns the shape identifiers (IDs) of all members of the container, as specified.

Suppose when having the array of ID's it's a matter of looping through those shapes and summing/counting as normal.

Thanks!

Noisy Cricket

Ok so....... yet again resorting to appending someone else's code (think it's Paul Herber's that did the trick).

Also found an older post here on Visio Guy: http://visguy.com/vgforum/index.php?topic=325.0

Happy hunting!

Gijs