# XTrkCad Version: 3.0.1, Date: Wed Sep 20 22:05:35 2000

VERSION 10
DEMOINIT
PARAMETER display labelenable 1
ORIG 1.0 0.0 0.0
TURNOUT  6 0 0 0 0 DEMO 2 2.125000 2.281250 0 0.000000 "Peco-55	Medium Right	SL-E395F"
	E 2.125000 2.281250 270.000000
	E 7.530000 2.281250 90.000000
	E 7.495000 1.759250 99.686000
	D -0.108750 -0.832750
	P "Normal" 1 2
	P "Reverse" 1 3 4
	S 0 0.000000 0.000000 0.000000 0.353000 0.000000
	S 0 0.000000 0.353000 0.000000 5.405000 0.000000
	C 0 0.000000 23.136000 0.351000 -23.136000 0.004000 9.700000
	S 0 0.000000 4.251000 -0.331000 5.370000 -0.522000
	END
REDRAW
RESET
MESSAGE
The <Group> and <Ungroup> commands (on the Tools menu) are a powerful way to manipulate Turnout and Structure definitions.

We'll start with a simple turnout and add a switch machine.
END
STEP
COMMAND DrawLine
PARAMETER draw linewidth 0
PARAMETER draw linecolor 0
PARAMETER GROUP draw
PARAMETER draw linewidth 0.055555
MOUSE 1 2.500 3.000
COMMAND DrawLine
MOUSE 2 2.500 3.000
MOUSE 4 2.500 1.500
COMMAND DrawLine
KEYSTATE A
MOUSE 2 3.200 3.000
KEYSTATE A
MOUSE 4 3.200 1.500
STEP
COMMAND DrawFilledBox
PARAMETER draw linecolor 0
PARAMETER GROUP draw
KEYSTATE A
MOUSE 1 2.600 3.000
KEYSTATE A
MOUSE 2 2.600 3.000
KEYSTATE A
MOUSE 4 3.100 2.500
KEYSTATE A
MOUSE 2 2.600 2.000
KEYSTATE A
MOUSE 4 3.100 1.500
MESSAGE
_________________________________________

Now that we have drawn a rough outline of a switch machine we will group it with the turnout definition.

First we Select the objects in the new definition.
END
STEP
COMMAND Select
MOUSE 1 0.781 3.375
MOUSE 2 0.781 3.375
MOUSE 3 8.312 1.312
MOUSE 4 8.312 1.312
MESSAGE
_________________________________________

Now do the <Group> command.
END
STEP
PARAMETER misc cmdGroup
MESSAGE
_________________________________________

The <Group> command dialog shows the Title (Manufacturer, Description and Part Number) of the new definition.  This information is taken from the Selected objects you are grouping.
END
STEP
MESSAGE
_________________________________________

The 'Replace with new group?' toggle will replace the Selected objects with the new definition.
END
STEP
PARAMETER group replace 1
MESSAGE
_________________________________________

If we don't change the Title then the new definition will replace the existing definition.

We'll give this definition a new Description.
END
STEP
PARAMETER group desc M Medium Right
PARAMETER group desc Modi Medium Right
PARAMETER group desc Modified Medium Right
MESSAGE
_________________________________________

We're done with this definition.  Press Ok.
END
STEP
PARAMETER group ok
MESSAGE
_________________________________________

You will see the updated image on the HotBar.
END
STEP
CLEAR
MESSAGE
The <Ungroup> command replaces any Selected turnouts or structures with their parts.

Structures and non-track segements of turnouts are composed of Lines, Circles and other shapes.  In this turnout these are the two lines and the two squares.

We will Ungroup this turnout and see how the individual parts can be changed.

First Select the turnout and then Ungroup it.

END
STEP
MOUSE 1 7.156 2.094
MOUSE 2 7.156 2.094
MOUSE 4 7.156 2.094
PARAMETER misc cmdUngroup
MESSAGE
_________________________________________

Notice that the Title now indicates the turnout is Ungrouped.

Hit Escape to deselect everything.
END
STEP
MOUSE 2800 4.094 5.188
RESET
MESSAGE
_________________________________________

Now Select the lines and squares.
END
STEP
#KEYSTATE C
MOUSE 1 2.500 2.812
#KEYSTATE C
MOUSE 2 2.500 2.812
KEYSTATE C
MOUSE 4 2.500 2.812
KEYSTATE C
MOUSE 2 2.850 2.500
KEYSTATE C
MOUSE 4 2.850 2.500
KEYSTATE C
MOUSE 2 3.200 2.000
KEYSTATE C
MOUSE 4 3.200 2.000
KEYSTATE C
MOUSE 2 2.850 1.500
KEYSTATE C
MOUSE 4 2.850 1.500
MOUSE 1 5.000 1.000
MESSAGE
_________________________________________

We could modify these object or add new ones.  For now we'll just delete them.
END
STEP
PARAMETER misc cmdDelete
MESSAGE
_________________________________________

And move the Label out of the way.
END
STEP
COMMAND MoveLabel
MOUSE 1 5.000 2.116
MOUSE 2 5.000 2.116
MOUSE 4 4.594 0.844
ORIG 1.0 0.0 0.0
MESSAGE
_________________________________________

Notice that the turnout has been broken into three parts.
END
STEP
COMMAND Describe
MOUSE 1 4.531 2.219
MOUSE 2 4.531 2.219
MOUSE 4 4.531 2.219
BIGPAUSE
MOUSE 1 6.984 1.812
MOUSE 2 6.984 1.812
MOUSE 4 6.984 1.812
BIGPAUSE
MOUSE 1 2.359 2.266
MOUSE 2 2.359 2.266
MOUSE 4 2.359 2.266
BIGPAUSE
#DESCRIBE OK
PARAMETER describe cancel
RESET
MESSAGE
_________________________________________

Two ends of the turnout, from the frog to the end of the diverging leg and from the points to the left, are now straight track sections.

The a turnout is made of a number of individual straight and curved track segements.  This turnout had four segments:
   1 a short straight segment to the left of the points
   2 a long straight segment to the right of the points
   3 a curved segment from the points to the frog
   4 a straight segment from the frog to the end of the diverging leg.
The first and last segments have be converted to straight tracks.
The second and third segments form the the body of the turnout and can not be ungrouped further.

You can later Group this turnout with the straight segments to recreate the turnout definition.  You can also add other track segments to turnout definitions.

END
STEP
KEYSTATE S
MOUSE 2 4.625 1.969
KEYSTATE S
MOUSE 4 4.625 1.969
REGRESSION START 10 - group 1
TURNOUT  16 0 32 0 0 DEMO 2 2.477615 1.950213 0 0.000000 "Peco-55	Modified Medium Right	SL-E395F"
	T4 17 2.478000 2.281250 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	E4 7.530000 2.281250 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	T4 18 6.375762 1.950213 99.704000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	D -0.409808 -1.271732
	P "P1" 1
	P "P2" 2
	S 0 0.000000 0.000385 0.331037 5.052385 0.331037
	C 0 0.000000 23.136000 -0.001615 -22.804963 0.004000 9.700000
	END
STRAIGHT 17 0 0 0 0 DEMO 2
	E4 2.125000 2.281250 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	T4 16 2.478000 2.281250 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	END
STRAIGHT 18 0 0 0 0 DEMO 2
	T4 16 6.376000 1.950250 279.686360 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	E4 7.495000 1.759250 99.686360 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	END
REGRESSION END
PARAMETER misc cmdDelete
ORIG 1.0 0.0 0.0
CLEAR
MESSAGE
Now, create a track and place the new turnout on it.
END
STEP
COMMAND Straight
MOUSE 1 0.281 0.688
MOUSE 2 0.281 0.688
MOUSE 3 11.156 4.281
MOUSE 4 11.156 4.281
BIGPAUSE
COMMAND TurnoutHotBar
#PARAMETER turnout list 0 
PARAMETER GROUP newFixedTrack
HOTBARSELECT Peco-55	Modified Medium Right	SL-E395F
MOUSE 1 4.750 1.906
MOUSE 2 4.750 1.906
MOUSE 4 4.750 1.906
MOUSE 8200 4.750 1.906
MESSAGE
_________________________________________

Now suppose we want to replace the black squares with green circles.

First we Select the turnout.
END
STEP
COMMAND Select
MOUSE 1 6.062 2.906
MOUSE 2 6.062 2.906
MOUSE 4 6.062 2.906
MESSAGE
And now Ungroup it (from the Tools Menu)
END
STEP
PARAMETER misc cmdUngroup
MESSAGE
_________________________________________

Notice that the name has changed to indicate the turnout was Ungrouped.
END
STEP
MESSAGE
_________________________________________

Now, hit escape to deselect everything and then Select the 2 squares and delete them.
END
STEP
MOUSE 2800 6.062 2.906
RESET
BIGPAUSE
MOUSE 1 5.219 3.000
MOUSE 2 5.219 3.000
MOUSE 4 5.219 3.000
KEYSTATE S
MOUSE 2 5.219 2.000
KEYSTATE S
MOUSE 4 5.219 2.000
PARAMETER misc cmdDelete
MESSAGE
_________________________________________

Now draw the green circles...
END
STEP
ORIG 1.0 0.0 0.0
COMMAND DrawFilledCircleCenter
PARAMETER draw linecolor 0
PARAMETER GROUP draw
PARAMETER draw linecolor 65280
MOUSE 1 5.203 2.812
MOUSE 2 5.203 2.812
MOUSE 3 5.359 2.609
MOUSE 4 5.359 2.609
PARAMETER GROUP draw
MOUSE 1 5.516 1.891
MOUSE 2 5.516 1.891
MOUSE 3 5.672 1.719
MOUSE 4 5.672 1.719
PARAMETER GROUP draw
MESSAGE
and Group the new definition.
END
STEP
ORIG 1.0 0.0 0.0
COMMAND Select
KEYSTATE S
MOUSE 1 3.719 4.156
KEYSTATE S
MOUSE 2 3.719 4.156
KEYSTATE S
MOUSE 3 10.531 0.969
KEYSTATE S
MOUSE 4 10.531 0.969
BIGPAUSE
PARAMETER misc cmdGroup
PARAMETER group replace 1
BIGPAUSE
PARAMETER group ok
MESSAGE
_________________________________________

Notice that the turnout in the HotBar is angled the same as the turnout on the layout.  Make sure your new definition is rotated the way you want it.
END
STEP
KEYSTATE S
MOUSE 2 5.000 2.188
KEYSTATE S
MOUSE 4 5.000 2.188
REGRESSION START 10 - group 2
STRAIGHT 19 0 0 0 0 DEMO 2
	E4 0.281000 0.688000 251.716920 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	T4 32 4.672994 2.139075 71.716920 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	END
STRAIGHT 20 0 0 0 0 DEMO 2
	T4 32 9.805140 3.834688 251.716920 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	E4 11.156000 4.281000 71.716920 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	END
TURNOUT  32 0 0 0 0 DEMO 2 4.672994 2.139075 0 0.000000 "Peco-55	Modified Medium Right	SL-E395F"
	T4 19 4.672994 2.139075 251.716920 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	T4 20 9.805140 3.834688 71.716920 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	E4 9.935665 3.328060 81.403280 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	D 0.000000 0.000000
	P "P0" 1 3
	P "P1" 4 2 3
	L3 0 0.055556 0.130589 0.800108 0 0.601157 -0.624169 0
	L3 0 0.055556 0.795251 1.019707 0 1.265820 -0.404571 0
	S 0 0.000000 5.132146 1.695614 0.335180 0.110740
	C 0 0.000000 -23.136000 7.591323 -21.857939 341.720920 9.700000
	S 0 0.000000 0.335180 0.110740 0.000000 0.000000
	S 0 0.000000 5.262670 1.188985 4.140240 1.019299
	G3 65280 0.000000 0.256018 0.530006 0.672925 0
	G3 65280 0.000000 0.232207 0.843006 -0.248075 0
	END
REGRESSION END
PARAMETER misc cmdDelete
CLEAR
RESET
MESSAGE
We can also create turnouts from simple straight and curved tracks.

We'll create two tracks that have a common endpoint.
END
STEP
COMMAND Straight
MOUSE 1 2.000 2.000
MOUSE 2 2.000 2.000
MOUSE 3 10.000 2.000
MOUSE 4 10.000 2.000
MESSAGE

When we create the curve from the straight track endpoint we need to hold down the <Shift> key to prevent XTrackCAD from trying to join the two tracks.
END
COMMAND CurveEndPt
MOUSE 1 2.000 2.000
KEYSTATE S
MOUSE 2 2.000 2.000
KEYSTATE S
MOUSE 3 9.000 2.000
KEYSTATE S
MOUSE 4 9.000 2.000
KEYSTATE S
MOUSE 2 9.000 2.000
KEYSTATE S
MOUSE 3 8.875 3.062
KEYSTATE S
MOUSE 4 8.875 3.062
MESSAGE
_________________________________________

At this point we can modify the tracks if necessary.

We will use the <Describe> command to change the tracks.
END
STEP
COMMAND Describe
MOUSE 1 9.438 2.000
MOUSE 2 9.438 2.000
MOUSE 4 9.438 2.000
MESSAGE
_________________________________________

We'll make the Length 7.5".

If we change the Length, each End-Point will be moved to shorten the track.  We want to just move the Right End-Point.  To control this, change the Lock to First which means the Left End-Point will be unchanged when we change the length (or angle) of the track.
END
STEP
#DESCRIBE Pivot	0
PARAMETER describe P1 0
MESSAGE
_________________________________________

Now when change the Length only the Right End-Point will move.
END
STEP
#DESCRIBE Length	7.500
PARAMETER describe F7 7.500
#DESCRIBE OK
PARAMETER describe cancel
RESET
MESSAGE
_________________________________________

Now let's look at the curved track.
END
STEP
COMMAND Describe
MOUSE 1 7.688 2.625
MOUSE 2 7.688 2.625
MOUSE 4 7.688 2.625
MESSAGE
_________________________________________

Here the Left End-Point (which we don't want to move) is the Second End-Point, so we'll make that the Lock.
END
STEP
#DESCRIBE Pivot	2
PARAMETER describe P1 2
MESSAGE
_________________________________________

We want the curve to have a radius of 20" and an angle of 17.5°.
First change the Radius...
END
STEP
#DESCRIBE Radius	20.000
PARAMETER describe F9 20.000000
MESSAGE
and the the Angular Length.
END
STEP
PARAMETER describe F11 17.5
BIGPAUSE
#DESCRIBE OK
PARAMETER describe cancel
MESSAGE
_________________________________________

Now Select both tracks...
END
STEP
COMMAND Select
MOUSE 1 7.500 2.750
MOUSE 2 7.500 2.750
MOUSE 4 7.500 2.750
KEYSTATE S
MOUSE 1 8.000 2.000
KEYSTATE S
MOUSE 2 8.000 2.000
KEYSTATE S
MOUSE 4 8.000 2.000
MESSAGE
and Group them.
END
PARAMETER group manuf 
PARAMETER group desc 
PARAMETER group partno 
STEP
PARAMETER misc cmdGroup
PARAMETER group manuf Custom
PARAMETER group desc Left
PARAMETER group partno 99-L
MESSAGE
_________________________________________

If the two tracks have a common End-Point then they will form a Turnout and can be switched with the <Train> command.  Otherwise they will just be two track segments grouped together.
END
STEP
PARAMETER group ok
MESSAGE
_________________________________________

We have created a left hand turnout and we also want a right hand version.

We'll use the <Flip> command.
END
STEP
COMMAND Select
MOUSE 1 7.812 2.250
MOUSE 2 7.812 2.250
MOUSE 4 7.812 2.250
COMMAND Flip
MESSAGE
_________________________________________

Drag a horizontal line that will be the mirror for the <Flip> command.
END
STEP
MOUSE 1 1.438 1.938
MOUSE 2 1.438 1.938
MOUSE 3 11.625 1.938
MOUSE 4 11.625 1.938
MESSAGE
_________________________________________

Notice the title has changed to Flipped Left.

Now Group the turnout.
END
STEP
PARAMETER misc cmdGroup
MESSAGE
_________________________________________

We'll change the Title and Part No for the new defintion.
END
STEP
PARAMETER group desc Right
PARAMETER group partno 99-
PARAMETER group partno 99-R
PARAMETER group replace 1
PARAMETER group ok
STEP
CLEAR
MESSAGE
To Remove the definitions, use the Custom Management dialog on the Tools menu.
END
STEP
PARAMETER misc cmdCustmgm
MESSAGE
_________________________________________

Select the definitions you added and Delete them.
END
STEP
PARAMETER custmgm inx 0 	Peco-55	DEMO	SL-E395F	Modified Medium Right
PARAMETER custmgm delete
PARAMETER custmgm inx 0 	Custom	DEMO	99-L	Left
PARAMETER custmgm delete
PARAMETER custmgm inx 0 	Custom	DEMO	99-R	Right
PARAMETER custmgm delete
PARAMETER custmgm ok
MESSAGE
=========================================
END
STEP
REGRESSION START 10 - group 3
TURNOUT  36 0 0 0 0 DEMO 2 2.000000 1.876000 0 0.000000 "Custom	Right	99-R"
	E4 2.000000 1.876000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	E4 9.500000 1.876000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	E4 8.014116 0.950339 107.500000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 
	D 0.000000 0.000000
	P "P0" 1
	P "P1" 2
	S 0 0.000000 0.000000 0.000000 7.500000 -0.000000
	C 0 0.000000 20.000000 -0.000000 -20.000000 0.000000 17.500000
	END
REGRESSION END
CLEAR
