model railroad track planning

This forum is for 'Work-in-Progress' QCAD user developed script Add Ons and Plug-ins.

Please use this forum to request/submit your script Add-Ons & Plug-in idea's.

Moderators: andrew, Husky, J-J

Post Reply
smf
Premier Member
Posts: 177
Joined: Tue Feb 28, 2012 1:05 pm

model railroad track planning

Post by smf » Sat Dec 13, 2014 8:51 pm

I wrote some small scripts to support model railroad track planning with QCad, for my purpose it is (thanks to the default QCad features) better than most 2D track planning tools.

Have fun, any comment is welcome. :)

See also the other two threads created in this context:
viewtopic.php?f=32&t=3171
viewtopic.php?f=8&t=1763&start=30
Attachments
QCTrack_V11_Cost.zip
version 11 with support for track creation, track movement, track list with(out) cost calculation
(13.98 KiB) Downloaded 2997 times

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

Re: model railroad track planning

Post by smf » Tue Dec 23, 2014 5:17 pm

The new version supports many useful new things like track variegation, easy track alignment, automatic straight track filling.
Attachments
QCTrack_V44_MoveOpt.zip
QCTrack V44
(30.88 KiB) Downloaded 2910 times

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

Re: model railroad track planning

Post by smf » Tue Dec 23, 2014 8:27 pm

attached are:
- MaerklinCGleis: a "library" for Märklin C-System
- Spielbahn: an example model railroad plan
Spielbahn.png
Example plan as bitmap
Spielbahn.png (252.75 KiB) Viewed 454425 times
Attachments
Spielbahn.dxf.zip
Example plan
(61.31 KiB) Downloaded 2840 times
MaerklinCGleis.dxf.zip
MaerklinCGleis: library for Maerklin C-System
(117.76 KiB) Downloaded 2842 times

User avatar
Clive
Moderator
Posts: 1329
Joined: Thu Aug 25, 2011 9:28 pm
Location: UK

Re: model railroad track planning

Post by Clive » Thu Jan 01, 2015 3:41 pm

smf,
Great contribution you have made here,it might be useful for some if you could outline the steps needed to use this Q Tracker.
For the best support please state your operating system, QCAD version and add any supporting DXF/DWG files, screenshots etc...

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

Re: model railroad track planning

Post by smf » Thu Jan 01, 2015 8:06 pm

Hi Clive,

thank you for your comment. :) I'm still working on some functionality like "continous track extension" to build new plans very fast. After that I will upload sort of "final" version and give detailled information with step-by-step-tutorial. Work in progress... :) Thanks to Andrew's help, my questions are solved - now it's happy coding time.

User avatar
Clive
Moderator
Posts: 1329
Joined: Thu Aug 25, 2011 9:28 pm
Location: UK

Re: model railroad track planning

Post by Clive » Thu Jan 01, 2015 8:10 pm

smf wrote: I'm still working on some functionality like "continous track extension" to build new plans very fast. After that I will upload sort of "final" version and give detailled information with step-by-step-tutorial. Work in progress... :) Thanks to Andrew's help, my questions are solved - now it's happy coding time.
Okay thanks, I'll look forward to it :) .
For the best support please state your operating system, QCAD version and add any supporting DXF/DWG files, screenshots etc...

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

Re: model railroad track planning

Post by smf » Fri Jan 02, 2015 5:23 pm

The new version fixes some bugs and contains a running version of "consecutive extension". For the moment, all features are implemented, so next step is the tutorial...
Attachments
QCTrack_V48_ConsecExtendOk.zip
QCTrack version 48
(31.12 KiB) Downloaded 2845 times

User avatar
Husky
Moderator/Drawing Help/Testing
Posts: 4931
Joined: Wed May 11, 2011 9:25 am
Location: USA

Re: model railroad track planning

Post by Husky » Fri Jan 02, 2015 8:31 pm

smf wrote:... so next step is the tutorial...
Yes please - I'm excited to get it running on my machine! :wink:
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."

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

Re: model railroad track planning

Post by smf » Sat Jan 03, 2015 1:09 pm

The new version contains a better version of "consecutive extension".
Attachments
QCTrack_V49_ConsecExtendBetter.zip
(31.28 KiB) Downloaded 2887 times

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

Tutorial step 1: installation

Post by smf » Sat Jan 03, 2015 1:12 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: 177
Joined: Tue Feb 28, 2012 1:05 pm

Tutorial step 2: create track parts

Post by smf » Sat Jan 03, 2015 1:42 pm

To create a new track part, select "Create" from the QCTrack menu. The following dialog will appear:
Create.png
Create dialog
Create.png (29.72 KiB) Viewed 454323 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" - please use Cent or Penny or something like that, here no floating point numbers are allowed for precision reasons.
  • 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.
Attention: If you create a new track element and already have the required layers existing, they need to be visible and editable! If you don't have the required layers, they will be created in a proper way.

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 2.65-something with the following input:
CreateFilled.png
Filled create dialog
CreateFilled.png (31.9 KiB) Viewed 454323 times
Therefore, you'll get a new QCad block looking like that:
CreateResult.png
Created track
CreateResult.png (2.27 KiB) Viewed 454323 times
Last edited by smf on Sat Jan 03, 2015 3:02 pm, edited 1 time in total.

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

Tutorial step 3: create complex parts like turnouts

Post by smf » Sat Jan 03, 2015 2: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:
ComplexBase.png
Create base element
ComplexBase.png (31.7 KiB) Viewed 454322 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
All parts are created
ComplexParts.png (113.16 KiB) Viewed 454322 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
Edited parts
ComplexPartsEdited.png (10.61 KiB) Viewed 454322 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
Parts moved
ComplexPartsMoved.png (7.39 KiB) Viewed 454322 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
Bed is edited
ComplexBedEdited.png (2.14 KiB) Viewed 454322 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
Done.
ComplexDone.png (6.56 KiB) Viewed 454322 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'").
Last edited by smf on Sat Jan 03, 2015 5:36 pm, edited 1 time in total.

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

Tutorial step 4: create your "library"

Post by smf » Sat Jan 03, 2015 2:18 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
Screenshot of MaerklinCSystem
MaerklinCSystem.png (30.73 KiB) Viewed 454322 times
Of course, for Maerklin C-System tracks you may just download my library MaerklinCGleis.dxf.zip from the post above. :D
Last edited by smf on Sat Jan 03, 2015 5:39 pm, edited 1 time in total.

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

Tutorial step 5: simple functions

Post by smf » Sat Jan 03, 2015 2:42 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). 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. Sounds complicated, but is very useful if you have two straight lines ending somewhere. Now 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 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.
  • Consecutive extension: This will be explained in the next tutorial step.

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

Tutorial step 6: create plans superfast

Post by smf » Sat Jan 03, 2015 2:59 pm

With the (some kind of beta-experimental) function "Consecutive extension", you can extend a track end by many track elements very fast. Therefore, with an already existing track element type "QE" or select QCTrack / Consecutive extension from the menu. Then select the track end which is to be extended. Now you should get a list of all available tracks in a new window.
ConsecBase.png
Start of consecutive extension
ConsecBase.png (88.74 KiB) Viewed 454321 times
Please pay attention to the light blue auxiliary circle visible at the track end. At this track end the next track will be inserted. Therefore select the next track from the list either by double clicking it or selecting it with confirmation "Insert track element". For each track element you get some basic information: first is the block name, second is radius for curved tracks and empty for straight tracks, third is angle for curved tracks and length of straight tracks. If the element is complex (means: has more than two track ends), only "complex" is shown. At the spinbox in the fourth column you choose which track end should be connected (e.g. "1" for a left curve will insert a left curve and "2" will rotate the curve so that it will result in a right curve). The spinbox in the fifth column lets you select the track end of the to-be-inserted track to continue with.

If you want to continue at another track end or just zoom / move the QCad window, hit "Select new destination" which will temporarily close the window waiting for a new (or the old) track end to extend.

In this example, after double-clicking MC24230 six times, then double-clicking MC24188 once and then double-clicking MC24230 five times, the oval is almost done:
ConsecInProgress.png
Consecutive extension built an oval
ConsecInProgress.png (76.41 KiB) Viewed 454321 times
So with just one track existing, QE inserted 12 elements by 12 double clicks. :D Playing around with the track-end-spinbox will clearly point out its function.

One exception are elements that are marked as "track end": the window closes immediately after insertion as there is no meaningful extension left.
Last edited by smf on Sat Jan 03, 2015 5:42 pm, edited 2 times in total.

Post Reply

Return to “QCAD 'Script Add-On & Plug-in challenge' - Work in Progress”