Shapesheet's RAND() function to be executed only once on shape creation

Started by visionator, July 08, 2016, 02:08:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

visionator

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

Yacine

Write in the EventDrop cell of the shapesheet in the Evens section: setf(getref(user.varyy1), height*(0.5 + 1.0*(RAND() - 0.5)))
Yacine

wapperdude

Visio 2019 Pro

visionator

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