Limit line length to a multiple of a value

S

SirRounded

Hi all,

I'm trying to limit the length of a line to be a multiple of a certain
value (for example, it can be 3 in., 6 in., 9 in., etc.) and I'm
having some trouble figuring out how to do this.

Note that this isn't the same as having the grid set to 3 in, because
I want the line length to be a multiple of 3 in. no matter what angle
it's at.

It would be great to be able to do this through the Shapesheet, but it
wouldn't be a problem to do this through code (we already have Visio
add-in code running for our application).

What I've tried so far:
1) using the BOUND function in the Shapesheet.
This was hurting my brain for multiple reasons. First, the length of
a line (the "Width" cell) is a calculated cell, not a pure value, so I
didn't know how to incorporate the BOUND function. In addition, I
didn't know how to limit the values using the BOUND function.
Normally I would use something like: IF(MODULUS(Width, 3) == 0)...

2) Trapping the BeginX/EndX/BeginY/EndY cell changed event
I think this is my best bet so far. The idea being that when the
BeginX/EndX/BeginY/EndY cell changes, set the appropriate cells to
make the length work out to be the nearest multiple of the given
value. So if the BeginX changes, set the BeginX and BeginY so that
the line length is a multiple of 3. One unfortunate side-effect is
that apparently the Cell Changed event isn't fired while dragging (in
2003), so the user would have to drag the endpoint, drop it, and then
the length would snap to the correct length. Would be nice to snap
while dragging...

Does anybody have any suggestions?

Thanks for your help,
Kevin
============================================
(e-mail address removed) or (e-mail address removed)
============================================
 
J

J Kallay

I think that setting the X cell of the LineTo row in the Geometry section to
INT(Width/3)*3 should do the trick.
 
S

SirRounded

That's very close! I just tried that and the line shows the correct
length, even while dragging. The only problem is that the EndX and
EndY are still wherever the user left them (they no longer match the
end of the drawn line). This is a problem, since the line will need
to be connected to other shapes.

However, this solves the problems I was having with 2) in that the
line will look correct while dragging. What I can probably do is set
the BeginX/BeginY/EndX/EndY as apporpriate after the user stops
dragging, and then the endpoints will pop back to the drawn line!

Thanks!
Kevin
 

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