Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: david on July 19, 2008, 09:37:20 PM

Title: Building a Triangle Shape
Post by: david on July 19, 2008, 09:37:20 PM
i built a triagle master (by three simple lines and 3 control points for each vertex to allow the user to make whichever triangle he wants).  i also added 6 custom properties for the coordinates of the triangle (x coordinate and y coordinate for each vertex).  my problem is that i didn't succeed making the right formulas for changing the coordinates through the custom properties.  i did succeed after many formulas to do it vise-versa (moving the triangle updates the coordinates in the custom properties to the right values) and even then it works only if i don't rotate the triangle.  somehow i'm sure that i'm working hard for nothing.  isn't there a simple way to build a triangle by its vertexes and not by its width, height and angle?

thanks in advance
David
Title: Re: Building a Triangle Shape
Post by: wapperdude on July 20, 2008, 12:35:48 AM
You may use the Geometry section of the shape sheet to specify the X-, Y- coordinates relative to each other.  The Geometry Section locates one point at (0,0), and all the others are placed relative to that point, regardless of rotation.  So, you have to do some math to do a coordinate translation mapping.  The math may be done in the User-defined Cell Section, which you will have to add if you haven't already done so.  The angle in the Shape Transform Section controls the overall orientation of the rectangle.  Note, the Size and Position Window also gives the user direct access to this angle along with the width and height of the shape.  The pencil tool may be used to grab individual vertex and move it around.

Hope this gets you headed in the right (useful?) direction.
Wapperdude
Title: Re: Building a Triangle Shape
Post by: vojo on July 20, 2008, 02:27:51 AM
You can look at these for what they are worth....have others (octagon, hexagon, etc) if you are interest
Can set by custom properties or by dragging....right click shape.
Title: Re: Building a Triangle Shape
Post by: wapperdude on July 20, 2008, 03:20:18 AM
David, I tried to re-create your steps, and here's what I found to work.
1.)  Draw your default triangle.
2.)  Create your shape data entries.  For simplicity, I made the "names" X1, Y1, X2 ... etc.  Six entries.  I added 3 more entries, the lengths of each side.  For convenience, make the values that you enter identical to your drawn shape.  Also, you might want to check the box:  ask on drop.
3.)  Open the shape sheet:
       Shape Transform:
       Use the max fcn for both width and height.  Width will be the greater of X2-X1 and X3-X1.  Likewise for height.  You may want to guard these fcns.  Don't forget the Prop prefix.

       Geometry1 Section
       Set the 1st X & Y entries to Prop.X1 and Prop.Y1.  Likewise for the next two vertices.  The last will remain unchanged as it closes the shape back to the 1st point.  You may want to guard these entries too.  I didn't try this though.

       Shape Data Section
       Enter formulas for the three line length rows in the value cells.  For exmaple:  L1= SQRT((Prop.X2-Prop.X1)^2+(Prop.Y2-Prop.Y1)^2)

Your triangle should maintain it's shape for any angular rotation.  When you bring the Shape Data table back up, the lengths will be updated.  This ought to meet your basic requirements.

Title: Re: Building a Triangle Shape
Post by: Visio Guy on July 20, 2008, 09:02:03 AM
Try the stencil:

File > Shapes > Visio Extras > Drawing Tool Shapes
Title: Re: Building a Triangle Shape
Post by: david on July 21, 2008, 05:35:01 AM
thanks for your answers
i already looked at that stencil and you can update the triangle there by its pinx, piny, width and height.  and not by its six coordinates like i wanted.

btw, i looked at the triangle shapesheet and i don't understand where are all the formulas that update the size/position of the triangle on the frame after the user changed the details on the size/pos properties?

wapperdude, thanks for your steps but it still didn't work for me.  i sent you a personal message.

thanks
David
Title: Re: Building a Triangle Shape
Post by: wapperdude on July 21, 2008, 06:20:31 PM
Hi David --

This is a follow-up reply to your email.  I can attach the file here, in case anyone wants to look at it and make suggestions and recommendations.
Title: Re: Building a Triangle Shape
Post by: wapperdude on July 22, 2008, 01:37:57 AM
The better triangle:  properly stretches/shrinks,rotates,modifiable with pencil tool, takes user input.