model railroad track planning

Please contact a Moderator to submit *Only Finished Scrips/Plug-in's here (include relevant tutorials).

Moderators: andrew, Husky, J-J

Locked
smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

model railroad track planning

Post by smf » Wed Feb 25, 2015 8:37 pm

Hi there,

with massive support of Andrew and many many suggestions of Husky and Clive, I wrote some scripts to ease model railroad track plannig with QCad. Please see the original thread at viewtopic.php?f=107&t=3172 for the full story, here you'll find only the latest version and up-to-date tutorials.


Latest stable release of QCTrack:
QCTrack_V101_SelectStopTurn.zip
2015/09/02: Version 101
(79.71 KiB) Downloaded 926 times
(For previous releases of QCTrack please check the original thread)

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

libraries for QCTrack

Post by smf » Wed Feb 25, 2015 8:41 pm

Attached are example libraries containing track elements (and some example plans) for Märklin H0 C-Gleis, Märklin Z miniclub and Ninco slot car tracks.
NincoSchienen.dxf
Ninco slot car
(124.47 KiB) Downloaded 906 times
MaerklinZ.dxf
Märklin Z (miniclub)
(922.67 KiB) Downloaded 862 times
MaerklinC.dxf
Märklin H0 C-Gleis
18.09.15 updated / now incl. R3-curved-turnout
(1.27 MiB) Downloaded 865 times
MaerklinM.dxf
Märklin H0 M-Gleis
20.01.17
(609.94 KiB) Downloaded 268 times

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 1: installation

Post by smf » Wed Feb 25, 2015 8:43 pm

To install the QCTrack extension, download the latest zip file and unpack it to the

Code: Select all

..../qcad/scripts
folder, so there exists a file

Code: Select all

..../qcad/scripts/QCTrack/QCTrack.js
in your QCad-installation. That's all. :)

After a QCad restart, you should have a new menu item "QCTrack" after the "Help" item.

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 2: create track parts

Post by smf » Sun Mar 01, 2015 7:05 pm

To create a new track part, select "Create" from the QCTrack menu. The following dialog will appear:
CreateNew.png
CreateNew.png (31.38 KiB) Viewed 33343 times
  • Enter a block name for the to be created block, e.g. "MC24188" for a Maerklin C-System track with number 24188.
  • Because the "MC24" is all the same for all compatible tracks, this information isn't needed on the final plan, so just enter "188" at "Display name".
  • Next, you must enter either a length at "Straight" for a straight track, which would be 188.3 for the MC24188, or you must enter "Radius" and "Angle" for a curved track.
  • You may also enter the cost of a single peace of MC24188 at "Cost".
  • All other values are default values for H0 (scale 1:87) systems, usually they are all the same for one type of track parts.
Clicking "OK", the script will create a new (standard QCad) block with the name given at "block name". This block will have:
  • The ends of the track, they are very imported for all other features of QCTrack. This "ends" are two lines on TR_ENDS layer. Usually there are 2 for normal tracks, but you may edit the block later on to have 3 for turn outs, 1 for track ends. This will be discussed in a later step.
  • The main layout on TR_PLAN. Those lines have the color of the layer you put the block into, so you can have the same track elements on different layers and the lines of TR_PLAN will have the color of the corresponding layer and will therefore be distinguishable from eachother (see Spielbahn example above).
  • A line on TR_MIDS. This is for those of you in need of a very simple overview plan and is used to calculate track and/or element lengths.
  • The bounding box contours of this element on TR_BEDS.
  • The entered value at "Display name" will be inserted in the block at layer TR_NMBRS.
  • From several to many :wink: swells are created on TR_SWELLS. Those are just for "reality" reasons and have no special function.
If you create a curved track, you don't need to create one for "left curve" and one for "right curve", if your elements have symmetric connectors (as is usual).

So, for example, you could create a straight curve with 188.3mm length, name the block MC24188 and have 188 be displayed in the plan, calculating cost of 2.65-something with the following input:
CreateFilledNew.png
CreateFilledNew.png (32.97 KiB) Viewed 33343 times
Therefore, you'll get a new QCad block looking like that:
CreateResult.png
CreateResult.png (2.27 KiB) Viewed 33343 times

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 3: create complex parts like turnouts

Post by smf » Sun Mar 01, 2015 7:13 pm

To create more complex elements than just straight or curved elements, you may edit the created blocks as needed. In this example, I will show the required steps to create a curved turn out like Maerklin 24671 which has 360mm radius and 30° curves which have an offset of 77.5mm.

First, create the "base" element just like a "normal" element: At the Model_Space (the normal work space, not inside any block), create a new curved track via QCTrack / Create menu:
ComplexBaseNew.png
ComplexBaseNew.png (32.97 KiB) Viewed 33343 times
Then, change the current block space by double clicking the newly created MC24671 block in the QCad Block list. You now should be able to select elements inside the newly created MC24671 element. Select all elements and move them all together some distance away (we will need them later).

Next, again select QCTrack / Create, but this time leave the "block name" empty (maybe you will notice that the top check box is deselected and the cursor starts in "Display name" instead of "block name"). Leave "Display name" empty, again enter 360 / 30° at the bottom of this dialog and hit "Ok". Again move the created element away.

Now for the third time select QCTrack / Create, leave "block name" and "Display name" empty and enter "straight 77.5" to create a straight element.

Your QCad window should now look similar to this:
ComplexParts.png
ComplexParts.png (113.16 KiB) Viewed 33343 times
Now select only TR_PLAN to be visible. Remove the short ends of the straight element and the left end of the curved element without display name.
Remove the same lines on TR_ENDS and the something longer lines on TR_BEDS. (Means: you remove three lines on each of those three layers.)

All layers visible now you have:
ComplexPartsEdited.png
ComplexPartsEdited.png (10.61 KiB) Viewed 33343 times
All parts are created now, so let's move them to the appropriate position with the normal QCad command (like "mv" for move with "se" for snapend using the bottom left ends of the bed lines):
ComplexPartsMoved.png
ComplexPartsMoved.png (7.39 KiB) Viewed 33343 times
Now adjust the lines on the TR_BEDS layer as wanted. For me, the following seems to be appropriate (deleting and trimming lines):
ComplexBedEdited.png
ComplexBedEdited.png (2.14 KiB) Viewed 33343 times
As last step, mark all layers to be visible and select QCTrack / Ensure order of track layer objects. This should put the swells to the back and bring the display name to the front (and also sort all other elements). You should now have:
ComplexDone.png
ComplexDone.png (6.56 KiB) Viewed 33343 times
Of course, you may edit the swells to look more like they realy do, but this isn't needed. Very importand is only one thing: there must be three (not four, not five, and, of course: not six) lines on TR_ENDS, because all other QCTrack-scripts use the lines on TR_ENDS to connect track elements. So double check if your block has three lines (e.g. select only TR_ENDS layer to be visble and select all elements, then QCad should display "3 Lines on Layer 'TR_ENDS'").

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 4: create your library

Post by smf » Sun Mar 01, 2015 7:31 pm

As described in step 2 and 3, create all your track elements, insert each block once and save :D this file. For Maerklin C-System tracks, you get something like this:
MaerklinCSystem.png
MaerklinCSystem.png (30.73 KiB) Viewed 33341 times
Of course, for Maerklin C-System tracks you may just download my library MaerklinCGleis.dxf from the post above. :D There some plan examples are included, too.

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 5: simple functions

Post by smf » Sun Mar 01, 2015 7:37 pm

Now let's play. :)

To build a new track plan, insert the first block somewhere with the usual QCad functions (e.g. select one at the Block List and insert it or just copy it from your "library" area) or via "QN" (QCtrack / Insert new track from track widget) after selecting one in the track widget (see next tutorial). Ensure to have an appropriate layer selected, for example "playground" or just the "0" layer. Do not use any of the TR_* layers to insert blocks to.

QCTrack then supports plan building with several functions:
  • Movement of elements: Select the element(s) to be moved, type "QM" or select QCTrack / Move from the menu, select the track end to connect to another existing track (mouse-over a selected track will show a auxiliary circle) and then select the destination track end. All selected tracks will be rotated and moved to connect the selected track ends. All attributes of all elements will be unchanged.
  • Duplication of elements: The user interface is the same as for movement of elements, but you must type "QD" or select QCTrack / Duplicate and move from the menu. The selected elements in contrast to Move will be copied with the current attributes (i.e. the currently selected layer!).
  • Select connected tracks: Select "QS" or QCTrack / Select connected tracks to extend the current selection by all "nearby" track elements to the selection recursively. This is helpful if you want to move a complete part of your current drawing.
  • Align: Typing "QA" or selecting QCTrack/ Align moves the current selection so that the first selected track end will be in a straight line to the second track end but will be moved only on a straight line of the third track end. It is described in a tutorial below in detail. Sounds complicated, but is very useful if you have two straight lines ending somewhere. Add at one of them curved tracks to balance the angle difference. Normally, you have an offset between this curve and the destination track end. Therefor select the curved tracks and use the align function to have the curved tracks aligned to both straight tracks. Those can now be enlonged up to the curve.
  • Fill with straight tracks: To connect two track ends in line by inserting new straight elements, type "QF" or select QCTrack / Fill with Straight Tracks from the menu. Select the starting and the ending track, an auxiliary line will be displayed during selection. After selecting the second track end, a window will appear where you can enter the maximum track element amount and the amount of each element (0 means none, 1 means 0 or 1, 2 means 0 or 1 or 2 etc., -1 means unlimited). Per default, the minimum track length is 5 less than the desired track length (which is the measured distance between the two track ends you clicked) and the maximum track length is 5 more than the desired track length. You may also add some optimization options to eliminate solutions. Caution: depending on the selected element count, it may take a very long time to try out all combinations. Please start with a short distance and/or limited track element amounts.
  • Variegate: This is some kind of "Full with straight tracks" and only reachable by QCTrack / Variegate from the menu. It creates all combinations of available tracks (with restrictions as in "Fill with straight tracks") and let select you which of those should be inserted in the drawing. Each combination can be labelled with the spanned distance, so you get some kind of distance table.
  • Distance information: "QI" or QCTrack / Distance information lets you select two track ends and prints distance information in the QCad console.
  • Show Part List: Summarize (selected / all) used track elements. If you entered cost information, this will also add up the costs.
  • Track widget functions: described in the next tutorial.

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Re: Tutorial step 6: create plans superfast

Post by smf » Sun Mar 01, 2015 7:53 pm

Thanks to perstistent asking :wink: of Husky, there is a Track Widget :) that can be enabled / disabled via menu item QCTrack / View track widget or "QV". You then get something like the Block list but with some more information about the tracks you may add.
TrackWidgetBaseNew.png
TrackWidgetBaseNew.png (20.67 KiB) Viewed 33341 times
To place an unconnected track, select a track from the track widget and click "Ins" or choose meu item QCTrack / Insert new track from track widget or type "QN". You may place it everywhere like a normal QCad block. To extend an existing track, select a track from the track widget and click "Con" or choose menu item QCTrack / Connect new track from track widget or type "QC". With mouse over the existing track, there should be preview of the track that would be inserted on left mouse click.

Even during preview, you may type "QR" or click "Rot" in the track widget select menu item QCTrack / Rotate track at track widget (or you may right click inside the track widget or select a track end from the combobox or hit the Rotate button at the track widget) to select another track end to connect.

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 7: align

Post by smf » Sun Mar 01, 2015 8:00 pm

Below you see an example of how to use the QCTrack align function. If you have one or more tracks that should be aligned to another track but moved only on an (may be arbitrary) axis, you can do this:
  • Select tracks to align.
  • Select QCTrack / Align or type QA.
  • Select to-be-aligned track end.
  • Select target track end.
  • Select track axis.
At the start of the animated GIF the three curves are inserted via Track Widget in combination with QC and QR (connect new track and rotate).
AlignNew.gif
AlignNew.gif (121.38 KiB) Viewed 33340 times

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 8: fill with straight tracks

Post by smf » Sun Mar 01, 2015 8:19 pm

Below you see an example of how to use the QCTrack fill with straight function. If you have track ends in a straight line, you can (try to) connect them:
  • Select QCTrack / Fill with straight tracks or type QF.
  • Select track ends to connect.
  • Check / modify maximum use of track elements (first example: 077 is unlimited, second example: 077 is limited to 1) and hit "Ok".
  • Wait. This can really take some time if you have many different track elements and/or a long distance.
  • Select one combination. In the result table, each column show one combination with overall-length and element-count (overall and per track element type). Additionally, in the upper table you may view / select minimum and maximum element amount summarized or per element type as filter to reduce displayed solutions.
  • Hit Ok.
FillStraightNew.gif
FillStraightNew.gif (406.77 KiB) Viewed 33340 times
Last edited by smf on Sun Mar 01, 2015 8:26 pm, edited 1 time in total.

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

example plan

Post by smf » Sun Mar 01, 2015 8:24 pm

Attached is a dxf example plan for Maerklin C system which looks like this:
example.png
Mäklin C-Gleis example plan image
example.png (323.34 KiB) Viewed 33339 times
Attachments
example.dxf
Märklin C-Gleis example plan
(999.29 KiB) Downloaded 809 times

smf
Premier Member
Posts: 164
Joined: Tue Feb 28, 2012 1:05 pm

howto: oval with siding

Post by smf » Sun Mar 01, 2015 11:06 pm

SimpleExampleSml.gif
howto: oval with siding animation
SimpleExampleSml.gif (492.19 KiB) Viewed 33328 times

Locked

Return to “Finished 'Ready to go' Scripts/Plug-in's”