Author Topic: SmartShape "Containers"  (Read 7547 times)

0 Members and 1 Guest are viewing this topic.

Gordon

  • Newbie
  • *
  • Posts: 6
SmartShape "Containers"
« on: June 12, 2008, 12:19:34 PM »

Is it possible to make smartshapes that are aware of other shapes being dropped onto them or, conversely, aware when they are being dropped onto other shapes?


Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1716
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: SmartShape "Containers"
« Reply #1 on: June 12, 2008, 01:04:34 PM »
Hi Gordon,

Under Format > Behavior, there are two settings for this sort of thing:

  • Add shape to groups on drop
  • Accept dropped shapes

This, of course, takes "two to tango". A group that can accept and another shape that can be added. When you drag the add-ee over an acceptor, you get a funny highlighting around the group that lets you know that the add-ee is going to go into the group.

Unfortunately, you can't build any rules or categorize who can belong to what, and the shapes don't pick up any real ShapeSheet capabilities. I.e.: you can't build a formula that "suddenly knows" about the newly-begotten parent.

There are a few "magic" callouts in in the Visio Extras Callouts stencil that link to the shapes they are pointed to. There is a Visio add-on that sets up some of the cross-referencing ShapeSheet formulas to get this done. (The add-on comes with Visio, you don't need to worry about it) It is possible that this could be exploited.



For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Gordon

  • Newbie
  • *
  • Posts: 6
Re: SmartShape "Containers"
« Reply #2 on: June 12, 2008, 03:07:07 PM »
Thanks (chris?)

That's too bad about the lack of capability for a shape to "know" it has a parent or a child.  Thought that kind of event might be a common requirement.

I'll look into the "magic" callouts (I understand you wrote most of them?) and get back to the board if I discover anything earth-shattering...(unlikely).

Thanks again,

Gord

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1716
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: SmartShape "Containers"
« Reply #3 on: June 12, 2008, 03:33:30 PM »
If you are incorporating code into your app, then there are lots of events that you can trap to help refine your solution.

The "magic" callouts are fairly new - since they work in conjunction with a small amount of add-on code. I've been looking at them lately, because I think that little add-on could be put to other purposes. Let's just hope they don't cut it from Visio 2009! :)
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Gordon

  • Newbie
  • *
  • Posts: 6
Re: SmartShape "Containers"
« Reply #4 on: June 16, 2008, 03:13:40 PM »
I'm working with your idea to use Grouping and adding the Format > Behavior to create the child-parent relationship between shapes.

Is it possible to access the Parent property from a child object (for example to get the text of the Parent object from the child) from a shapesheet formula?

Thanks!

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1716
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: SmartShape "Containers"
« Reply #5 on: June 16, 2008, 03:46:10 PM »
Yes, if sheet.5 is the group (parent), then the sub-shape can reference ShapeText(Sheet.5!TheText).

The problem is that you can't pick this up automatically. A human, or code, has to enter the Sheet.5 part. There is not "Parent!" identifier, unfortunately. We've been asking for it for years...
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Gordon

  • Newbie
  • *
  • Posts: 6
Re: SmartShape "Containers"
« Reply #6 on: June 16, 2008, 03:54:54 PM »
So I can't use the EventDrop event in the child shape to get the Parent (unless I hardcode a known Parent name - i.e. if there was only 1 "container" on a page with a known name)?

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1716
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: SmartShape "Containers"
« Reply #7 on: June 18, 2008, 11:30:36 AM »
Ok, I see what you're up to.

Look at the Blocks With Perspective template. On the drawing page, there is a vanishing point (the V.P. shape).

When the V.P. shape moves, cells in the PageSheet (select nothing, Window > Show ShapeSheet...) track its position. Then, shapes that are dropped on the page reference the cells in the page.

Putting (user) cells in the page is a good way to create "global" variables for a drawing. And shapes that reference cells in the page will drag the page cells along into new pages or masters.

So for your drawing, you might do something like this:

In the page:

User.ContainerX = Sheet.52!PinX
User.ContainerY = Sheet.52!PinY

Sheet.52 is your container shape. The actual ID will vary.

Then, you make another shape with these formulas:

PinX = GUARD(ThePage!User.ContainerX)
PinY = GUARD(ThePage!User.ContainerY)

When you drop this shape, it will always find the middle of your container shape. You might need to add GUARD( ) around your formulas to protect them from getting broken.

There are other, more complicated techniques you could use that involve the functions SETF, or SETATREF. But see if you can get going with this first.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010