Visio Discussions > ShapeSheet & Smart Shapes

Building a Triangle Shape

**david**:

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

**wapperdude**:

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

**vojo**:

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.

**wapperdude**:

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.

**Visio Guy**:

Try the stencil:

File > Shapes > Visio Extras > Drawing Tool Shapes

Navigation

[0] Message Index

[#] Next page

Go to full version