Dimension

R

Ryan T Akers

If i have two objects spaced apart by a given dimension, and i wish to
increase this space to a larger dimension, how do i input the dimension i
wish to see between the two objects? I know that i can move the objects apart
with the mouse or keyboard, but quite often this is not good enough. If i
click on the dimension to change what it reads, it does not move the object,
it merely updates what is displayed.
Your help would be greatly appreciated.
 
J

John Goldsmith_Visio_MVP

Hello Ryan,

Take a look at the Size And Position window (via the View menu) and alter
the X Y values. This will give you an exact positioning.

A few things to bear in mind:

1) These X Y values refer to the shape's PinX PinY which are generally
positioned at the centre of the shape. (The implication being that if you
know the position of one shape and want to create a set gap between it and
another then you need to take into account half of the width of each shape.)

2) The Size And Position window can expect formulae. For example, for a
20mm wide shape, "Width*2" would result in a value of 40mm.

3) All values in the Size And Position window are really refering to the
shape's underlying 'ShapeSheet'. Have a look at the first section of this
post for more information:

For more information on shape geometry and how PinX and PinY work have a
look at this link:
http://visualsignals.typepad.co.uk/vislog/2007/10/just-for-starte.html

http://msdn.microsoft.com/en-us/library/aa200965(office.10).aspx

Finally in terms of your non-moving shapes (through dragging), this may be
due to you page grid's snap settings. For more information on this, have a
look over here:
http://msdn.microsoft.com/en-us/library/aa201723(office.10).aspx

Hope that helps.

Best regards

John


John Goldsmith (Visio MVP)
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
R

Ryan T Akers

Thanks John,
I know of this functionality, however it is rather a convoluted way to gain
the solution i require. I take it due to the fact that you have not mentioned
it, nor does a search yeild results, that a simple input of the required
dimension is not available for visio, in a similar capacity to the way that
Autodesk Inventor or Solidworks function.
We use Visio for designing switchboards and the drawings do get rather
technical and complex. I know that we are probably pushing the boundaries to
which visio was designed, and personally i would use a cad based program to
do this work, however the senior members of my firm have been brought up on
visio and do not know how to use cad and therefore we are stuck with Visio. I
have been given the task by them to find a solution to out dimensioning
dillema.
 
J

John... Visio MVP

Or you could write your own routine

Sub SeperateShapes()

Dim shp1 As Visio.Shape, shp2 As Visio.Shape
Dim PinX1 As Double, PinY1 As Double, PinX2 As Double, PinY2 As Double
Dim lPinX1 As Double, lPinY1 As Double, lPinX2 As Double, lPinY2 As Double
Dim W1 As Double, H1 As Double, W2 As Double, H2 As Double

Dim SepDist As Double

If Visio.ActiveWindow.Selection.Count = 2 Then

SepDist = InputBox("Enter the desired distance between shapes:",
"Seperate Shapes")

Set shp1 = Visio.ActiveWindow.Selection(1)
Set shp2 = Visio.ActiveWindow.Selection(2)

PinX1 = shp1.Cells("pinx").Result("inches")
PinY1 = shp1.Cells("piny").Result("inches")
PinX2 = shp2.Cells("pinx").Result("inches")
PinY2 = shp2.Cells("piny").Result("inches")
lPinX1 = shp1.Cells("locpinx").Result("inches")
lPinY1 = shp1.Cells("locpiny").Result("inches")
lPinX2 = shp2.Cells("locpinx").Result("inches")
lPinY2 = shp2.Cells("locpiny").Result("inches")

W1 = shp1.Cells("Width").Result("inches")
H1 = shp1.Cells("Height").Result("inches")
W2 = shp2.Cells("Width").Result("inches")
H2 = shp2.Cells("Height").Result("inches")

shp2.Cells("PinX") = PinX1 + SepDist + (W1 - lPinX1) + lPinX2

End If

End Sub

John... Visio MVP
 
R

Ryan T Akers

Ok John, Now we are getting somewhere!
I take it that i go to tools, macro, VB editor, then paste the code into the
resulting window. I've done this and saved.
Now i go to visio, put two shapes on the page, select them both and run the
macro. I get a syntax error.
The other thing is, to change it to MM instead of Inches, do i change the
references to inches to MM or millimeters?
 
J

John Goldsmith_Visio_MVP

Hello Ryan,

Probably the following line being run over two lines (due to the newsgroup
wrapping)...

SepDist = InputBox("Enter the desired distance between shapes:",
"Seperate Shapes")

....it needs to be a single line.

In terms of units, yes, just replaces "inches" with "mm" and add a Results
property to the final line:

shp2.Cells("PinX").Result("mm") =.....

Finally although I like John's code it strikes me that if your shape's
matched your grid then you wouldn't have this problem unless I've
misunderstood what you're doing. Did you read through that last link in my
previous post?

Best regards

John


John Goldsmith (Visio MVP)
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
J

John... Visio MVP

Thanks John for taking the morning shift.

Ryan, Visio's internal units are in inches, so you can follow John G's
suggestion (which I like) or you can make sure that the units entered for
the seperation are converted to inches.

The grid may also be a solution, but it sounds like he is looking for a
specific gap between objects that may not nicely lime up with the grid. For
example, a 3cm gap, but the edge of the first object ends at 45.25cm.

John... Visio MVP
 
R

Ryan T Akers

Thanks John(s),
I have made the changes as suggested and can now separate the items by an
entered amount. How would I change the code to work in a vertical axis also?
And can i change the connection points that I am measuring from? For
instance, in some cases i might want to have a dimension between centre
points, whereas in other cases i might want a edge to edge dimension.
I take it there is no way to simply enter the required dimension into a
previously defined dimension shape?

Thanks,
Ryan Akers
 
J

John Goldsmith_Visio_MVP

Hello Ryan,

I'm not sure if you mentioned whether you're using Professional or Standard
version, but if it's the former there's a "Move shapes..." addon option that
you might find useful under Tools / Addons / Visio Extras (it enable
horizontal and vertical movement). See this for info on some other
differences:

http://visualsignals.typepad.co.uk/vislog/2009/01/visio-extras-add-ons-a-version-comparison.html

....there's also an Array Shapes.. option that might help as well.

For vertical movement using John's code, you can see that he's already
collecting the relevent Y values, so you just need to use them in the same
way he's used the X ones. You can also see that he uses the Inputbox
function to ask the separation question, so you could add a (boolean)
question like:

Dim IsMeasuredFromEdge As Boolean ' I like verbose names :)
IsMeasuredFromEdge = InputBox("Separate shapes from edge?")

Then is IsMeasuredFromEdge is True you can calculate from the edge and from
the centre if it's False.

Let me know how you get on.

Best regards

John


John Goldsmith (Visio MVP)
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
J

John... Visio MVP

If you check the code, the measurement is from edge to edge based on John
G's suggestion.

John... Visio MVP
 
W

WapperDude

By checking the code, John, you're referring to the last line that computes
the new PinX of shape2.

Not everyone may be familiar with LocPin's, and not realize that the formula
does edge to edge. VisioGuy has a nice picture and download zip file
depicting the relation between Pin and LocPin:
http://www.visguy.com/shapes/visio-art/. (You have to scroll down the page a
little to find the graphic.)

John's formula accounts for situations where PinX, PinY may or may not be in
the center of either shape, because of changes to LocPins.

HTH
Wapperdude
 
R

Ryan T Akers

For the record we are using the standard edition.

I've shown this solution to my boss, who is after a solution, and he is not
interested in the slightest at this resolution.

He wants to be able to be able to put a dimension onto two handles, and then
input a value to the dimesion box and have those objects move to fit the
input data.

Is this possible? Yes or No.
 
W

WapperDude

I'll give you a possible solution which may spur either of the John's to come
up with a more elegant approach.

Let me preface this by saying that part of the issue is the order in which
items are glued together. Usually, the shapes are placed, and then the
dimension shape added. That way, it is glued to the two shapes and changes
with their movement. Doesn't work the other way around. But...

Take your basic dimension shape and add two connector points, one on each
leg end that normally attaches to the shapes. Open the shapesheet and make
sure that the Type / C cell value is "0". (No quotes.)

Now, add connection points to the shapes in question. Again, open their
shapesheets and make sure the connection point Type / C cell value is "1".
"2" may work, but I didn't try it.

Place your shapes as normal. Place the dimension as usual. Note, it will
not glue to the shapes. Now, select and nudge each shape and they will glue
to the dimension line. At this point you have several options. You can
select the dimension line and drag it and the shapes will follow, drag one
end and the attached shape will follow, if you have the Size and Position
window open, then in the length entry, you can enter a value and the
dimension line will update, change length, and the shapes will shift
appropriately.

With a little more editting, you could control the dimension line by
directly entering a value as a shape property.

Two caveates: 1.) Selecting and moving the shapes will unglue the
dimension line, and 2.) once glued, the shapes will track the dimension line
unless gluing is turned off or the dimension line deleted.

Anyway, this is about as good as can be done without use of macros. I
suspect the other programs you refer to have such coding built in. It is not
a normal Visio feature. Don't know about Visio 2010.

HTH
Wapperdude
 
W

WapperDude

Update: If all connection points are set to Type / C = "2", then gluing can
go either way, dimension to shape or shape to dimension. But it's still
order dependent. If the shapes are first and then add dimension line, then
the dimension is the "slave". If dimension line 1st, and shape "glued" to
it, then dimension is the "master" and shape positions are "slaved" to it.

Wapperdude
 

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