News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Building a Triangle Shape

Started by david, July 19, 2008, 09:37:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

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

#1
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
Visio 2019 Pro

vojo

#2
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

#3
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 2019 Pro

Visio Guy

Try the stencil:

File > Shapes > Visio Extras > Drawing Tool Shapes
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

david

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

wapperdude

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.
Visio 2019 Pro

wapperdude

The better triangle:  properly stretches/shrinks,rotates,modifiable with pencil tool, takes user input.
Visio 2019 Pro

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 271 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1146KB.
Tokens: post-login.
Cache hits: 13: 0.00154s for 26,729 bytes (show)
Cache misses: 3: (show)
Queries used: 17.

[Show Queries]