Author Topic: Adding an icon to a process shape then including it into an exiting stencil  (Read 1834 times)

0 Members and 1 Guest are viewing this topic.

paulricot

  • Jr. Member
  • **
  • Posts: 10
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #15 on: September 26, 2018, 10:16:50 AM »
Hi Wapperdude - I will work through your steps later on, however, I have a feeling that even though on the canvas, it will work as expected, when the working shape is dropped into a stencil, then using it from the stencil will reset all the shapesheet parameters. But we'll see.

Yacine

  • Hero Member
  • *****
  • Posts: 2510
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #16 on: September 26, 2018, 10:31:12 AM »
However...when I drop the "now working" grouped shaped onto a stencil, save the stencil then drag the now "master" shape onto the working area, it no longer works. Looks like putting these shapes into a stencil undoes all the good work from your macro.

I haven't experienced such a behaviour in the past. Would like to upload some material (shape, stencil , ...)? Either to the forum or to private message?
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3330
  • Ideas Visio-lized into solutions
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #17 on: September 26, 2018, 11:10:35 AM »
I concur with Yacine re stencil dropping behavior, and agree that if you could upload simple file would be helpful.

At my computer, followed the steps I outlined.  Worked as expected.  Copied grouped shape to stencil.  Dropped stencil shape onto drawing page.  Works as expected.

See attached.



Wapperdude
« Last Edit: September 26, 2018, 11:12:50 AM by wapperdude »
Visio 2019 Pro

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2672
    • Paul Herber's website
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #18 on: September 26, 2018, 11:28:25 AM »
I'm wondering if the grouping at step 5 happened correctly?
Electronic and Electrical engineering, business and software stencils and applications for Visio -

http://www.paulherber.co.uk/

paulricot

  • Jr. Member
  • **
  • Posts: 10
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #19 on: September 27, 2018, 06:28:33 AM »
So, using Yacine's "Group Behavior" macro, I find that when the shape is on the working pane, after transformations, it works ok.
But then if you drag & drop to a stencil, save the stencil, then pull of an example to use, it does not work properly.

(File attached - the shaded process shape is the one not from the stencil and that works. I will also try and attach the stencil)

Thanks again for your help

Yacine

  • Hero Member
  • *****
  • Posts: 2510
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #20 on: September 27, 2018, 07:59:14 AM »
@Paul,
Your observations are indeed correct. But neither have I observed this behaviour yet, nor can I explain it.
A workaround (tested) is to guard the cells. ie: include every formula or value in the object section in a "Guard( ... )" function.

My tool is in so far buggy as it doesn't yet set properly the guard function. So until I upload a corrected version, please do the adjustments manually.
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3330
  • Ideas Visio-lized into solutions
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #21 on: September 27, 2018, 08:49:12 AM »
The issue is, indeed, the lack of the guard function.  When the group is copied to the stencil, Visio overwrites non-grouped referenced values, e.g., width, height, with group references.  So, yes, before copying to stencil, the guard fcn must be added. 

So, until the macro is updated, you will, have to do some manual shapesheet editing.

Wapperdude
Visio 2019 Pro

paulricot

  • Jr. Member
  • **
  • Posts: 10
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #22 on: September 27, 2018, 09:46:19 AM »
ok Wapperdude

- so is it just "Width" & "Height" on the icon that needs changing (leave PinX, PinY, LocPinX, LocPinY alone) or do I need to GUARD the parent shape "Width" & "Height" as well?

Thanks

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3330
  • Ideas Visio-lized into solutions
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #23 on: September 27, 2018, 10:43:27 AM »
Rather than me telling you.  Just open the shapesheet of the stencil master...make stencil editable, right click the icon, edit master, select the shape, open shapesheet.  Compare the contents with your original grouped shape's (that works correctly) shapesheet.  Look at the differences and make the corrections.  This gives you hands on experience.  Close shapesheet of stencil master.  Close stencil master...say yes to update.  Now drop on the drawing page.  Should work fine.  Hint:  not every cell you named needs editing.
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 2510
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #24 on: September 30, 2018, 07:52:55 AM »
Wapperdude pushed me to finish the job ...
so I refactored the code, so as to make readable. Replaced the nested if statements by a select case on a coded combination of the operations.
I did also check the behaviour when formulaForce and Guarded options are selected. Both options work fine.

Still sometimes some formulas get lost when applying different operations in a row.
I suspect it has less to do with the operation flow of the tool, than with the order of the formulas applied to the shapes.... couldn't really get my head around it and ... gave up.
At least the code is cleaner now and the guard function works. Modified shapes can now be saved to stencils without losing their behaviour.

Cheers,Y.

PS:The code setting the formulas with select case:
Code: [Select]
            If Optsize Then op = "size_" Else op = "pos_"
           
            If OptX Then dir_ = "x_" Else dir_ = "y_"
           
            If OptProp Then rel = "Prop"           
            If OptFixed Then rel = "Fixed"            If OptMid Then rel = "Mid"            If OptMin Then rel = "Min"            If OptMax Then rel = "Max"
           
            combo = op & dir_ & rel
           
            Select Case combo
                Case "size_x_Prop":     writeFormula subShp, "width", "sheet." & pShp.ID & "!width*" & Replace(sWidth / pWidth, ",", ".")
                Case "size_x_Fixed":    writeFormula subShp, "width", Replace(sWidth, ",", ".")
                Case "size_x_Mid":
                                        writeFormula subShp, "PinX", Replace(sPinX - sLocPinX, ",", ".")
                                        writeFormula subShp, "LocPinX", "width*0"
                                        writeFormula subShp, "width", "sheet." & pShp.ID & "!width*1 - " & Replace(pWidth - sWidth, ",", ".")
                Case "size_y_Prop":     writeFormula subShp, "height", "sheet." & pShp.ID & "!height*" & Replace(sHeight / pHeight, ",", ".")
                Case "size_y_Fixed":    writeFormula subShp, "height", Replace(sHeight, ",", ".")
                Case "size_y_Mid":
                                        writeFormula subShp, "PinY", Replace(sPinY - sLocPinY, ",", ".")
                                        writeFormula subShp, "LocPinY", "height*0"
                                        writeFormula subShp, "height", "sheet." & pShp.ID & "!height*1 - " & Replace(pHeight - sHeight, ",", ".")
                Case "pos_x_Prop":      writeFormula subShp, "pinX", "sheet." & pShp.ID & "!width*" & Replace(sPinX / pWidth, ",", ".")
                Case "pos_x_Min":       writeFormula subShp, "pinX", Replace(sPinX, ",", ".")
                Case "pos_x_Mid":       writeFormula subShp, "pinX", "sheet." & pShp.ID & "!width*0.5-" & Replace(pWidth / 2 - sPinX, ",", ".")
                Case "pos_x_Max":       writeFormula subShp, "pinX", "sheet." & pShp.ID & "!width*1-" & Replace(pWidth - sPinX, ",", ".")
               
                Case "pos_y_Prop":      writeFormula subShp, "pinY", "sheet." & pShp.ID & "!height*" & Replace(sPinY / pHeight, ",", ".")
                Case "pos_y_Min":       writeFormula subShp, "pinY", Replace(sPinY, ",", ".")
                Case "pos_y_Mid":       writeFormula subShp, "pinY", "sheet." & pShp.ID & "!height*0.5-" & Replace(pHeight / 2 - sPinY, ",", ".")
                Case "pos_y_Max":       writeFormula subShp, "pinY", "sheet." & pShp.ID & "!height*1-" & Replace(pHeight - sPinY, ",", ".")
            End Select
« Last Edit: September 30, 2018, 08:00:42 AM by Yacine »
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3330
  • Ideas Visio-lized into solutions
Re: Adding an icon to a process shape then including it into an exiting stencil
« Reply #25 on: September 30, 2018, 06:52:25 PM »
For the specific case of this post, I played with the shape to enhance its smartness. 
First, the icon size and offset were parameterized.  You can immediately access the data entry by double-clicking the shape.
Second, the offsets are edge to edge defined.  Just seemed like common sense.  Plus, if the icon size is changed, its relative distance from top / left edge remains unchanged.
Third, unlike Word, where you have word wrapping around a picture, Visio has no such option (that I'm aware of).  To circumvent this deficiency, the first tab stop is defined to be the icon width + 2*horizontal offset from the left edge of the group shape.  Well, it's better than a poke in the eye with a sharp stick!

Wapperdude
Visio 2019 Pro

paulricot

  • Jr. Member
  • **
  • Posts: 10
Thanks Yacine & Wapperdude - you have both gone to a lot of trouble to help me and that is much appreciated. I will try both new GroupBehaviour and GroupTest.