Author Topic: Interactive DIP Switch Shape  (Read 35984 times)

0 Members and 1 Guest are viewing this topic.

zhuravsky

  • Jr. Member
  • **
  • Posts: 46
Re: Interactive DIP Switch Shape
« Reply #15 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



rsoby

  • Jr. Member
  • **
  • Posts: 14
Re: Interactive DIP Switch Shape
« Reply #16 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
« Last Edit: March 10, 2009, 03:04:08 PM by Visio Guy »

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3824
  • Ideas Visio-lized into solutions
Re: Interactive DIP Switch Shape
« Reply #17 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
« Last Edit: March 10, 2009, 09:17:12 PM by wapperdude »
Visio 2019 Pro

zhuravsky

  • Jr. Member
  • **
  • Posts: 46
Re: Interactive DIP Switch Shape
« Reply #18 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.

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1716
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: Interactive DIP Switch Shape
« Reply #19 on: February 21, 2010, 06:10:03 PM »
Dude, that is cool!
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

zhuravsky

  • Jr. Member
  • **
  • Posts: 46
Re: Interactive DIP Switch Shape
« Reply #20 on: February 21, 2010, 11:47:13 PM »
May be somebody has a shape for JUMPER ?

DC Kelley

  • Jr. Member
  • **
  • Posts: 34
Re: Interactive DIP Switch Shape
« Reply #21 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. 

vojo

  • Hero Member
  • *****
  • Posts: 1515
Re: Interactive DIP Switch Shape
« Reply #22 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

vojo

  • Hero Member
  • *****
  • Posts: 1515
Re: Interactive DIP Switch Shape
« Reply #23 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

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3824
  • Ideas Visio-lized into solutions
Re: Interactive DIP Switch Shape
« Reply #24 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
Visio 2019 Pro

mrphysics90

  • Newbie
  • *
  • Posts: 1
Re: Interactive DIP Switch Shape
« Reply #25 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

zhuravsky

  • Jr. Member
  • **
  • Posts: 46
Re: Interactive DIP Switch Shape
« Reply #26 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 :))

paidcritic

  • Newbie
  • *
  • Posts: 1
Re: Interactive DIP Switch Shape how about a utility switch?
« Reply #27 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.

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: Interactive DIP Switch Shape
« Reply #28 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.

dkcorreia

  • Jr. Member
  • **
  • Posts: 22
Re: Interactive DIP Switch Shape
« Reply #29 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