formula disappear when drag and drop from stencil

Started by Lmontenegro, August 10, 2020, 05:51:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Lmontenegro

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

Paul Herber

Does the layer exist on the page where you are dropping the shape?

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

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

Surrogate

#2
Try add in section Events in cell EventDrop formula
setf(getref(LayerMember),"user.assign2Values")

wapperdude

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

thanks Paul... well, I created manually the 3 layer before dropping the object into the drawing and I have the same issue.

Lmontenegro

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

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

#7
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.
Visio 2019 Pro

Lmontenegro

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

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

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

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

 :)Thanks a lot wapperdude, it is working now.

Lmontenegro

Hello, I am using the code to assign layers when I drop a shape. It is working, however, I would like to load the dropdown menu with the existing layer names on the page. I have been trying with the following formula, but it is not working when I drag a shape from the stencil.

User-defined Cells:
User.LayerData = SETF(GetRef(LayerMember),LOOKUP(Prop.LayerData,User.LayerList))
User.LayerList =  ThePage!Layers.Name&";"&ThePage!Layers.Name[2]&";"&ThePage!Layers.Name[3]&";"&ThePage!Layers.Name[4]

Shape Data:
Prop.colorShape
Format = User.LayerList
(Value)  =INDEX(2,Prop.LayerData.Format)







Surrogate

#14
Which visio version do you use?
I find this topic Visio shapesheet get Layer index from name
My suggest from that topic dont work with Visio 2013 and newest versions...