Interactive DIP Switch Shape

Started by YossiD, February 08, 2009, 10:26:05 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

zhuravsky

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

#16
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

wapperdude

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

zhuravsky

Some new fuctionality. Now you can change the number of switches from 1 to 10 just sliding a control.

Visio Guy

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

May be somebody has a shape for JUMPER ?

DC Kelley

I am dense, but how does this line "connect" to the ligh bulb shape and cause it to turn on or off?

=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:
QuoteAll 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

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

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

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

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

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

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

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

Quote from: zhuravsky on February 21, 2010, 06:23:47 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