Switch Symbols

I initially had a single switch call that handled many different types of switches. However, that made the function very complicated to use. So I cut back to defining several types. Like Toggle, Slide, Push Button, etc..

Switch (Toggle || Slide) (SPST || SPDT || DPST || DPDT)

Description: Draws a Toggle Switch starting at point Lib_S_Start_X, Lib_S_Start_Y.
Where:
    Lib_S_RefDes - Reference Designator = "S1" || "S2" || etc.
    Lib_S_Label - Switch Label = "None " || "Power" || "On/Off" || etc.
    Lib_S_Type - Switch Type = "Toggle" || "Slide"
    Lib_S_Contact - Switch Contact = "SPST" || "SPDT" || "DPST" || "DPDT"
    Lib_S_End_Swap - Switch Ends = "Norm" || "Swap"
    Lib_S_Label_Flip - Flip RefDes/Label = "Norm" || "Flip"
    Lib_S_Rot - Switch Rotation = "R0" || "R90", || "R180" || "R270" degrees

To create DP, 3P, or 4P switches, use multiple instances of the SPST or SPDT switch.

The table below is just for testing purposes and does not include all of the possible parameters that can be passed. Parameters like Lib_S_RefDes and Lib_S_Label can be any ascii string.

ParameterDescriptionExample
Lib_S_Dwg_Obj jsGraphics Object that points to the drawing.
S1
Power
Lib_S_RefDes Switch Reference Designator
("S1" || "S2" || "S1-A").
RefDes
S1 S2 S1-A S1-B
Lib_S_Label Arbitrary Switch Label
("Power" || "On/Off" || etc.)
Label
None "Power" "On/Off"
Lib_S_Type, Lib_S_Contact Type - "Toggle" || "Toggle Ctr Off" || "Slide"
Contact
"SPST" || "SPDT" ||
"DPST" || "DPST Inv" || "DPDT"
Toggle/Slide
Toggle
Toggle CO
Slide
Contact Type
SPST
DPST
SPDT
DPDT
Lib_S_End_Swap, Lib_S_Labels_Flip Switch Ends ("Norm" || Swap")
RefDes/Label ("Norm" || Flip")
Ends Swap
Norm Swap
Labels Norm/Flip
Norm Flip
Lib_S_Rot Rotation Angle, CCW.
Rotation Angle
90° 180° 270°
Lib_S_Center_X Symbol Center X Position Show/Hide Grid (10x10), Center Mark, Pins (green dot).
Grid
On
Off
Center
On
Off
Pins
On
Off
Lib_S_Center_Y Symbol Center Y Position

Return: The switch In_X/Y and Out_X/Y are returned. In the case of Double Pole switches, InA_X/Y, InB_X/Y, OutA_X/Y and OutB_X/Y will be returned.

Note: A Lib_S_Swap value of "Swap" will swap the switch inputs and outputs. A Lib_S_Label_Loc value of "Flip" will flip the RefDes and Label from above to below the switch.

Usage: The selections from the table above, are used to create the example below. After selecting and entering your specific information, the example can be used directly, with a copy/paste. The items in Red are the only ones that need to be adjusted to your specific needs. The lines in Green are just comments and can be deleted. Due to space limitations, some of the lines below may be split onto more than one line.

// Draw S1
// Declare and Set the center point.
var S1_Center_X = ??; var S1_Center_Y = ??;
// Declare the switch return variables (C, NO, NC, Return[]).
var S1_C_X, S1_C_Y, S1_NO_X, S1_NO_Y; S1_NC_X, S1_NC_Y; var S1_XY_Return = new Array();
// Draw the symbol.
S1_XY_Return = TO_SL_Switch( Dwg_Obj, "S1", "Power", "Toggle_CO", "SPDT", "Norm", "Norm", "0", S1_Center_X, S1_Center_Y );
// Extract the switch end points (C, NO, NC) from the return array.
S1_C_X = S1_XY_Return[0]; S1_C_Y = S1_XY_Return[1];
S1_NO_X = S1_XY_Return[2]; S1_NO_Y = S1_XY_Return[3];
S1_NC_X = S1_XY_Return[4]; S1_NC_Y = S1_XY_Return[5];

Toggle_Switch (SPST, SPDT, DPST, and DPDT)

Description: Draws a Toggle Switch starting at point Lib_S_Start_X, Lib_S_Start_Y.
Where:
    Lib_S_RefDes - Reference Designator = "S1" || "S2" || etc.
    Lib_S_Type - Switch Type = "Toggle" || "Slide"
    Lib_S_Funct - Switch Function = "SPST" || "SPDT"
    Lib_S_Rot - Switch Rotation = "R0" || "R90", || "R180" || "R270" degrees

To create DP, 3P, or 4P switches, use multiple instances of the SPST or SPDT switch.

The table below is just for testing purposes and does not include all of the possible parameters that can be passed. Parameters like Lib_S_RefDes and Lib_S_Label can be any ascii string.

ParameterDescriptionExample
Lib_S_Dwg_Obj jsGraphics Object that points to the drawing.
S1
Power
Lib_S_RefDes Switch Reference Designator
("S1" || "S2" || "S1-A").
RefDes
S1 S2 S1-A S1-B
Lib_S_Label Arbitrary Switch Label
("Power" || "Enable" || etc.)
Label
Power Enable On/Off
Lib_S_Funct Switch Function, "SPST" || "DPST",
"SPDT-A" Type A and B,
and "SPDT" Type A and B)
Function
SPST
DPST
SPDT-A
DPDT-A
SPDT-B
DPDT-B
SPDT-C
DPDT-C
Lib_S_Swap Switch End Swap
("No-Swap" || Swap")
Swap
No-Swap Swap
Lib_S_Label_Loc Switch RefDes/Label Location
"" || "Norm" = Above, "Flip" = Below
Norm/Flip
Norm Flip
Lib_S_Center_X Symbol Center X Position Show/Hide Grid (10x10), Center Mark, Pins (green dot).
Grid
On
Off
Center
On
Off
Pins
On
Off
Lib_S_Center_Y Symbol Center Y Position

Return: The switch In_X/Y and Out_X/Y are returned. In the case of Double Pole switches, InA_X/Y, InB_X/Y, OutA_X/Y and OutB_X/Y will be returned.

Note: A Lib_S_Swap value of "Swap" will swap the switch inputs and outputs. A Lib_S_Label_Loc value of "Flip" will flip the RefDes and Label from above to below the switch.

Usage: The selections from the table above, are used to create the example below. After selecting and entering your specific information, the example can be used directly, with a copy/paste. The items in Red are the only ones that need to be adjusted to your specific needs. The lines in Green are just comments and can be deleted. Due to space limitations, some of the lines below may be split onto more than one line.

// Draw S1
// Declare and Set the center point.
var S1_Center_X = ??; var S1_Center_Y = ??;
// Declare the switch return variables (C, NO, Return[]).
var S1_C_X, S1_C_Y, S1_NO_X, S1_NO_Y; var S1_XY_Return = new Array();
// Draw the symbol.
S1_XY_Return = Toggle_Switch( Dwg_Obj, "S1", "Power", "SPST", "No-Swap", "Norm", S1_Center_X, S1_Center_Y );
// Extract the end points (C, NO) from the return array.
S1_C_X = S1_XY_Return[0]; S1_C_Y = S1_XY_Return[1]; S1_NO_X = S1_XY_Return[2]; S1_NO_Y = S1_XY_Return[3];

Slide_Switch (SPDT and DPDT)

Description: Draws a Slide Switch starting at point Lib_S_Start_X, Lib_S_Start_Y.
Where:
    Lib_S_RefDes - Reference Designator = "S1" || "S2" || etc.
    Lib_S_Funct - Switch Function = "SPST" || "DPDT"
    Lib_S_Rot - Switch Rotation = "R0" || "R90", || "R180" || "R270" degrees

To create DP, 3P, or 4P switches, use multiple instances of the SPST or SPDT switch.

The table below is just for testing purposes and does not include all of the possible parameters that can be passed. Parameters like Lib_S_RefDes and Lib_S_Label can be any ascii string.

ParameterDescriptionExample
Lib_S_Dwg_Obj jsGraphics Object that points to the drawing.
S1
Power
Lib_S_RefDes Switch Reference Designator
("S1" || "S2" || "S1-A").
Switch RefDes
S1 S2 S1-A S1-B
Lib_S_Label Arbitrary Switch Label
("Power" || "Enable" || etc.)
Switch Label
Power Enable On/Off
Lib_S_Funct Switch Function, "SPST" || "DPST"
Switch Function
SPDT DPDT
Lib_S_Swap Switch End Swap
("No-Swap" || Swap")
H-Swap
No-Swap H-Swap
V-Swap
No-Swap V-Swap
Lib_S_Label_Loc Switch RefDes/Label Location
"" || "Norm" = Above, "Flip" = Below
Label Norm/Flip
Norm Flip
Lib_S_Center_X Symbol Center X Position Show/Hide Grid (10x10), Center Mark, Pins (green dot).
Grid
On
Off
Center
On
Off
Pins
On
Off
Lib_S_Center_Y Symbol Center Y Position

Return: The switch In_X/Y and Out_X/Y are returned. In the case of Double Pole switches, InA_X/Y, InB_X/Y, OutA_X/Y and OutB_X/Y will be returned.

Note: A Lib_S_Swap value of "Swap" will swap the switch inputs and outputs. A Lib_S_Label_Loc value of "Flip" will flip the RefDes and Label from above to below the switch.

Usage: The selections from the table above, are used to create the example below. After selecting and entering your specific information, the example can be used directly, with a copy/paste. The items in Red are the only ones that need to be adjusted to your specific needs. The lines in Green are just comments and can be deleted. Due to space limitations, some of the lines below may be split onto more than one line.

// Draw S1
// Declare and Set the center point.
var S1_Center_X = ??; var S1_Center_Y = ??;
// Declare the switch return variables (C, NO, NC, Return[]).
var S1_C_X, S1_C_Y, S1_NO_X, S1_NO_Y; S1_NC_X, S1_NC_Y; var S1_XY_Return = new Array();
// Draw the symbol.
S1_XY_Return = Slide_Switch( Dwg_Obj, "S1", "Power", "SPDT", "No-Swap", "No-Swap", "Norm", S1_Center_X, S1_Center_Y );
// Extract the switch end points (C, NO, NC) from the return array.
S1_C_X = S1_XY_Ret[0]; S1_C_Y = S1_XY_Ret[1]; S1_NO_X = S1_XY_Ret[2]; S1_NO_Y = S1_XY_Ret[3];S1_NC_X = S1_XY_Ret[4]; S1_NC_Y = S1_XY_Ret[5];

Rotary Switch

Description: Draws a Rotary Switch that has from 3 to 8 contacts. The contacts rotate Counter Clock Wise (CCW) starting at the Start angle for the Span angle specified. The table below illustrates the limitations.

ParameterDescriptionExample
Lib_S_Dwg_Obj jsGraphics Object that points to the drawing.
S1B
Lib_S_RefDes Switch Reference Designator
("S1" || "S2" || "S3).
Switch RefDes
S1 S2 S3 S4 S1A S1B
Lib_S_Label Arbitrary Switch Label
("Power" || "Enable" || etc.)
Switch Label
Power Enable On/Off
Lib_S_RSW_NPos Switch Positions
(1 to 8)
Switch Positions
2 3 4 5
6 7 8 9 10
Lib_S_RSW_Start_Ang Start Angle, Rotation CCW
(0 = Center Right).
Start Angle
45° 90° 135°
180° 225° 270° 315°
Lib_S_RSW_Span_Ang Span Angle, Rotation CCW
(360° = Spread evenly over 360°).
Span Angle
45° 90° 135° 180°
225° 270° 315° 360°
Lib_S_RSW_Rot_Dir
Not Implemented
Rotation Direction
("CW", "CCW").
Rotation Direction
CW CCW
Lib_S_Center_X Symbol Center X Position Show/Hide Grid (10x10), Center Mark, Pins (green dot).
Grid
On
Off
Center
On
Off
Pins
On
Off
Lib_S_Center_Y Symbol Start Y Position

Return: The draw function will return the X/Y coordnates for the Common and each switch position (2, 3, 4, 5, 6, 7, 8, 9, 10).

Usage: The selections from the table above, are used to create the example below. After selecting and entering your specific information, the example can be used directly, with a copy/paste. The items in Red are the only ones that need to be adjusted to your specific needs. The lines in Green are just comments and can be deleted. Due to space limitations, some of the lines below may be split onto more than one line.

// Draw Rotary Switch S1B
var RSW_Info = [ "S1B", "Power", 4, 0, 180, "CW" ];
S1B_Rtn = Rotary_Switch( Dwg_Obj, RSW_Info, S1B_Start_X, S1B_Start_Y );
S1B_C_X = S1B_Rtn[0]; S1B_C_Y = S1B_Rtn[1];
S1B_P1_X = S1B_Rtn[2]; S1B_P1_Y = S1B_Rtn[3]; S1B_P2_X = S1B_Rtn[4]; S1B_P2_Y = S1B_Rtn[5];
S1B_P3_X = S1B_Rtn[6]; S1B_P3_Y = S1B_Rtn[7]; S1B_P4_X = S1B_Rtn[8]; S1B_P4_Y = S1B_Rtn[9];

Relay

Description: Draws a Relay that consists of a Relay Coil and one, or two, sets of Switch Contacts. The contacts can be SPST || SPDT || DPDT. The Relay can also be rotated CCW, in it's entirety, 0 || 90 || 180 || 270 degrees.

The table below is only meant as an example, meaning that, RefDes and Voltage are not limited to the available selections from the drop down menu. They can be anything, as long as they are wrapped in quotes on the command line.

ParameterDescriptionExample
Lib_S_Dwg_Obj jsGraphics Object that points to the drawing.
K1
12VDC
Lib_S_RefDes Reference Designator
(K1 || K2 || K3).
Relay RefDes
K1 K2 K3
Lib_S_Voltage Relay Coil Voltage
(5VDC || 6VDC || 12VDC)
Relay Coil Voltage
5V 6V 12V
Lib_S_Type Relay Contact Type
(SPST || SPDT || DPDT)
Relay Contact Type
SPST SPDT DPDT
Lib_S_Coil_pins, Lib_S_Switch_pins, Lib_S_Label_Loc Flip Coil || Flip Switch || Label Loc
Coil Pins
Norm Flip
Switch Pins
Norm Flip
Label Loc
Norm Flip
Lib_S_Rot Rotation Angle, CCW.
Rotation Angle
90° 180° 270°
Lib_S_Center_X Symbol Center X Position Show/Hide Grid (10x10), Center Mark, Pins (green dot).
Grid
On
Off
Center
On
Off
Pins
On
Off
Lib_S_Center_Y Symbol Center Y Position

Return: The draw function will return the X/Y coordnates for the Relay Coil terminals (e.g. K1-C_X/Y) and each switch position (e.g. K1-A_Common_X/Y, K1-A_NO_X/Y, K1-A_NC_X/Y).

Usage: The selections from the table above, are used to create the example below. After selecting and entering your specific information, the example can be used directly, with a copy/paste. The items in Red are the only ones that need to be adjusted to your specific needs. The lines in Green are just comments and can be deleted. Due to space limitations, some of the lines below may be split onto more than one line.

// K1
// Declare and Set the center point.
var K1_Center_X = ??; var K1_Center_Y = ??;
// Declare the coil and switch return variables (CA, CB, Sw_Com, Sw_NO).
var K1_CA_X, K1_CA_Y, K1_CB_X, K1_CB_Y;
var K1_A_Com_X, K1_A_Com_Y, K1_A_NO_X, K1_A_NO_Y; var K1_XY_Return = new Array();
// Draw the symbol.
K1_XY_Return = Relay( Dwg_Obj, "K1", "12VDC", "SPST", "Norm", "Norm", "Norm", 0, K1_Center_X, K1_Center_Y );
// Extract the end points from the return array.
K1_CA_X = K1_XY_Return[0]; K1_CA_Y = K1_XY_Return[1];K1_CB_X = K1_XY_Return[2]; K1_CB_Y = K1_XY_Return[3];
K1_A_Com_X = K1_XY_Return[4]; K1_A_Com_Y = K1_XY_Return[5];
K1_A_NO_X = K1_XY_Return[6]; K1_A_NO_Y = K1_XY_Return[7];