Author Topic: shape width resize with control point from the center  (Read 8908 times)

0 Members and 1 Guest are viewing this topic.

kiler40

  • Sr. Member
  • ****
  • Posts: 328
shape width resize with control point from the center
« on: November 02, 2013, 05:58:47 AM »
Hello Again :)

I know that maybe i`m flooding the forum but again have an idea... that i really cant see how to accomplish...
i want to control the width of the shape with control point. But i want the control point to be in the center, and when I move it left the shape to shrink from  right to left and oposite.
only for info the big shape is the parent shape

Any ideas ?
Thanks !
« Last Edit: November 02, 2013, 06:00:46 AM by kiler40 »

kiler40

  • Sr. Member
  • ****
  • Posts: 328
Re: shape width resize with control point from the center
« Reply #1 on: November 02, 2013, 06:20:45 AM »
I think the goal to suceede is to put some bounds to the small shape control point movement, and then i don`t know how to represent that the value of the control point is changing between 0 and 1, so i modifi pinX value to become sth like:

Code
PinX=Sheet.3!Width*(value between 0 and 1)

In general this should do the trick...
but i cant event make the BOUND function work ok
the yellow dot cant go further in the right....
and the value from 0 to 1... cant figure it out

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: shape width resize with control point from the center
« Reply #2 on: November 02, 2013, 12:21:10 PM »
There are two problems with the proposed approach. 
1.) The control is part of the subshape, so, it only appears when the subshape is selected; perhaps that's desired.
2.) It is trying to control the width of the shape to which it belongs and that makes a circular argument.  So far, you've not put reference to the control point into the width cell and that's  why it seems non-functional.  The bound function merely limits the range of values which it may assume.  It does not assign these values to any place in the shapesheet.  You need to enter "Controls.row_1" (or whatever the row name is) into the width cell, but, when you do, you'll get circular argument error message.  This is a serious problem.

The easiest way around it is to move the control to the group (parent) level.  Then, in the shapesheet for the subshape, in the width cell enter formula something like sheet.ID!controls.row_1, where ID is the ID number of the parent shape.  This pulls the control point value into the shape's width box.

Also, you will have to alter the subshape's formulas for PinX and LocPinX, otherwise it will expand contract around the parent's mid-point.  For the behavior you diagram, you'll need conditional statements (if) to assess the control points location and then assign appropriate values to the two PIN locations.

The harder way, assuming that you really want the control to hide, would require use of SETATREF function.  For the case that the control point is part of the shape, then, rather than using the control point to set the shape's width, use it to control the Geometry section entries.  Now the conditional statements must be effectively applied to each corner of the rectangle.  In this case, it should not be necessary to change the PIN formulas.  However, it will be necessary to add the TextTransform section such that the TextPinX can be slaved to horizontal midpoint of the rectangle.

HTH
Wapperdude

BTW, if you do get stuck, I have a solution for both cases.  But, hammer away at it for awhile....
« Last Edit: November 02, 2013, 04:18:44 PM by wapperdude »
Visio 2019 Pro

kiler40

  • Sr. Member
  • ****
  • Posts: 328
Re: shape width resize with control point from the center
« Reply #3 on: November 04, 2013, 01:00:11 AM »
it seems so much pain in the A** for a simple resize. But thanks for the deep explanation. i`ll wee what i can do.
Other thing - is there a way to make the control point return a value. but in with steps devided to the length of the control point movement.
from 0 to 10 for example

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: shape width resize with control point from the center
« Reply #4 on: November 04, 2013, 01:46:17 AM »
A pain?  Well, yes.  That comes with flexibility.  Visio does have shortcomings but, it is very customizable. 

So, all that you've needed so far can be done in the shapesheet.  The control point can return a value.  Need more information.
  1.)  How do you want the value displayed:
         a.  As shape data
         b.  As shape text
         c.  As a temporary note?  This could go beyond the realm of shapesheet and require VBA.
  2.)  In steps?  Presently, the control point has very fine steps limited by grid size and viewing zoom factor.  0 to 10 is pretty coarse.  How about 0 to 100%?  Or do you want drawing units?
  3.)  When?
        a.  Whenever the subshape is selected?
        b.  When and only when the control point moves?
        c.  When should it disappear...no timer function.  That's VBA, and not a strong feature.  So, could be when the shape is unselected...maybe.  As I think about this, beginning to sound more  like a VBA task.

Putting the info into shapedata wouldn't be too hard.  Shapedata would also be away to specify the desired location of the control point.  So, a position could be entered and if the control point is moved, that position could be used to update the shape data.  Putting it into a temporary note that pops up and disappears probably has to be VBA which would have to check for certain events. 

Is there a benefit to this?

Wapperdude
Visio 2019 Pro

kiler40

  • Sr. Member
  • ****
  • Posts: 328
Re: shape width resize with control point from the center
« Reply #5 on: November 04, 2013, 03:19:28 AM »
for example this

http://visualsignals.typepad.co.uk/vislog/2012/01/creating-a-color-picker-in-visio.html

it was too complex for me to understand the background of the color picker
But as easy example if you want to create a shape with 3 control handles, that control the color, and each one to be linked with the one of the RGB values you need the control handle move between 0 and 255 no matter how long is the shape...

I understand the flexibility of visio and shapesheet. but i`m still new to the stuff. On other hand, i have already created some shapes that are useful to me as they are, but all the time i want them to be more flexible and "user friendly" /i`m talking about my colleagues that know visio only as a drawing software/. So customizing of the shapes that i create be more or less "right click -> edit mode -> change what you want but in bounds that i have given -> exit edit mode"
And control handles can be really usefull to me.


wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: shape width resize with control point from the center
« Reply #6 on: November 04, 2013, 11:28:33 AM »
Well, since what you're asking is getting more involved, here's the Visio file as promised.  Only the lower shape has the value of the control point indicated.  This was pretty quick...no special formatting, so the precision is what the page provides, same with increment steps.

To implement the text to show/hide:
1. Convert the subshape to a group.
2. In the shapesheet Protection section, lock the calculation of width, height
3. Add User-defined section to store text display status
4. Add Action section to shapesheet to create Right click menu entries.
    a. first row just adds a "title" to the right click menu
    b. add 2nd row to implement the show/hide action.  Note, I opted just to show the appropriate action to take.  Alternative would be 3rd row and using check marks to show what's selected.

5. Add shape to hold text to the group.
6. Insert custom field to show control point X-value, converted to percent
7.  Open shapesheet for this shape
8.  To control visibility
    a. in the geometry1.noshow cell add reference to user hide/show text entry.
    b.  likewise, in the character section, add reference to the transparency cell

HTH
Wapperdude
Visio 2019 Pro

kiler40

  • Sr. Member
  • ****
  • Posts: 328
Re: shape width resize with control point from the center
« Reply #7 on: November 04, 2013, 11:39:12 AM »
WOW ! I`ll give a great read through all shapesheet fields to understaind all this !
Thanks a lot !!!!

Just to ask - as first impression: if you want to get the value in the percentage, you use simple division formula logik. In this case (if my aproach is correct) i can use a function to receive a value from that
For Example - if i want to move in the bounds from 0 to 255 i can use 50% of 255 and receive a value =127.5 and so one and so one...

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: shape width resize with control point from the center
« Reply #8 on: November 04, 2013, 11:58:33 AM »
Nothing special about the formula.  Since the position is in terms of the shape width, all I did was divide the position by the width and multiply by 100.  If you wanted to convert this to say 0 to 255 and be independent of actual shape size, then, just use 255 instead of the 100 and drop the "%" from the text field.  One of the shapesheet functions allows you to control the step size...perhaps a couple of ways, actually...the most convenient would be the modulus fcn. 

If you haven't checked this out, this is a pretty good site for getting into things:  http://msdn.microsoft.com/en-us/library/ms427031.aspx

BTW, I've changed the shape slightly and moved the control position indicating text outside and above the main shape.  Plus, it'll track with the control point.  Compare the two "text" shapes to see the difference.  By locking the calculation of the "master" subshape (ID = 10) in this case, allows you to move the text shape (ID=13) without impacting the alignment box.

Wapperdude
Visio 2019 Pro

kiler40

  • Sr. Member
  • ****
  • Posts: 328
Re: shape width resize with control point from the center
« Reply #9 on: November 04, 2013, 12:06:40 PM »
to be honest I cant all the time understaind everything in the explanation of the functions (my english is not really bad), but when it comes to understanding logic algorithms... i have somme issues. This is why i use so much this forum. people like you explain and give examples to me in a really more understandable language!
Thank you for that !!! (grab a beer from me tonight :) )
i`ll continue with my tryouts and see what i can get

Wish you all the best
Andrei

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: shape width resize with control point from the center
« Reply #10 on: November 04, 2013, 11:23:35 PM »
Don't feel bad.  Some of those explanations only look like they're written in English.  They only make sense if you already know what they do!!!   ???

Well, made one more change.  This allows you to double click the main group to toggle the control text on / off.  Gives you two ways to show / hide. 

Wapperdude
Visio 2019 Pro

kiler40

  • Sr. Member
  • ****
  • Posts: 328
Re: shape width resize with control point from the center
« Reply #11 on: November 07, 2013, 06:11:29 AM »
Hi again !
Everything is so cool, but i`m trying to make the moving part to have some fixed area around he middle (50%). for lets say fixation in the middle. No action between 49% and 51%
I have tried different stuff but no one seems to be the right one...
any ideas ?

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3833
  • Ideas Visio-lized into solutions
Re: shape width resize with control point from the center
« Reply #12 on: November 07, 2013, 12:15:10 PM »
This is not difficult, but, because of the various master and subgroup shapes, text justifications, format fills, it does become somewhat tedious.  I will explain the basic premise, then, indicate which shapes and shapesheet fields get changed, and finally provide an updated shape because of the complexity.

Basically, the Visio "IF" statement says if something is true, do this, otherwise do something else.  The form is IF(test condition, do this, do something else).  If you have more than one test condition, then you can catenate the if statements.  So, it becomes if case A is true, do this, otherwise, if case B is true, do that, else do whatever if both not true.  Probably confusing. 

You now have two conditions (well, in a sense, three.)  If control point less than 49% shrink box to the left, otherwise if control point is greater than 51% shrink the box to the right, other wise keep the box at full size.

The formula would be IF(controlPT<0.49*width, shrink left formula, IF(controlPT>0.51*width, shrink right formula, box width full))


The complication arises from
1.)  This basic formula is used many places and
2.)  the 49%, 51% may get changed on a trial and error basis.
 
You don't want to re-edit every formula each time these two numbers change.  But, these are hidden numbers, not user controllable, so they get hard coded.  To do this, I created placeholders for each number, and then made the IF statement formulas reference these numbers.

In the attached file, here's what's up:
1.  Master group shape is sheet.1. 
    a. The Text Fields section, value cell has formula for text that changes with control position.  You may want to delete this section.
    b.  The paragraph section, HAlign cell controls the justification.  You may want to delete the formula, set initial value to 1.  Normal Format UI will also clobber this entry.

2.)  The main subshape is sheet.2.  That's where the bottom text is located.

3.)  Sheet.3 is the green box subshape.
    a. Added User-defined Section to store the upper, lower deadband limits, 51% and 49%.  But as actual values, not percents.  You would change entries for User.UL, and User.LL.  Right now they're set for 55% and 45%.
    b. Revised formulas in Geometry1 section
    c.  Revised formulas in Fill section, Fill Pattern cell.  The formula has guard function, may want delete that to allow normal fill user interface.

4.)  Sheet.4 is the textbox for control position.  The Text Fields section contains formulas for what gets shown.

5.)  Sheet.5 is the arrow that points to the control point.  Keep or delete as desired.

HTH
Wapperdude
« Last Edit: November 07, 2013, 12:19:18 PM by wapperdude »
Visio 2019 Pro

kiler40

  • Sr. Member
  • ****
  • Posts: 328
Re: shape width resize with control point from the center
« Reply #13 on: November 08, 2013, 01:02:33 AM »
Pfff... thank you so much !
It come in handy !

Many Thanks !
Andrei