Author Topic: formula disappear when drag and drop from stencil  (Read 236 times)

0 Members and 1 Guest are viewing this topic.

Lmontenegro

  • Newbie
  • *
  • Posts: 9
formula disappear when drag and drop from stencil
« on: August 10, 2020, 12:51:49 PM »
Hello Everyone

I am adding a drop-down feature to my shapes. I created the formulas on the ShapeSheet to ask the user to assign a Layer as soon as the shape is added to the drawing.

On the stencil the formulas look ok, but when I am grab and drop the shape from the stencil to the drawing, the formula I wrote on the stencil for "Layer Membership" just disappear.

On the screenshot attached...
"ShapeSheet on Stencil.png" show the code on the shape. The "Layer Membership" section shows the formula =User.assign2Shape

BUT,
"ShapeSheet on Drawing.png" when I grab and drop the shape to the drawing, the formula on "Layer Membership" is nos appearing, just brings "0"

How can I fix this issue?

Thanks in advance
« Last Edit: August 10, 2020, 12:57:19 PM by Lmontenegro »

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2929
    • Paul Herber's website
Re: formula disappear when drag and drop from stencil
« Reply #1 on: August 10, 2020, 01:06:33 PM »
Does the layer exist on the page where you are dropping the shape?

Electronic and Electrical engineering, business and software stencils and applications for Visio -

https://www.paulherber.co.uk/

Surrogate

  • Hero Member
  • *****
  • Posts: 1014
    • ShapeSheet™ Knowledge Base
Re: formula disappear when drag and drop from stencil
« Reply #2 on: August 10, 2020, 03:08:00 PM »
Try add in section Events in cell EventDrop formula
Code
setf(getref(LayerMember),"user.assign2Values")
« Last Edit: August 10, 2020, 03:33:55 PM by Surrogate »

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3821
  • Ideas Visio-lized into solutions
Re: formula disappear when drag and drop from stencil
« Reply #3 on: August 10, 2020, 05:04:45 PM »
Perhaps I'm missing something but...
When you are creating the prop entry, you can have ask on drop enabled, plus provide a hint without any time extra steps.  Seems like that what you're trying to accomplish???
Visio 2019 Pro

Lmontenegro

  • Newbie
  • *
  • Posts: 9
Re: formula disappear when drag and drop from stencil
« Reply #4 on: August 10, 2020, 06:26:28 PM »
thanks Paul... well, I created manually the 3 layer before dropping the object into the drawing and I have the same issue.

Lmontenegro

  • Newbie
  • *
  • Posts: 9
Re: formula disappear when drag and drop from stencil
« Reply #5 on: August 10, 2020, 06:28:17 PM »
Thanks for your answer... I am kind of new on Visio and I couldn't find section Events. where and how can I add it?

Lmontenegro

  • Newbie
  • *
  • Posts: 9
Re: formula disappear when drag and drop from stencil
« Reply #6 on: August 10, 2020, 06:32:28 PM »
wapperdude, I am trying to generate a popup window asking for the layer where the shape needs to be placed. That's all. I haven't been able to get the list of layer, either. But something I found weird is the formula on Layer Membership just disappear when I drop the shape.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3821
  • Ideas Visio-lized into solutions
Re: formula disappear when drag and drop from stencil
« Reply #7 on: August 10, 2020, 07:11:57 PM »
Exactly!  Do that in dropdown window when you create your Data property or open shapesheet if already defined and make following entries in the Shape Data section:
>> Prompt Cell enter some text providing user with a hint
>> In Ask Cell set to True or 1

See attached example.  <Cntl> + D has same effect as dropping from a stencil.
« Last Edit: August 10, 2020, 07:14:39 PM by wapperdude »
Visio 2019 Pro

Lmontenegro

  • Newbie
  • *
  • Posts: 9
Re: formula disappear when drag and drop from stencil
« Reply #8 on: August 10, 2020, 09:43:41 PM »
thanks wapperdude for the example... this is how I am getting so far... the popup window asking for the layer.

Trying your suggestion, everything works... BUT still losing the formula on the Layer Membership section when I am dropping the shape into the stencil.

the upper part of the screenshot shows the code on the stencil, the lower part of the screenshot is when I drop the shape from the stencil into the drawing.

vojo

  • Hero Member
  • *****
  • Posts: 1513
Re: formula disappear when drag and drop from stencil
« Reply #9 on: August 11, 2020, 10:22:19 AM »
IMHO, I would consider using prop.data to do 2 things

First, list out layers available...something like
    layer1 = <NA or layer name or layer number>   ///get these from the page shapesheet….parse, etc
    layer2 = <NA or layer name or layer numbername>
    use the  fixed list format to prevent user from overwriting the these props.

Second, an entry to select the layer to use...something like
    Layer_to_place_shape = <layer name or layer number>   

so usage is
    eventondrop = docmd(1312)               // same for eventdblclk
    maybe use setf(getref(<layer cell for this ship>), layer_to_place_shape) to put layer value in the layer cell of shape
    (something like this...never did much with layers so syntax might be wrong).



Lmontenegro

  • Newbie
  • *
  • Posts: 9
Re: formula disappear when drag and drop from stencil
« Reply #10 on: August 11, 2020, 01:01:13 PM »
thanks Vojo for your help.. I think I have something pretty similar what you are suggesting, I think I am going on the right path... BUT my problem is when I grab and drop the shape into the drawing... the formula on the "Layer Membership" just disappear. Any idea what is generating that weird behavior?

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3821
  • Ideas Visio-lized into solutions
Re: formula disappear when drag and drop from stencil
« Reply #11 on: August 11, 2020, 01:02:40 PM »
Updated file.  Forgot that the LayerMember cell prefers index number.  So, the User cell formula needs to use the Lookup fcn.  Now, the attached should provide what you want...without all of the extra User formulas!

Cheers.
Note, this and the previous example from yesterday do utilize the docmd(1312) double click formula.  Although, that's more for convenience and not really needed for your task.
Visio 2019 Pro

Lmontenegro

  • Newbie
  • *
  • Posts: 9
Re: formula disappear when drag and drop from stencil
« Reply #12 on: August 11, 2020, 01:57:36 PM »
 :)Thanks a lot wapperdude, it is working now.