Author Topic: SetAtRef et al.  (Read 8173 times)

0 Members and 1 Guest are viewing this topic.

spandex

  • Jr. Member
  • **
  • Posts: 16
SetAtRef et al.
« on: March 13, 2015, 09:58:15 AM »
I am looking for a "Tutorial for Dummies" on the SetAtRef.* family of functions. I have the Visio 2003 Developer's Survival Pack as well as a pair of entries from a Microsoft blog. Unfortunately, we dummies need a much more detailed explanation. Google did not have much to offer.

Thanks.

Surrogate

  • Hero Member
  • *****
  • Posts: 734
Re: SetAtRef et al.
« Reply #1 on: March 13, 2015, 10:46:03 AM »
May be this article by John Goldsmith can help
Shapes with global values

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2961
  • Ideas Visio-lized into solutions
Re: SetAtRef et al.
« Reply #2 on: March 13, 2015, 10:49:35 AM »
Setatref() is the most mysterious function in all of Visio. Appropriately, it has the least amount of documentation.  It is definitely not something for dummies!

While you googled for Setatref, did you search this forum?  There're many posts on the topic.  Let me direct you here for starters, suspect you'll be back with more questions:  Trouble with relative position of line shape's label

Wapperdude
« Last Edit: March 26, 2015, 07:16:30 AM by Visio Guy »

vojo

  • Hero Member
  • *****
  • Posts: 1047
Re: SetAtRef et al.
« Reply #3 on: March 13, 2015, 11:14:38 AM »
it would be great if somebody on this forum could write a nice tutorial for posting on visio guy.
What the intent is in general
  -human words not abstract speak such as "container", "object", etc
  - Illustrative examples showing both the formula and result image/shape/display
  - Vary the examples to see what its actually doing

spandex

  • Jr. Member
  • **
  • Posts: 16
Re: SetAtRef et al.
« Reply #4 on: March 14, 2015, 06:03:00 AM »

spandex

  • Jr. Member
  • **
  • Posts: 16
Re: SetAtRef et al.
« Reply #5 on: March 14, 2015, 06:14:39 AM »
Setatref() is the most mysterious function in all of Visio. Appropriately, it has the least amount of documentation.  It is definitely not something for dummies!

While you googled for Setatref, did you search this forum?  There're many posts on the topic.  Let me direct you here for starters, suspect you'll be back with more questions:  [url]http://visguy.com/vgforum/index.php?topic=5968.msg24073#msg24073/url]

Wapperdude
You're right; I missed this thread. That's very helpful. It will take me a while to go through it. Thanks!

spandex

  • Jr. Member
  • **
  • Posts: 16
Re: SetAtRef et al.
« Reply #6 on: March 14, 2015, 06:39:49 AM »
I am looking for a "Tutorial for Dummies" on the SetAtRef.* family of functions. I have the Visio 2003 Developer's Survival Pack as well as a pair of entries from a Microsoft blog. Unfortunately, we dummies need a much more detailed explanation. Google did not have much to offer.
In case anyone is interested, here's what I'm trying to accomplish:

I want to be able to change the line rounding in two places and keep them synchronized: the standard Visio UI (invoked e.g. by Format | Line from the right mouse-click menu) and a custom property dialog (invoked by a DOCMD(1312) action as a result of a custom item from a right mouse-click menu).

To complicate things further, I want to add another item to the RMB menu that will enable/disable Rounding. If unchecked, the value of zero will be used. If toggling from unchecked to checked, the most recent non-zero rounding value (from either of the two sources) should be used.

Thanks!


spandex

  • Jr. Member
  • **
  • Posts: 16
Re: SetAtRef et al.
« Reply #7 on: March 14, 2015, 06:52:09 AM »
it would be great if somebody on this forum could write a nice tutorial for posting on visio guy.
What the intent is in general
  -human words not abstract speak such as "container", "object", etc
  - Illustrative examples showing both the formula and result image/shape/display
  - Vary the examples to see what its actually doing
That would be fantastic! I imagine that it would be quite an undertaking. I could easily see a whole chapter in a book devoted to it, so perhaps 10-20 pages would be a reasonable estimate.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2961
  • Ideas Visio-lized into solutions
Re: SetAtRef et al.
« Reply #8 on: March 14, 2015, 09:50:55 AM »
@ Spandex:  couple of things re what you want to do.

1.  Bad news:  SETATREF won't work for what you want to do.  There are only a limited number of shapesheet entries for which it can be used:  https://msdn.microsoft.com/en-us/library/ff765523.aspx .

2.  Good news:  you don't need it.  What you do need to use are
   A.  IF fcn to do the conditional checking...
   B.  The SETF(GETREF()) functional construct.

Basic info on these, and all shapesheet info can be found at the referenced link.  Search the forum for setf for examples.

Wapperdude

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2961
  • Ideas Visio-lized into solutions
Re: SetAtRef et al.
« Reply #9 on: March 14, 2015, 10:24:16 AM »
Correction!  MS lied.  SETATREF can be used for the corner rounding...I decided to try it since that is a UI parameter. 

So, for example, you have shape1 and shape2.  Open shape1 shapesheet and scroll to the Line Format section.  In the Rounding cell, enter this formula:  =SETATREF(Sheet.2!Rounding).  That's it.

The cool thing, it's bi-directional.  If you select shape1, change its corner rounding, shape2 inherits that rounding.  In addition, if you select shape2, change its corner rounding, shape1 inherits the rounding.

Moral of the story...try things before making suggestions   ::)  ...and, don't believe everything you read!   :o

HTH
Wapperdude

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2961
  • Ideas Visio-lized into solutions
Re: SetAtRef et al.
« Reply #10 on: March 14, 2015, 11:17:19 AM »
OK, so, my curiousity got the better of me...

Suppose that both shapes had a shapedata entry, Prop.bend.  Now, you want to use Prop.bend to control the rounding in both shapes, plus use the UI for rounding, and of course, not clobber the formulas.  Perfect scenario for SETATREF...mostly.

The temptation would be to do the following for each shape.  Shape1 shapesheet, rounding cell:  =(SETATREF(Prop.bend) + SETATREF(sheet.2!Prop.bend))*0.5.  The 0.5 factor is needed since the two results are additive.  Unfortunately, this only sort of works...the rounding of both shapes responds as expected, but, the Prop.bend cell in sheet.2 doesn't update.  Even if you don't do the 0.5 factor. 

Still wanting to keep this simple, and since SETATREF intercepts the direct changes (which is why the formulas don't get clobbered), the formula can be modified to =SETATREF(Prop.bend)+SETF(GETREF(sheet.2!Prop.bend),Prop.bend).  The SETATREF intercepts the direct change, recalcs the Prop.bend, and updates the Rounding cell.  The SETF fcn gets the Prop.bend cell in sheet.2 and updates it with the value of sheet.1's Prop.bend.  This has the added benefit that the results of the two functions are not additive...pun intended.   ::)

Of course, sheet.2's shapesheet needs similar entries, only, pointing to sheet.1.

Finally, the DblClick event has DOCMD(1312) to directly access the shapedata.

Attached is Visio file of all of the above to help visualize.  Each shape displays its own Prop.Bend and Rounding so you can see the changes in values as they happen.

Enjoy,
Wapperdude
« Last Edit: March 14, 2015, 11:19:44 AM by wapperdude »

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1003
    • Visio Shapes, Stencils and Sample Drawings
Re: SetAtRef et al.
« Reply #11 on: March 14, 2015, 11:42:47 PM »
I am using SetAtRef to change color of invisible faces of my intelligent cube.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

spandex

  • Jr. Member
  • **
  • Posts: 16
Re: SetAtRef et al.
« Reply #12 on: March 15, 2015, 06:15:07 AM »
OK, so, my curiousity got the better of me...

Suppose that both shapes had a shapedata entry, Prop.bend.  Now, you want to use Prop.bend to control the rounding in both shapes, plus use the UI for rounding, and of course, not clobber the formulas.  Perfect scenario for SETATREF...mostly.

The temptation would be to do the following for each shape.  Shape1 shapesheet, rounding cell:  =(SETATREF(Prop.bend) + SETATREF(sheet.2!Prop.bend))*0.5.  The 0.5 factor is needed since the two results are additive.  Unfortunately, this only sort of works...the rounding of both shapes responds as expected, but, the Prop.bend cell in sheet.2 doesn't update.  Even if you don't do the 0.5 factor. 

Still wanting to keep this simple, and since SETATREF intercepts the direct changes (which is why the formulas don't get clobbered), the formula can be modified to =SETATREF(Prop.bend)+SETF(GETREF(sheet.2!Prop.bend),Prop.bend).  The SETATREF intercepts the direct change, recalcs the Prop.bend, and updates the Rounding cell.  The SETF fcn gets the Prop.bend cell in sheet.2 and updates it with the value of sheet.1's Prop.bend.  This has the added benefit that the results of the two functions are not additive...pun intended.   ::)

Of course, sheet.2's shapesheet needs similar entries, only, pointing to sheet.1.

Finally, the DblClick event has DOCMD(1312) to directly access the shapedata.

Attached is Visio file of all of the above to help visualize.  Each shape displays its own Prop.Bend and Rounding so you can see the changes in values as they happen.

Enjoy,
Wapperdude

Wow, Wapperdude, I'm speechless. I really appreciate your help!

Going through your shapesheets, I have a question: when either of your shapes changes line rounding via the Shape Data dialog (dbl-click), what mechanism causes the Rounding field in the same shape to update?

Thanks so much!
« Last Edit: March 15, 2015, 06:32:47 AM by spandex »

spandex

  • Jr. Member
  • **
  • Posts: 16
Re: SetAtRef et al.
« Reply #13 on: March 15, 2015, 12:34:55 PM »
Thanks to everyone's help, I believe that I have what I need:
  • The rounding for a given shape can be set by either a Shape Data RMB dialog or a standard Visio dialog (such as Line | Format)
  • The two input methods track each other, so a change in one will cause a change in the other
  • Rounding can be turned off via an item in the RMB pop-up menu, and this causes rounding to use zero
  • If rounding is turned back on, the last non-zero value is remembered and used

A copy of the Visio doc is attached. Also attached is a PDF that shows the primary cell changes that are needed to implement this.

Thanks, again, for everyone's help


spandex

  • Jr. Member
  • **
  • Posts: 16
Re: SetAtRef et al.
« Reply #14 on: March 15, 2015, 03:01:37 PM »
Long explanation about my ultimate goal follows:

BACKGROUND
This rounding issue is part of an effort to update a stencil I  have been using and tweaking for 15+ years (IIRC, before Microsoft purchased Visio). Two shapes that were distributed with Visio (Visio Technical?) really interested me. One was a circle with a connection point in the center and several connection points around the circumference. They had no special code. The second was a connector whose begin and end points would glue to the centers of two circles. In addition, a control near each end would be glued to a circumference of a circle. The connector would then be drawn between the circumferences of the two circles; the line and arrow(s) would not go inside it. Another control, which I call the AlterCurve control, allowed the user to raise or lower the height of the center of the curve. When AlterCurve was moved or one of the circles was moved, the ends of the connector would move themselves around the circumferences so that the lines/arrows would always point to the centers of the circles.

I modified the connector shape to add two primary features:

  • Add support for a rectangular shape
  • Allow the AlterCurve control to move in both the X and Y directions, which I referred to as Skew and Height, respectively.

The curve was implemented using SplineStart and SplineKnot geometry rows. Over the years, I have added various rectangular shapes, including folder shapes, a database (or "store") shape, and a UML Actor shape.

CHALLENGE
I now need to support a general ellipse, but I needed more information on the Spline rows. Unfortunately,  these row type have been deprecated. I then considered NURBS, but that seemed like extraordinary overkill. I decided to use two straight lines and to utilize rounding to make it "curvy." That's where the rounding requirement comes from. The connector must be completely redone to remove the Spline vestiges.

I have almost everything working, but I need to do a lot of testing.

Question: would this stencil be of interest to anyone? If so, I could attach it to a subsequent post once I have it ready.

Thanks!