shape dimensions driven by linked data

Started by oompa_l, May 09, 2008, 06:19:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

oompa_l

I have an excel spreadsheet with two columns of numerical values that I would like to use for the X and Y dimensions of each rectangle a row is linked to...is this possible?

Lars-Erik

#1
Yes this can be done.

How? Well... This is one way of doing it

Use the build in wizard to link Excel to Visio (There are some posts on this forum, I won't go into this deeper).
After that the size data should be linked into Visio's custom properties.
Because you want to import the size of the shape and not some properties we are going to make the shape get its size from these properties we just imported.
To do this you'll need to change the shape's ShapeSheet. It's really easy.

Here's an example of how this could look:



I got to go now ( meeting ) If you need more help. Let us know.

- Lars-Erik

oompa_l

#2
Thanks!

that was very easy. The only problem is I have almost 70 entities that need this transformation. I tried copying the shape I practiced on over to a new one but the shape sheet data became consequently fixed constants in the duplicated - where the first one had a dimension that was equal to the cell in the linked data sheet, the new one loses this parametric quality and is just the number of the previous shape. What's the best way to do this globally?

Should I first place all shapes on page, link data, then select all, and make the edit to the shape sheet? or can I do something to the shape before I even link the data?

thanks

Lars-Erik

#3
Mmmm, I see. I'll try and find a way around that.

Here we go, you're probably doing this:
Dragging the shape while holding Ctrl. (it seems to change the custom fields in width and height to static values)

This will work:
If you select your shape, copy it using ctrl + c, and then paste it using ctrl + v. The custom fields will stay in tact. that way you can link the new data again and it WILL change size accordingly.

Visguy, do you know why this is? might make a nice article to explain the difference in the ways of copying shapes?

Let me know if this works for you as well.

- Lars-Erik

oompa_l

you're right, that's what I was doing. Your solution works...but still there's no other way to globally change that?

I have a couple of other questions...I could repost but since I have your attention:

1- I need help implementing VisioGuy's connect shapes to each other, http://www.visguy.com/2008/03/17/connect-all-shapes-to-each-other/ . Do I need to change anything in that script to get it working for me? Do I need to change any variables? I am new to VIsio and VBA and I cant afford to learn this language...

2- Is there a way to rotate text in data graphics?

Thanks!

Lars-Erik

Quotebut still there's no other way to globally change that?
What do you mean exactly? I dont quite understand. If you copy that shape using ctrl + c ; ctrl +v you can make as many shapes as you want. Or do you mean that there are like 20 different shapes with different properties, sizes whatever that all need to resize on excel data?
In that case: I'm not aware of any way of changing a shape sheet cell in multiple shape sheets at a time. though me not knowing about an option doesn't mean there is none. Chris (Visguy) has loads more experience with Visio so lets hope he give his thoughts.
If i misunderstood, explain it with some more detail...

1- Ill have to check (ill try to get back to you tommorow)
2- Yes, in the shape sheet again. look for the section called "Textblock format". There should be a cell called TextDirection, it has two options. LefttoRight and ToptoBottom.

oompa_l

about issue 2 - thanks..i should've specified that I want to change the orientation of the text in the data graphic callout...is that possible?

Lars-Erik

I skipped true the code (i dont know all of it myself but Chris his comments are pretty clear).

Quote'// For this example, we will get all shapes on the page
    '// that ARE NOT of these:
    '//
    '//  1. Connectors
    '//  2. Foreign objects (like Buttons)
    '//  3. Guides

It doesn't look for a certain shape. it gets all the shapes that are not of this kind and connects them. So I dont see a reason why you cant use the code as it is.

Try it, you'll know either way if it works or not :D (maybe try it on a copy of your file so you cant mess anything up?)

Lars-Erik

Ok the email you send me with the picture clears things up ALOT. thanks for that.

The text you want to change in orientation is the text that Visio added using its wizzard. This should be no problem.
Select your shape that have this type of text. Then select all the instances of text that are show. Next use the right click menu to navigate to: Format ---> Protection. Uncheck the box that protects it against rotating. After this you should be able to rotate the text as pleased.

- Lars-Erik

(Image attached is the mentioned emailed picture)

PS: Select additional options when posting to attach an image.

oompa_l

thanks. that was pretty straightforward.

now that I have that sorted out, I have been pretty baffled by how the data graphic is placed - by this I mean where the text (or graphic) is placed with respect to the shape. There are tons of options, but they dont really perform as I expect. I found out where to make those changes in the shape sheet but I am overwhelmed by the variables. After I rotated the text as per your suggestion I found this formula that was controlling the Y position.

=BOUND(-0.25*Height,0,FALSE,Height*-0.25,Height*-0.25,FALSE,0,0,FALSE,Height*0.25,Height*0.25,FALSE,Height*0.5,Height*0.5,FALSE,Height*0.75,Height*0.75,FALSE,Height,Height,FALSE,Height*1.25,Height*1.25)

Where can I find a description (so I dont have to try each one and piece together what's going on) of what each one is controlling?

thanks!

Lars-Erik

The Visio SDK is a nice place for the explination of functions
In this case for the Bound function try this link:

http://msdn.microsoft.com/en-us/library/aa214155(office.11).aspx

Did you try using the "Control handle" when you select your text (or the shape im not sure which one) a yellow dot will be shown. grab and drag the yellow dot to move your text.

- Lars-Erik

oompa_l

ok lars...still struggling to understand how the text positioning works. I have fiddled around with it for a while but there are things that are beyond my comprehension. Ideally I could use the "edit data graphic option" to keep all labels aligned to the same position with respect to each one's shape. I have attached an image of the diagram I am just sketching out and because each shape ends up being very different in size (the shape dimensions are triggered by values in the database) the text ends up being in different places. Really, what I am looking for is to keep each label in the lower left hand corner, slightly offset from each edge. Then, regardless of each shape's width or height it always keeps the relationship to that corner. The "warthog" label depicts the one I want while the others are the sorts of things I am getting.

I may need to give you the whole file for you to understand what's happening.


oompa_l

just a little more detail - the anchor point (the point about which text rotates) seems to change depending on the text positioning I choose in the "edit data graphic" window. That is not what I want - I need to know where that anchor point is and have it stay fixed with respect to the text no matter what globaly positioning I am using for the text box....

oompa_l

nevermind, figured it out. I needed to change the shapesheet of the text

from

LocPinX=Width*0
LocPinY=Height*0

to

LocPinX=Width*0
LocPinY=Height*1

and now it works!

oompa_l

ok, here's a new question:

I am finding that I need to tweak the equation that governs the dimensions of my rectangular shape, but I have almost 70 shapes that have this formula. Is there an easy way to change them at once?