Learning XTrackCAD


Today's post is about my latest (and more successful) attempt to learn to use XTrackCAD for layout design (see diagram above). I've made a few half-hearted attempts in the past, but was always turned off by the amount of up-front work needed to learn the dang thing. It's not at all obvious, at least not to me. This time I started knowing it was going to be a pain, but with the commitment to see that through.

Much of what I learned was basic, but some of it was very specific to what I'm doing, which is a flex track layout in Japanese N scale. If you weren't already aware, Japanese N is 1:150 scale rather than the usual 1:160 used in American/European N, and, oddly, for Japanese Shinkansen models, but I'm modeling normal trains for the most part. And I'm also planning to hand-lay at least some turnouts using the Fast Tracks jigs, although that turned out to be a lot simpler to design in XTrackCAD than I'd expected.

Good track planning software is really an essential tool. You can certainly design a model railroad without it. I've done that, as did thousands of others before computers came along. But as a time-saving tool that lets you focus on the "design" part, rather than all the fussing about with rulers, protractors, and string, it's pretty much indispensable.

For years I've used RailModeller Pro (the paid version; there's also a more limited free one). This is a great design tool within its limits, but those limits are pretty severe. At heart it's a design tool for sectional track. It worked pretty well when I was using Kato Unitrack, but as the new layout is going to be based on flex track, the limits are much more apparent. And the author's focus right now seems to be on adding new features rather than making some of the existing basics work better.

The largest problem at present is that the tools for building curves with flex track are very poor. Those have improved some in recent releases, and you can now build a curve to a specific radius fairly easily (I still had to break out a calculator at one point). But that's only for simple curves. There's no way to specify easements. And getting a curve to end on something other than a 90-degree boundary seems to be "by eye" rather than anything more exact.

A secondary problem is the usual one of any library-driven system: they don't have everything I need in their libraries. Specifically, I'm going to be using some hand-made tracks using the fasttracks system. Those have standard shapes, but there's no current library for them. I actually did find one reference to there having been one about six years ago on an Italian blog, but I couldn't find the actual library, and if it's that old it's probably incompatible with the present version of the program anyway, as there was a change in how those were done a number of years ago (I had to update some files I'd made).

I could make my own fasttracks definitions, of course. I've done similar things before. But I don't really feel like doing it right now. It's not the part of the hobby that excites me, and I really want to do some track design, not fiddle about with software. I have other, more exciting, ways to fiddle about with software.

Another reason is that I'm thinking about building control panels in JMRI. And JMRI has some support for doing that off XTrackCAD track plans. Which already had me thinking about finally learning that program. Banging my head into RailModeller's limitations yet again finally motivated me to do so.

Installing XTrackCAD

It's 2016, and I'm using a Mac, so I just need to download some pre-packaged binary and run it, right?

Well, no. XTrackCAD, like JMRI, is fundamentally a Unix/Linux program. An unlike JMRI, it's both more complicated and with less polish, at least for the "on a Mac" parts. Because of this, the installation process is a lot more complicated than a normal Mac install, and with much more room for things to go wrong in unfathomable ways.

The good news is that it works, and It's actually fairly easy in practice. But the install process and actually using the program is very different from what a Mac user is used to.

This is ultimately one of the costs of "free" open-source software. Development resources are limited to volunteers for most projects, and volunteers work on what matters to them. Presumably they mostly want model-railroad features, and actually making the software usable for non-developers is a distant second in their priorities. After all, most of them are quite comfortable with Linux software. I can't say I really blame them; if I wanted slick software with fewer features I'd still be using RailModeller after all.

Also, after doing a bit of reading, apparently there are a number of technical issues getting the program to run under modern versions of OSX, and the reason there's a lot of complexity to the install process is largely due to that. If I was on an older OS (like 10.6.8, I suspect) it wouldn't be this hard. It still wouldn't be trivial.

Macs are Unix under the hood, although these days it's a fairly heavily modified version of Unix. One thing they lost along the way was X11 (there used to be a native version). So the first thing in the installation instructions, even before getting the current software, is to download and install several things including XCode (and its command line tools) and the X11 support: XQuartz, a library and some window-management system resource files.

This is done via the command line, meaning that you need to open a Terminal window (Terminal is in the Utilities folder under Applications if you've never had cause to use it before).

Long ago, when computers were coal-fired, I was a Unix sysadmin using X11. I haven't had any reason to use it in more than twenty years, aside from some minor use with JMRI and the Raspberry Pi, so my skills there are quite out of date. Still, I'm very familiar with command line tools, and I can muddle through. This must be an incredible pain for anyone raised on twenty-first century computers though, and next to impossible for anyone who isn't familiar with computers at all.

Lest anyone who hasn't tried this get too discouraged, I'll note that there are a fairly limited number of steps, and if you follow the instructions carefully it ought to work. It's that "ought to" that's the sticky point. If it doesn't, it's going to be very difficult to understand what went wrong and how to fix it. There's a Yahoo group where you can ask the developers for help, just be patient as they do have other things to work on and most of them aren't Mac users.

I already had XCode installed for other reasons so I skipped that step, but apparently although I had the command line tools installed at one time, they'd gone away in a subsequent release. So one of the commands I ran noted an error because they were missing. It seemed to work anyway, but just to be safe I installed the tools and re-ran the command.

Then the install for the "gnome-icon-theme" failed because the name had changed, and if you didn't read all the messages, that would be easy to overlook. The error helpfully told you the new name and suggested installing that instead (so I did), but despite the software obviously knowing the new name, it wouldn't just substitute it and carry on.

Finally, I fired up XTrackCAD, only for the Mac's Gatekeeper software to step in and tell me it wasn't a properly signed application. Of course not; it's not really a Mac application at all, and I was running a beta version to get El Capitan support, so it wasn't going to be signed. Sigh.

So, there's an easy fix for that. Open the Security preference pane, and there's a button that says in effect "you tried to run X and it wasn't allowed, allow it anyway". Click on that and re-launch the app and it works, right? Nope.

Here the problem is that I run applications from a non-Administrator username for security, and that prevents writing to applications (part of that “for security” bit), which Gatekeeper needs to do to sign them, which is what that button is doing. So, a quick switch over to my admin username, launch the app, get rejected and click the button, launch the app again, then quit and back to my usual username. Now it works.

One final thing: by default XQuartz authenticates network connections. That's important if you allow your XWindows system to be remotely connected to. But there's a problem: that's tied to a static IP address, and most computers these days use dynamic addresses. On a Mac, if you go into XQuartz (which will be running once you successfully launch XTrackCAD) and open the Preferences dialog, under the security section there's a checkbox for "Authenticate connections”. Unchecking that should avoid any problems for changing addresses. It may be safe to leave this checked, if you quit XQuartz when not in use (I can't tell offhand if it creates new access keys each time it's launched, but the description implies that). If you do uncheck this, it's important to be sure you have your firewall turned on (on the same Security Preference Pane used to control Gatekeeper).

Now in truth, all of this took less than an hour and I had the program running. But in the process of that I had to do quite a bit that would be utterly alien to the average Mac user. It's probably a lot more painful for most people.

It also means that an evening I'd planned to use to design track went to installing software. Actually, I lost a couple due to playing with RailModeller first before I decided it wasn't going to work. and then learning the basics of a new program before I could really dive in and do design.

BTW, I should mention that I'm using the OSX beta version from early May (4.2.3b), which is intended for use on El Capitan, as I wanted to learn the latest version and there are apparently some issues with older ones on ElCap, which is what my computer is running. Things may be slightly different if you use an older release. And the beta may be less stable (it's a beta, after all) than a normal release. But aside from a couple of odd hangs which I think were me rather than the program, it's been pretty solid.

Using XTrackCAD

Now to finally use it. My past attempts have foundered on my belief that any software can be learned without reading the manual. I've been working that way for decades and it usually works, except when it doesn't, of course. This is one of those times. Of course it doesn’t actually have a manual, which is part of what makes learning it fun, but there’s an onliine wiki User’s Guide with a tutorial and some examples.

As the name says, this is a Computer Aided Design (or Drawing) or CAD program. CAD programs are notorious for being extremely flexible at the expense of being very hard to learn, with lots of un-obvious solutions to simple problems. And while this isn't as bad as some, it's not really easy.

There's internal help, but frankly I found that to be fairly useless. And it mostly doesn't even bother to describe Mac details when those differ (it talks about Windows and Linux, but Macs appear to have been ignored), which is part of what I needed help with. Better is the wiki, which at least tries to cover all platforms and provides some good basic info, although the organization is a bit wonky (it took me two days to find the file format for parameter files, because it's buried halfway down a page about config file formats).

There's a Beginner's Tutorial available, so I started with that. It was a bit simplistic and left me with a bunch of questions, so I hunted around for more info later, and found a very detailed tutorial on TrainBoard. That, and a bunch of experimentation, helped a lot.

My goal was to design a simple interlocking with several tracks and switches that I'm going to build as a test-bed for some of my electronics work, as well as a way to get some experience with the fasttracks assembly and refresh my flex-track skills. It's not complicated, and I could design it faster on graph paper, but it's a good excuse to learn the software.

The main window shows a "canvas" area where the tracks are drawn, and this can be zoomed in all the way to "real size" (scale of 1:1). Lots of people use 1:1 scale to print out paper copies as a guide to laying track, once they have a good design, but since your monitor is a lot smaller than the layout room, usually you're going to be working zoomed out to some larger ratio (it starts at 8:1).

Although they mention page-up/page-down buttons as a zooming shortcut, the scroll wheel on my mouse actually defaults to doing that, which is more convenient.

There was a second all-black window that made no sense initially, but it turns out it's the Map Window, used to select which portion of the layout you're working on when you have one defined. Of course I closed this and later had to re-open it (View Menu, Show Map). Using it is also a bit non-intuitive. You have to click and drag the black rectangle to move it. You can't just click on the area you want to see, or use arrow keys.

Although the program's not fundamentally a Mac program, these days all drawing programs use similar conventions, so it's actually not that hard to figure out how to use it for the most part, although some of the commands work a bit differently from what I expected, which I'll get to in a bit, bur first for some basics.

Because this is a CAD program, it's not really intended to be used "by eye". It works much better when you pay attention to the numbers. After you add a part, it switches to the "Describe objects" mode (and there’s a button if you need to switch at other times). In that mode, if you click on the part you just added, or another, you get a window full of numbers like X,Y coordinates and angles. Using these to align parts before joining them will avoid a host of problems.

One last thing: shortcut command keys use the Control key rather than the Apple Command key (the cloverleaf one), because that's the Unix/Linux convention. So saving the file is Control-S rather than Command-S. Just one more thing to throw off an experienced Mac user who's used to the other key. Despite decades of experience with Unix, this still throws me because mostly I work in Mac apps these days.

Setting Up

The Options menu lets you select a bunch of useful things. Layout Options is probably the first thing to use. In it, you can select Scale, and while mine had defaulted to N scale (perhaps a leftover from some earlier attempt to use it), there's actually a "N(JP) (1/150.0)" scale now for Japanese N. You can also set the size of the layout, and define a minimum radius and maximum grade. Finally, this is where you give the layout a name.

I named my Layout “Demo 1" and set it up for Japanese N scale. I'm working in metric, so the "room size" for my test layout is 2' x 4' (122 x 61 cm).

Note: that’s not the test layout at the top of the page, that’s a different test where I was working on elevations and grades to model the other end of Ochanomizu station.

Under Preferences you can select English/Metric measurements, and I switched to metric since I prefer to dimension track that way. Despite growing up with English units, I find decimal measurements in millimeters, centimeters and meters much easier to deal with, particularly when I'm working on things ranging from small (track dimensions in mm) to very large (two-and-a-half-meter long station platforms).

In metric, the program does everything in centimeters, which I suppose is reasonable. I found this a little confusing at first, because they don't show units, and I tend to assume a metric length without qualification is in meters.

Where did the Track Go?

The next step is to select the types of track to use, which confusingly is done using the Parameter Files item on the File menu. There's also a ribbon bar, but it displays ALL selected parameter files, rather than just one, and doesn’t let you add files, so it's essentially useless. It's also blank for some reason, hmm, so is the parameter files window.

This turned out to be a lot simpler than I thought it would be. The files are there, but you have to load them before you can use them. To do that on a Mac, you have to Browse (using the Parameter Files item of the Files menu) to the application, and then inside it. The folder you want is:


On Linux this is just /usr/local/share/xtrkcad/params, and on Windows it's in the same folder as the application.

Once there, select the files you want, one at a time, and click Ok. You can't select multiple files together, but you can add as many as you want, one at a time.

By the way, the purpose of these files is simply to make using standard turnouts (and sectional track) easier. You don't need them for flex track itself, and you can make a turnout manually from flex track, it's just a lot of extra work.

The actual format of the files is defined on the wiki's File Formats page, but they're simply ASCII text files with a non-standard ending. To view them you need to use an ASCII-safe editor. TextEdit treating the file as Simple Text will work. I prefer to use TextWrangler myself. To open this kind of file with an editor, open them by Control-Clicking in the Finder window, and selecting “Open With” and “Other”. There's not a lot of reason to examine the files, unless you plan to create your own, but it's nice to know you can look under the hood this way.

My First Crossover

Placing a switch ought to be easy, right? Well, it is, but it took me a while to get the hang of it. Part of the problem is that tracks tend to move when two separate tracks are joined, and sometimes only one end moves, resulting in what should have been a straight track being at an angle. This gets even more complicated when you need two switches to face each other (e.g., in a crossover, or a yard ladder). There turns out to be a fairly simple solution to this, although I spent several days getting there.

In the following steps, I'll show how I used what I'd learned to make a crossover between two parallel tracks at a specific spacing.

I'm using Fast Tracks jigs for my switches, and will use their #8 double crossover in some places. That imposes a track center spacing for parallel lines of 2.77 cm, or roughly 1 3/32 inches. That's a rather weird spacing for N scale, although as I note on my flex track pages, it's not unreasonable as the standards run from 25 mm to around 30 mm for more prototypical models (neither Kato nor Tomix, with their much larger spacings, qualify as prototypical in that sense). Of course, you can use any spacing you like when placing two facing switches (as long as they don't overlap; that would be problematic).

I may use other spacings where I don't have crossovers, but this interlocking is going to have both a #8 double crossover and a #8 single crossover made from a pair of switches (if this sounds familiar, it should). So I need to enforce a 2.77 cm spacing when I put in the two #8 switches if I want all three tracks at an equal spacing (I'm not doing the double crossover now, just the two facing switches). But the process is the same for any spacing and for any switch with a Parameter File model (which is pretty much every switch anyone makes).

Here's the trick: placing a switch on top of a length of straight track will cause the switch to use the coordinates of the track (meaning the track won't move, the switch will). Note that I don't mean "joined to the end of a straight track". I mean lay a straight track and put the switch in the middle.

So I start with one straight track placed using the "Create Straight Track" button, and then use the "Create a Parallel Track" button to create a second at 2.77 cm offset. I've also found it best to do this fully zoomed in, at a 1:1 ratio. Some things are easier if they're mostly lined up by eye, although you still need to check, and sometimes adjust, the coordinates.


Now I place a #8 left switch on this using the "Place a Turnout or Sectional Track" button. The way to do this is to select the desired switch from the list, click on the canvas (someplace there's no track) to switch back to that window, and then click and hold the button, and move the mouse and the blue outline of the switch over the track until you get to where you want the switch. When you have the right position, release the mouse button, and press Return (Enter on some keyboards). The switch will lock to the straight track, removing a length of the straight track in the process.

Note: If the switch faces the wrong way, it's because the switch always faces away from the mouse, so try to hold the mouse over the rail opposite the diverging side. If you got it wrong, use undo to go back, don't delete the bad switch, or you'll leave a hole in the straight track which will complicate things.

Now add a straight track lined up with the diverging route using the "Create Straight Track" button. Try to center this exactly on the end of the switch and pull away at the angle of the switch. However, as long at the diverging track hasn't joined to the switch, you can use Describe to match the angle of the switch. This needs to extend over the other track and out a couple of inches (we'll delete the excess in a bit).

Angle numbers can be a bit wonky. The switch shows up at being at 0 degrees. The #8 fast tracks switch has a diverging angle of 7.13 degrees (it's listed on the paper template). But if you check the angle of the track before joining, you'll see that the angle that lines up with the diverging route is 90 - 7.13 = 82.87 degrees. So, if you lay the track by eye and get 83 degrees or something, just fix it here. Or don't, as long as it's close it will move to the correct angle once joined.

Once created, use the "Join" button to link the new track to the switch. The switch (and its attached straight tracks) should not move, but it's probably a good idea to click "Describe", select the switch, and make sure the reported angle is still zero (or whatever it was before). I noticed an interesting quirk here. Everything was right, but the angle of the diverging track was now reported as 270 - 7.206 = 262.704, both a different coordinate system (subtract from 270 rather than 90), and a slightly wrong angle. The latter is probably due to a dimensional error in the parameter file used for the switch, or rounding somewhere. Still, it is close enough.


Now place another #8 Left switch, just the way the first was placed but over the parallel track. Be careful that the straight portion lines up with the parallel track, then slide if along until the diverging route lines up with the diagonal track. When it's right, it's going to lock into both of them in a very obvious manner. Then press Return and it will join to both (and leave a bit of the excess diagonal dangling, which you can then select and delete).


Now use Describe again to check the four straight tracks at their ends, and make sure they're all still at the correct offsets and angle (they should be, if everything worked; if not click undo and try again).


And there you have it, a single crossover made exactly to the size and position it needs to be. It's more work than the simple drag-and-drop of RailModeller, and more of a pain for quick checking of ideas. I'll probably continue to use RailModeller for simple designs or preliminary concept-checking.

I think I'm getting the hang of XTrackCAD now. It's quirky, and still frustrating at times, but having worked through both of those tutorials and done some playing, I'm starting to see how it all works. And with practice I’m getting much faster and placing track, and making fewer errors.

One bit of advice: I went through about three different "layout" files in the process of learning, tossing them and starting over when things didn't work. Don't start on your actual layout when learning; spend some time on a disposable file, and even later that may be a good way to pre-check ideas before touching the layout file.

I also always work on a copy of something as critical as a layout track plan, so I can always toss all the recent work into the metaphorical trash and go back to what I had last week.