Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: YossiD on February 08, 2009, 05:26:05 AM

Title: Interactive DIP Switch Shape
Post by: YossiD on February 08, 2009, 05:26:05 AM
I have created a grouped shape of a DIP switch to be used in test equipment diagrams (attached). I'm looking for a way to get the individual switch to toggle between the OPEN and CLOSED positions. I thought of using EventDblClick, but I'm not experienced with that function and I haven't managed to get it to work.

I have a feeling this can be done making each switch in the bank a group of three shapes consisting of the outline and two smaller filled rectangles, one in the OPEN position and one in the CLOSED, with one of them visible and the other not. The double click event would swap the visibility attributes of the two small rectangles.

I also thought of a possibility of a right click option for the complete bank of switches that would bring up a table wherein one could specify which switches are OPEN and which are CLOSED.

All suggestions/solutions gratefully appreciated.
Title: Re: Interactive DIP Switch Shape
Post by: Paul Herber on February 08, 2009, 07:12:19 AM
Just a very quick response as I'm a bit busy ...
In the shape's shapesheet have a look at the Actions section, this is how you can add new commands to the shape's right-click menu. Toggling the menu item will change the "Checked" value, the fill formula (for example) of your shape can test this value and change the fill colour.
Or look at the formula used by the "Flowchart shapes" shape in the Flowchart stencil.

Title: Re: Interactive DIP Switch Shape
Post by: aledlund on February 08, 2009, 11:01:02 AM
sounds like a great project to implement Chris' discussion on multishapes (elsewhere on his site),
al
Title: Re: Interactive DIP Switch Shape
Post by: wapperdude on February 08, 2009, 12:11:10 PM
Take a look at the attached drawing.  It uses double click event.  It's something I did awhile back...cleaned-up the file.
Title: Re: Interactive Shapes
Post by: YossiD on February 11, 2009, 03:00:07 AM
Thanks, this is very helpful. Looks like it's more complicated to do than I originally thought, but hopefully your example will see me through.
Title: Re: Interactive DIP Switch Shape
Post by: Zigoto on February 11, 2009, 09:14:29 AM
Pls find here enclosed the Dip Switch I have made.
Right click on the shape to select Open or Closed switch

Ziorg77
Title: Re: Interactive DIP Switch Shape
Post by: YossiD on February 12, 2009, 12:54:36 AM
Whoa, looks like you've done all the work for me. Now I just have to work through it to understand how it all works.

Huge thanks.
Title: Re: Interactive DIP Switch Shape
Post by: Visio Guy on February 12, 2009, 03:41:31 AM
Nice work, Ziorg77!

I've added a modified version of the DIP switch shape. Depending on how you use it, this might be an easier way to set the switches. Instead of setting each item, you enter an 8-digit bit-mask in a Shape Data field.

So to turn all of the switches on, you enter: 11111111. To turn them off, enter 00000000

You see the Shape Data window by toggling it via: View > Shape Data Window, or View > Custom Properties Window in older versions of Visio.

This shape might come in handy, say, if you were dropping lots of them on a page using automation code. It would be much easier and faster to set the switch values. For novice users or occasional changes, the first version is much better.
Title: Re: Interactive DIP Switch Shape
Post by: aledlund on February 12, 2009, 07:02:28 AM
very slick!
al
Title: Re: Interactive DIP Switch Shape
Post by: Visio Guy on February 12, 2009, 07:53:43 AM
Ooops, I suppose the 0s should be open and the 1s closed?
Title: Re: Interactive DIP Switch Shape
Post by: Zigoto on February 12, 2009, 10:58:10 AM
Thanks Visio Guy,
It's always the same question with the Dip Switch Open=On=1 or Open=Off = 0
I use to say "OpenOffO" in one word to remember
Great job, perfect with "OPEN = ON = 0" string instead of "OPEN"

Ziorg77
Title: Re: Interactive DIP Switch Shape
Post by: YossiD on February 12, 2009, 12:22:00 PM
Thanks Ziorg and Visio guy for your excellent solutions. Not only have you provided me with the shape I need, but I have learned a lot by looking at the shape sheets for these solutions. It would have taken me days to figure this out on my own.
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on February 19, 2009, 01:16:05 AM
One more version.
No actions, no bit masks...
Just slide a switch as per usual, use mouse instead of screwdriver.
:)
Title: Re: Interactive DIP Switch Shape
Post by: YossiD on February 19, 2009, 03:00:48 AM
Thanks zhuravsky.

With three solutions now this is really an embarrassment of riches!

Where do you guys find the time to do this? I can't even find the time to try to understand exactly how the solutions work.

Thank you all.
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on February 19, 2009, 07:02:52 AM
Hi,
It takes not so much time if you know how, I spent may be 30 minutes for previous variant.
Enjoy one more variant: "3d" dip switch

Edit: images added by Visio Guy to show off zhuravsky's very cool shapes
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on February 19, 2009, 07:34:45 AM
Sorry, I did not understand that you asked how does it work.
Here are explanation for "flat" variant. I did following:

1. Draw big rectangle and convert it into group, open ShapeSheet and change DisplayMode to 1 (Group Properties section)
2. Draw two texts ("OPEN", "CLOSED"), locate them on rectangle and Add to group;
3. Draw 1 small recangle, press F2 and enter the text "1", then use TextBlock tool to shift this text down. After that duplicate this rectangle 7 times, place them inside big box, change text ("2", "3", "4"...) add to group;

Here comes the most diffuclt thing.

4. Open ShapeSheet and insert Controls section, then insert 8 rows - you will get 8 yelow controls in bottom left corner of the shape.
5. Locate each control on its place and enter necessary formulas- check them in my shape. General idea is to limit movement of the control (X-coordinate is constant, Y-coordinate - only two positions - up and down);

Now we have "casing" of DIP-switch and movable controls for each switch.

6. Draw dark small rectangle, place it inside DIP and add to group.
7. Open ShapeSheet of this DARK SMALL rectangle (not a big one!) and adjust its position (PinX, PinY) - enter Sheet.xxx!Controls.x1 for PinX and Sheet.xxx!Controls.y1 for PinY. You've got switch number 1 !
8. Same for other switches (2-8).
9. Control number 9 is used for text reposition, I hope you could understand necessary modifications in TextTransform section of main group.

All necessary additional information about cells in ShapeSheet and used functions you can find in help, just press F1!

Visio 2003 SP3


Title: Re: Interactive DIP Switch Shape
Post by: rsoby on March 10, 2009, 02:01:03 PM
wapperdude
can you provide me some insight into your on/off switch - where is the code under it - on the switch or on the drawing?? I found the IF statement where you SETF and the USER.SWDN which gets set to true or false - but where is the code that actually flips the image???
I' m trying to use this concept to allow users to turn on and off layers (have a box that gives layer description with an on/off. I have the code to turn a layer on and another to turn it off - just can't see where to put it. The code was on a control button but I had to make 2 to do the job - yours is a much more 'elegant' way to do it.

you can contact me off channel, but others may benefit from your answer

Rich
Title: Re: Interactive DIP Switch Shape
Post by: wapperdude on March 10, 2009, 07:20:12 PM
All code is in the shapesheets.  It begins with double click event.  The "if" statement checks to see what the current status is, and sets it to the opposite.  The User Defined entry (User.SwDwn) pushes down into the other shapes (both subshapes within the group and other shapes not associated with the group) and changes their visibility (Geometry NoShow) and/or color (fillforeground).  This is slightly different from the other approaches in this post for the dip switches.  Those entries use the FlipY cell in the Shape Transform section of the shapesheet.  Either approach gives the appearance of the switch toggling.  That's the basic process.  Below shows how to track down the specifics. 

If you open the switch's shapesheet, and then go to menu bar > View > Formula Tracing window, you will be able to see what's impacted by the User cell.  Also, under View > Toolbars, select Formula Tracing.  That toolbar will allow you to toggle between what shapes/cells are dependent upon the user cell in question or find out what cells influence the user cell in question.  Very handy for diagnosing what's happening within a shapesheet.

The other window you might want to open is the View > Drawing Explorer.  To get to this option though, the drawing window must be active, not the shapesheet window.  "Help" gives good explanation of these windows.

Let me know if you need further discussion.

One additional thought, you could use the double click event to run your code that controsl the layers.  The "if" statement could be used to select which macro to run.

Wapperdude
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on February 21, 2010, 01:23:47 PM
Some new fuctionality. Now you can change the number of switches from 1 to 10 just sliding a control.
Title: Re: Interactive DIP Switch Shape
Post by: Visio Guy on February 21, 2010, 06:10:03 PM
Dude, that is cool!
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on February 21, 2010, 11:47:13 PM
May be somebody has a shape for JUMPER ?
Title: Re: Interactive DIP Switch Shape
Post by: DC Kelley on April 30, 2010, 12:17:23 PM
I am dense, but how does this line "connect" to the ligh bulb shape and cause it to turn on or off?

Code
=IF(User.SwDwn,SETF(GetRef(User.SwDwn),FALSE),SETF(GetRef(User.SwDwn),TRUE))

I dont see the connection to what seems to be a shape called Geometry1

Repeating wraperdudes post:
Quote
All code is in the shapesheets.  It begins with double click event.  The "if" statement checks to see what the current status is, and sets it to the opposite.  The User Defined entry (User.SwDwn) pushes down into the other shapes (both subshapes within the group and other shapes not associated with the group) and changes their visibility (Geometry NoShow) and/or color (fillforeground).  This is slightly different from the other approaches in this post for the dip switches.  Those entries use the FlipY cell in the Shape Transform section of the shapesheet.  Either approach gives the appearance of the switch toggling.  That's the basic process.  Below shows how to track down the specifics. 

If you open the switch's shapesheet, and then go to menu bar > View > Formula Tracing window, you will be able to see what's impacted by the User cell.  Also, under View > Toolbars, select Formula Tracing.  That toolbar will allow you to toggle between what shapes/cells are dependent upon the user cell in question or find out what cells influence the user cell in question.  Very handy for diagnosing what's happening within a shapesheet.

I thnk this is the line that does not make sense to me...   The User Defined entry (User.SwDwn) pushes down into the other shapes (both subshapes within the group and other shapes not associated with the group) and    I see the user defined cells, but not how it connects to the other three shapes. 
Title: Re: Interactive DIP Switch Shape
Post by: vojo on April 30, 2010, 01:45:04 PM
basically...     user.swdn = !user.swdndn     ....when this cell is hit via user action or thru a chain of cell changes started by user action.

probably in the fill color  (dont have the shape so dont know)...something like

color = if(user.swdn, rgb<"yellow">, rgb<"dark grey">)

If you are looking at the shape sheet....can set view to values and see what is what when "yellow" vs when "dark grey"
user.swdn will be "1" in the "yellow" case and "0" in the "dark grey" case
Title: Re: Interactive DIP Switch Shape
Post by: vojo on April 30, 2010, 01:48:00 PM
other shapes would do something like

if(sheet.1!user.swdn, rbg<("yellow">),rgb(<"dark grey">))

sheet.1 defines which shape on the page to go look at.

Not uncommon to have 100s or 1000s of shapes in complex picture.....sheet.1296!user.swdn
Title: Re: Interactive DIP Switch Shape
Post by: wapperdude on April 30, 2010, 02:42:41 PM
There are two main events that must happen to represent the switch "turning the light on and off". 

The 1st event is the switch itself.  It must "toggle" between on and off.  The switch is a grouped shape.  So, the sub-group shape, sheet.1, uses the value of User.swdwn to toggle Geometry1.NoShow between true and false and at the same time toggle the Geometry2.NoShow between false and true.  Thus, by changing the visibility, the group appearance will toggle between on and off.  By cleverly arranging these shapes, it also hides / shows the "On" and "Off".

The 2nd event is the lights turning on and off.  It's a similar behavior.  The User.swdwn value is used to toggle the visibility of the lights, and it is used to toggle the color of the "background", so that when the lights are off, the room is dark.

If you select the switch and open its shapesheet.  Then, go to menu bar > View > Formula Tracing Window.  Then, on the menu bar, you can select Trace Dependents or Trace Precedents.  If you select the User.swdwn entry, the FTW will show you what cells control the value of the selected cell or what cells are controlled by the selected cell.

HTH
Wapperdude
Title: Re: Interactive DIP Switch Shape
Post by: mrphysics90 on May 11, 2010, 01:04:51 PM
All,

Having looked at all of your great work, I actually need a DIP Switch for more than 10 positions.  I also wanted to learn a bit about making my own shapes, so using your work I recreated my own 12 position DIP Switch.  I also used some articles from Visio Guy to scale the text so the shape could be made smaller and the text would scale with it.  Thanks for the great site!

mrphysics90
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on June 03, 2010, 11:12:48 AM
It is a miracle...
Yesterday I needed DIP switch for 10 positions and was going to redesign my own shape...
So, thanks! You saved my time :))
Title: Re: Interactive DIP Switch Shape how about a utility switch?
Post by: paidcritic on July 13, 2010, 10:05:09 PM
Electrical One-line drawings for the power grid are the basis for many operational procedures or guidelines.  Documenting the various switch positions for normal, bypass, and other maintenance conditions can be tedious.  It would be really helpful to have an 'active' switch element to toggle on/off to use to create drawings of the desired operating condition.  I have looked at this thread - can make the basic group for a 4 position pad mount, but cannot figure out how to get the switch to show the OPEN and CLOSED position - I need to change the switch arm.  I have attached the drawing I am working on - can get the controls positioned but need some logic to show either the OPEN arm or the CLOSED arm.  Suggestions would be welcomed,  Thanks.
Title: Re: Interactive DIP Switch Shape
Post by: Jumpy on July 14, 2010, 04:23:04 PM
Hello,
I would not work with control handles or sth.
I would give the (group)shape some Boolean-ShapeData.
Prop.S1 to Prop.S4 that are for example True if switch is closed and False otherwise.

Depending on that Data the concerning switch is displayed open or closed. That would have to be implemented in ShapeSheet formula.

If you later want to change the status of a switch u use the shapedata window. I would not recommend dblclick because it will be difficult to hit the right sub-shape with dblclicking and the group has to be changed so that subshapes get selected on first click and the group on the second and that is bad, when you want to move the group arround.
Title: Re: Interactive DIP Switch Shape
Post by: dkcorreia on January 04, 2013, 05:15:51 PM
Some new fuctionality. Now you can change the number of switches from 1 to 10 just sliding a control.

This is SO great. This just saved me.  How can I make increase to 12 switches?  That would solved all of my issue.

Thanks
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on January 07, 2013, 02:08:36 AM
Here you are.
12 DIP switches
Title: Re: Interactive DIP Switch Shape
Post by: dkcorreia on January 07, 2013, 02:53:13 AM
This is so very helpful!  I cannot wait to impress my team with this.  I am having one more issue.  When I slide it down to 4 switches and save it as SVG (which is our standard format for graphics in imported into FrameMaker) it saves the extra white space on the right.  Do you know of a fix for this?  I so appreciate your time.
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on January 07, 2013, 09:13:24 AM
Hm..
I'm sorry, I've created this DIP-switch so long ago that I already do not remeber its internal structure. If I did that white rectangle then it was necessary. I will check if it is possible remove it or not (sure that possible). Wait please.
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on January 07, 2013, 09:53:39 AM
Modified DIP-switch without white area
Title: Re: Interactive DIP Switch Shape
Post by: dkcorreia on January 07, 2013, 05:11:51 PM
That is sooo close.  When I save it it still saves that extra unused space on the right side.  I appreciate your help so very much.  I need to learn how to do this fancy stuff.  I don't want to take up any more of your time.  THanks SO MUCH zhuravsky!! 
Title: Re: Interactive DIP Switch Shape
Post by: zhuravsky on January 08, 2013, 01:12:24 AM
Actually that space is not "unused". In this area shape keeps unvisible switches. Idea is following: when you move "Size" control shape checks if X-coordinate of "Size" control > then X-coordinate of "
Switch-nn" control and if not then corresponding switch changes to invisible state. This means that switch still occupies some extra space, but it is not visible.
Title: Re: Interactive DIP Switch Shape
Post by: phil2 on November 02, 2014, 05:56:19 AM
I can see by the dates that I'm late to the game again, but hey nice work!  It may seem simple, but this impressed my little group of users.
Title: Re: Interactive DIP Switch Shape
Post by: hidden layer on October 10, 2019, 10:56:06 AM
Hi there,
just stumbled across this older thread...

I had the same question and I solved it in Excel the other way round. just type in a number and the Position of the Switches will be shown. then you can copy it to somewhere else as a pic.

have fun
hl