Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: visionator on July 08, 2016, 02:08:53 PM

Title: Shapesheet's RAND() function to be executed only once on shape creation
Post by: visionator on July 08, 2016, 02:08:53 PM
Hi,

For some reason I need a custom shape which slightly changes it's outline for each new instance. Some of the geometry points shall be moved randomly (within a certain range). So far so good. Each new instance looks different. What did I do? I used the RAND() function in the shapesheet's User-defined cells section. E.g.
User.VaryY1.Value = Height*(0.5 + 1.0*(RAND() - 0.5))
varies a value in a range between 0% and 100% of the height. In the geometry section I am using it to modify the y coordinate, e.g. in
Geometry2.Y = User.VaryY1

Unfortunately RAND() is executed all the time, so the shape outline changes on each action in the sheet. Looks funny if all shapes change their outline at the same time. But I want to have the random outline fixed after the new instance is placed on the sheet.
Is there any chance to execute the RAND() function only once on creating the instance?

Thanks, visionator
Win7-64, Visio 2013 Standard
Title: Re: Shapesheet's RAND() function to be executed only once on shape creation
Post by: Yacine on July 08, 2016, 04:17:21 PM
Write in the EventDrop cell of the shapesheet in the Evens section: setf(getref(user.varyy1), height*(0.5 + 1.0*(RAND() - 0.5)))
Title: Re: Shapesheet's RAND() function to be executed only once on shape creation
Post by: wapperdude on July 10, 2016, 09:30:24 PM
Check out this link, think it does what you want.

http://visguy.com/vgforum/index.php?topic=340.msg1503#msg1503 (http://visguy.com/vgforum/index.php?topic=340.msg1503#msg1503)

Wapperdude
Title: Re: Shapesheet's RAND() function to be executed only once on shape creation
Post by: visionator on July 11, 2016, 08:34:15 AM
Hi Yacine, Wrapperdude,

Fits perfectly. For more than one random value I created the following formula in Events/EventDrop (and the same in Actions/Action for manual updates):
SETF(GetRef(User.Rand1),RAND())+SETF(GetRef(User.Rand2),RAND())+SETF(GetRef(User.Rand3),RAND())+SETF(GetRef(User.Rand4),RAND())

See my result attached.

Thanks a lot,
visionator
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 54 (show)
Files included: 25 - 925KB. (show)
Memory used: 747KB.
Tokens: post-login.
Cache hits: 8: 0.00122s for 22,302 bytes (show)
Cache misses: 2: (show)
Queries used: 11.

[Show Queries]