is it possible to refer to my code from the shapesheet?

Started by david, January 15, 2009, 03:28:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

david

i'm asking that because i created a line shape and i put in its properties its both coordinates and its angle.  but i did not succeed writing formulas in the shapesheet so that whenever the user moves the line or rotates it, the properties change to their new values and vice versa (changing the coordinates or angle in the properties will change the position of the line in the frame).  my formulas work only in one way (the first one).  if i try to use both ways the line do unexpected things like moving to infinity (very large coordinates).  btw all my formulas are SETF formulas.

however, in my code i can always calculate the new position of the line.  is there a way that the value in the start_x property for example will refer to the variable start_x in the code.  or any similar way to use the code so that the properties will always show the right values?

thanks in advance
David

wapperdude

The problem is that this creates a circular argument for Visio.   :P  Property1 is used to set a position, then, dragging the object changes the position, which now tries to update the property1 value, which is trying to reset the position.   :o  Rather than directly linking them, you might be able to use the EventXFMod cell in the Events section.  It only triggers after a shape movement.  You might be able to enter your "update" formula for the Properties in this cell.  Maybe.   ???
Visio 2019 Pro

vojo

doesnt setatref functions break this loop.   I have used this function to allow a user to set size of a shape based on either control handles or based on custom properties.

wapperdude

Did you use the "setf" functions to update the custom properties based upon the new control point values?

Tried this in the past, results were very "jerky" and at times unpredictable, but, it may have been incorrectly implemented it.  This is a closed loop system.  What was tried:
1.)  Shape data has entries used to set the shape  --  form pops up on shape drop onto page.
2.)  These data properties set user functions which initialize the control point locations.
3.)  The control points actually set the shape in the Geometry section.
4.)  Control points may be grabbed to manually alter the shape.
5.)  Setf formula in Control points update the shape data values --  hence the closed loop.

I think that's it.   ???

A problem with the EventXFMod is that it doesn't trigger with Control Point movement, only with shape movement.   :o  :P

Visio 2019 Pro

Visio Guy

The ShapeSheet is first and foremost a spreadsheet engine, which is supposed to be downstream, which means either set a shape via data, or via the UI, but not both.

But over the years, Visio has gained features that allow us to work around this to some extent (and make a big mess, ha!)

SETATREF is definitely worth a look. In the Visio Developer Help (available in the Visio 2007 SDK), there's an example of getting a shape to snap to integral position on the page.

This works both when the user drags the shape, or when the user sets data using the Size & Position dialog, I believe--so we're close to what david needs.

But I've had problems getting SETATREF to work with polar coordinates or radial geometry.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

not setf...but setatref and its associated setatrefeval and setatrefexpr

point is....your code deals with one cell.   setatref will take input and drive to cell / drive output from cell to all other cells.

it is a bit tricky....and for shape to unrelated shape, I had a hard time ever trying to figure out what it is good for....but within a shape, seems to work pretty well.   I will say after I figured out how to use it, I decided to do it a different way cause of the complixity

wapperdude

Visio 2019 Pro

david

hi guys,
thank you so much for your answers.

i sat on this many hours.  after many many formulas in the shapesheet that didn't work i decided to do it through code (in FormulaChanged code).  now it works alot better.  it doesn't do infinity loops anymore although it sometimes changes a bit the coordinates i wrote in the properties.  for example if i write 250 in the start_x property it changes it to 249.999.  it still doesn't work in 100% and there are some cases it moves to strange locations (for some angles) so i'm still working on the formulas.  i'm glad i moved to code and i think it's almost impossible to do it through shapesheet.  there are so many cases to take into consideration (at least in my shapes).

i used so many math formulas from school.  didn't think i'll ever need them again.  too bad visio provides only the anchor point and not the four corners of the rectangle that surrounds the shapes.
anyway, hope to make it work 100%.

thanks for your help
David

wapperdude

You can play with the formating functions, e.g., format  ::) , to control how many decimal places show. 
Visio 2019 Pro

david

it's actually a problem.  because i do want to allow the user write accurate numbers (with 3-4 digits after the decimal point).

wapperdude

Typically, the error is so slight, due to precision issues, I guess, that if you use the "round" fcn to the number of decimal places desired, the number will have the desired accuracy.  Unfortunately, unless you want to get fancy with "if" statements, and checking for identical digits, you'll always see a bunch of zeroes after the decimal point.
Visio 2019 Pro

vojo

Note....even though not all displayed in a given cell, visio does know the difference between
0.0 and 0.0000000000000001  (yes more than 8 decimals).

Does not make much difference in math....but does make a big difference in things like
setatref and such (hence why I discovered the difference).