Bookmark and Share

Moving Stock Airport Buildings in FS
by John Allard
June 2011

I recently had a couple of situations where I wished to relocate stock FS9 airport buildings by a few hundred feet in FS9.  Though some of the airport editors (not all) will display these structures, buildings are not editable objects using the airport editors I’m aware of.  After the usual false starts and blind alleys, I’ve blundered onto a process that does the job.  It’s a bit tedious but gets the task done with no side effects that I’ve detected.  I don’t know if it works for FSX, not having tried it there, but all the same tools I used for FS9 will either work directly in FSX or have an FSX counterpart.  There’s a good chance that this process might serve there too unless there’s something different in the FSX scenery file structures that might throw a wrench into the gears.

How did I come to needing to do this?  In one situation, I had painstakingly added a missing GA ramp to the stock FS version of a large commercial airport, using Google Earth as guidance and an airport editor to do the work.  I got the ramp in the correct location and configuration using a screenshot of part of the GE image as a background guide, which worked just fine.  After firing up the modified airport up in FS, I found the control tower standing proud right on my new ramp.  Buildings don’t show in the airport editor I was using and I hadn’t realized the tower was there.  I didn’t have the heart to re-do the ramp so decided to see what it would take to move the tower.


Control Tower Move

A few days later, while browsing traffic elsewhere, I happened upon an Air National Guard base that has two good sized hangars on ramp stubs that protrude off the main parking ramp.  This was an enhanced airport, upgraded by my traffic program, which had placed Military Cargo parking positions inside the closed hangars.  What I saw was wingtips of C-130s sticking out through the walls and the nose and tail of one from the ends of the smaller of the two hangars – not a great effect.


Hangars Move

In both scenarios, sliding the offending buildings a short distance would solve the problem and leave a plausible situation in Flight Sim, so that’s what I set out to do.

Having worked my way through correcting these issues, I’m formally documenting my process here before it fades from the grey cells and so that others may possibly find it of some use.  I do so trusting that Mutley might permit me to publish this long and detailed article at his site.  He’s very good about that. 

There may well be other ways to do what I did and some of them may even be easier.  I do not pretend to be a scenery expert and those who can truly lay claim to that may find this whole article laughable, the FS equivalent of digging a ditch with a post-hole digger.  In any case, it worked, and so I pass this method on in hopes that it might help others too, somewhere, someday.  If nothing else, I learned a thing or three about FS scenery files in the process.

What I did involves several software tools.  Most are freeware however one key piece is payware.  There may be a freeware substitute but if so I don’t know of it.  Beginning with a list of the tools…

  • Notepad – It’s in your Operating System installation
  • BGLAnalyz – Scenery Decompiler – Freeware
  • BGLComp – BGL Compiler – Freeware in the MSFS SDK
  • Instant Scenery 2 – Object Placer – Flight1 Payware

The payware part, Instant Scenery 2 from Flight1, provides a vital piece of information needed to affect the building relocation process – without it, I’d have had no way of knowing which of the multitudinous FS scenery files contained the particular structures I was interested in.  Absent that, I’d have been dead in the water from the very beginning, so the contribution from the payware piece was vital.  If you’re aware of other products that will provide that information, particularly freeware products, use them.  I’d appreciate a follow-up e-mail with the information if such substitutes exist.

At this point I’ll paint for you the steps of the overall process in broad brush strokes before descending into the details.  The list below contains the essential tasks in the process of relocating the buildings…

  • Determine the FS BGL file that contains the building to be moved.
  • Determine the current location coordinates of the building.
  • Determine the desired location coordinates of the building.
  • Decompile the scenery BGL to an XML file.
  • Edit the location properties of the building in the XML file.
  • Compile the XML file back to a scenery BGL file.
  • Replace the original BGL file with the new one.


Diagram of Process

Determine the FS BGL File that Contains the Building to be Moved -  For the first step, I used Flight1’s Instant Scenery 2, a recently released major revision to their older Instant Scenery product.  The key feature of IS2 that enables this is new – it’s not in IS1.  IS2 has a Scan feature which puts labels on scenery objects within a user-specified distance from the current user location.  The label is the filename of the FS scenery BGL file from which the object is rendered.  This was truly the key to being able to perform the building moves.  Without knowing the file in which my offending building lurked, none of the rest was possible.

  Within FS with a top-down view, IS2 is invoked from the top line menu.  After the app is up, a right-click on the airport shows a context menu – Select “Extras”, then “Show Objects from all BGLs…” from the flyout.  A new dialog box appears from which the filename scan is performed.  If you’re close to the building in question, a radius setting of 1 NM in the dialog box field is more than sufficient.  The field will only accept integer distance values, so you’re stuck with a mile or more.  Be certain the checkbox for “Gen. buildings” is checked and press the “Scan” button.  Go have a cup of coffee while it’s running – it takes several minutes.  When you return, each scenery object will have a green text label showing the FS file name from which that object is created.  Make a note of the filename for the building you wish to move.

 


Finding the Scenery File – Step 1


Finding the Scenery File – Step 2


Finding the Scenery File – Step 3

Determine the Desired Location Coordinates of the Building -While still up and running in FS the next two steps are easily performed.  It is necessary to get the current and desired location coordinates of the building you wish to move.  This is best done in Slew Mode, in a top-down view.  If the building is large, it may be worth while to get the coordinates of the four corners as well as the center.  If the shape is irregular, the four corners of a bounding rectangle oriented with the cardinal compass points might be best.  For a relatively small building, just getting the coordinates of the center point is probably sufficient. 

 
Finding
Building
Locations

When using Slew Mode in FS, the latitude and longitude information is displayed at the top-left of the screen, just like the Shift-Z information display in Normal Mode.  It is from here that you’ll get your building location coordinates.  Slew yourself to the building center and/or the corners as noted and record the current locations.  The FS readout gives longitude and latitude readout with precision to the nearest 0.01 minute and that is sufficient; The XML files use more precise values but attempting to obtain them here will not be of much use in either finding or editing the locations.  If very precise re-location of the structure is needed, some trial and error entries might need to be made in the XML file, which uses more digits, permitting better precision than the FS display gives. 

De-Compile the Scenery BGL to an XML File - With the current and desired location coordinates captured, navigate to the Flight Simulator scenery folder tree and locate the BGL file that contains the building in question.  At this point, it’s wise to create a copy in the same location, changing the extension from “BGL” to “ORIG”. Using this method or some other of your own choosing to be sure you can revert to the current situation if things go badly wrong is worth the time and trouble.  Do it.

Pausing here to address file handling for this process, I’ll describe what I did.  There are myriad other ways you can handle this and you may do what’s comfortable and what works for you.  I’ll note at this point that a number of files are involved in this and the decompile process may create a large number of model files (I got 73 model files from one BGL decompile) that will need to be available to the compiler when performing the re-compile step later.  Having all the applications and data files scattered through various locations invites confusion, if not disaster and I found it best to concentrate everything in one temporary folder, doing all the work within that. 

I created the folder and brought in copies of the scenery file, the de-compiler and the compiler and did all my operations there until the new BGL was created, copied to FS and satisfactorily tested.  Once at that point, the entire temporary folder and all its contents can be erased and the only remaining trace of what you’ve done will be the new BGL and the renamed copy of the original BGL in the FS folder where you first found it – all neat and tidy with no artifacts or footprints left cluttering up your hard drive.

After copying the scenery file that contains the building in question to the working folder, the next step is to decompile it to editable XML code.  This is an appropriate time to address copyrights and software licenses.  Generally speaking, decompiling and modifying of program code or data is not permitted by the various software licenses.  It’s one thing to do it for your own purposes, either as a learning tool or to tweak your own copy of legally owned software (which the original vendor will then no longer support).  It’s quite another to decompile, edit and re-distribute what you’ve done to others, particularly for profit, or to use data, code or techniques gleaned from a developer’s software to produce your own.  There are legal and ethical issues intertwined throughout this and you should carefully consider whether what you’re doing is legal if you intend to do any more than simply tweak your own copy of FS.  Software developers have no sense of humor over such things and sometimes have deep pockets and staffs of lawyers who are engaged in protecting the company’s intellectual property.  It’s best to keep your personal integrity intact and to not mis-use the work of others.

Decompiling

Duly warned, lets move on to the decompile step.  It is only necessary to drag and drop the scenery BGL file onto the icon for BGLAnalyz.exe and the de-compiler does the rest.  An XML file will be produced, having the same filename as the BGL file, but with an XML extension.  The XML file is pure text and may be quite large.  In my case one XML file contained over 345,000 lines of code – that’s not bytes, that’s lines of code. 

Depending upon what’s in the BGL file, the de-compiler may also produce a number of model files with a MDL extension.  It will not be necessary for you to do anything with these, but they do need to be available to the compiler when re-compiling, so don’t erase or move them until all is complete and tested. 

Once the original BGL file is successfully decompiled to produce an editable XML file, it’s best to delete the original BGL from the working folder.  When you get to the compile step, a new BGL of the same name is created and you don’t want to be confused about whether you’re looking at a new one or an old one after compiling.

Edit the Location Properties of the Building in the XML File - Once written by the de-compiler, the XML file contains the editable code that defines the buildings (and many other things) in FS with all their respective properties and attributes.  If you’re not familiar with XML you may find that thought intimidating but the changes you’ll be making are relatively easy and straightforward and XML code itself is no more complex than the aircraft.cfg file or similar things in FS.  The most difficult part is finding the code for a particular building within a large XML file.

Since the file is text only, opening and editing the XML code is best done with Notepad, by right-clicking on the XML file and selecting “Open With” from the pop-up.  If you simply double-click on the XML file it will probably open in a browser window with a lot of helpful labels that aren’t very helpful at all.  For our purposes, stick with Notepad.  Bear in mind that the XML file may be very large and Notepad operations such as opening, searching, saving, etc. may take some time.  Be patient and allow the screen to refresh after performing any such operations, keeping in mind that your OS may be dealing with a prodigious amount of text.


Opening XML File for Editing

Once the XML file is open in Notepad, our next objective is to find the block of code that defines the particular building in question within that file.  It’s necessary to use Edit -> Find and enter part of the latitude or longitude coordinates to seek out our building.  I used the degree value and the integer part of the minutes value, with the trailing decimal, as a search term.  I looked at the format of the corresponding properties in the code block for the first building in the file as a model for formatting my search term.  Be very careful to put spaces only where they belong. My search term was something like…

“W083 50.”


Searching the XML File

After pumping through a dozen or more wrong ones, eventually the right block of code came up, identifiable by the latitude and longitude values matching the current building location.

Carefully edit the latitude and longitude values, using the data you derived in slew mode for the desired building location.  Be very careful to use the exact format that is used in the XML file, which may differ slightly from what you got from the Flight simulator screen – for instance, I needed a “N083” in the XML file instead of the “N83*” that was displayed in FS.  This is a place where an extra space or a missing quote mark will cause no end of wailing and gnashing of teeth.  Be careful – get it right on the first try.  After editing the location values in the XML file, save and close the file.

Compile the XML File Back to a Scenery BGL File – Be sure you’ve deleted the copy of the original BGL file from the working folder so there will be no confusion about whether a new one has appeared after running the compiler.  Compile the XML file by dragging and dropping it onto the icon for BGLComp.exe.  If after a few seconds a BGL file with the same name appears, all is well and the compiler ran to completion. 

Compiling the XML File

If that does not happen it is likely that a compile error occurred.  You may have briefly seen a Command Prompt window flash on the screen during the compile but it will disappear too quickly to be read.  If your compile failed, it will be necessary to re-run the compiler in a way that will permit seeing the error messages and determine what caused the compile to fail.  Take heart – it’s not hard.

·         With your Windows Explorer open to your temporary working folder, Copy the Path from the Address field near the top of the window, placing the path on the clipboard. 

·         Open a Command Window thusly – Start Button -> All Programs -> Accessories -> Command Prompt.

·         Click to the Command Prompt window and type “cd “, being sure to include the trailing space, then right-click and Paste.  Press Enter.

·         Type “bglcomp.exe [your XML file name with XML extension]”, being sure to put a space after “bglcomp.exe” and not including the square brackets shown.  Press enter.

Compiling the XML File in a Command Prompt Window

The compiler will run again and this time the errors that prevented its completion will be shown.  It will be necessary to try to understand what happened and to make the appropriate changes to the XML file and try again until a successful compile is achieved.

In my attempts I had two compile errors, neither related to the building in question or to my edits.  These appeared to have resulted from bugs in the de-compile process since they were in areas where I did no editing.  Nonetheless, they were easily fixed after carefully reading the error messages in the Command Prompt window. 

Error 1: A five-digit “toptexture”= value was in the XML code but the error message indicated that 122 was the maximum allowable value.  I corrected that by simply truncating the value to the first two digits.  I took the time to identify and go look at the building later and it looked fine.

Error 2: A parameter label of “pwindowsize” was declared invalid.  I did a search in the XML file and found no other examples of “pwindowsize” but many of “windowsize” at the corresponding place in the block of code for each building, so edited “pwidowsize” to “windowsize”. 

After making those two edits to my XML code file, the compiler ran without errors and a usable BGL file was produced.

--------------------------------------------------------------------------------------------------------------------------

Notepad Note:  Error codes often give line numbers to help you locate the offending line.  In Notepad, Format -> Word Wrap (off, unchecked) and View -> Status Bar (on, checked) will turn on a status bar at the bottom of the Notepad window that will give the line and column number of the insertion pointer position – very helpful for finding the line with the reported error.


Notepad Status Bar

--------------------------------------------------------------------------------------------------------------------------

Replace the Original BGL File with the New One – Once to compiler runs all the way through successfully and produces a BGL file with the same name as the XML file (and the same as the original BGL) it’s just a matter of copying the revised BGL back to the original location in the FS directory tree, restarting FS and having a look to see if the results are as desired.  It may be necessary to fine tune the building location by repeating the edit-recompile steps.  If you still have your edited XML file, it’s not necessary to decompile again – just edit again and recompile.  In one or two more iterations it should be possible to place the building exactly where you’d like it to be.  Note that each building in the XML file has a “heading” parameter too, so if you wish to rotate the building it is possible to edit that at the same time you edit the location.

Summary:  As noted at the beginning, there may well be easier or better ways to do this, but I managed to find my way through this method a piece at a time, learning something potentially useful and having some fun along the way. This method has worked for me in two of two attempts.  Hopefully if you ever run into a scenery anomaly that drives you crazy, this will give you a way to deal with it permanently. 

As near as I can tell there are no derogatory side effects from using this method.  FS9 behaves as before and the only visible changes are that the buildings that needed to be move are in fact moved.  You can’t ask for more than that.

Software Used:

Notepad – It’s in your Operating System installation

--------------------------------------------------------------------------------------------------------------------------

BGLAnalyz – Scenery Decompiler – Freeware - FS2004/FSX Bgl Analyze. Included are two different versions of a disassembler program for FS scenery files. BglAnalyze9 is for FS2004, BglAnalyze X for FSX. Where there are differences between the scenery files of both versions of FS, the programs will recognize if your are using the wrong program. In both versions only those scenery files can be disassembled which can be recompiled with the BglComp compiler from the FS SDK. If you try to recompile a disassembled FSX scenery file with the BglComp for FS2004, you will be confronted with a number of error messages, because the FSX scenery files have a number of features which were not existing in FS2004. By Winfried Orthmann.

File library search term: bglanalyze

NOTE: There is a different version of BGLAnalyz called New BGLAnalyz.  As I understand it, it’s intended to work on a different format of BGL scenery files.  It’s not so much a revision to the earlier one, which I used, as it is a new and different application with a similar name.  It was not necessary in my case to go to that one so I know little about it.  I mention it here only to avoid confusion. 

http://www.flightsim.com/

--------------------------------------------------------------------------------------------------------------------------

BGLComp – BGL Compiler – Freeware in the MSFS SDK – If you don’t already have it, you must download and install the Microsoft FS9 Software Developer Kit (SDK) from the Microsoft Support site at…

http://support.microsoft.com/kb/555857

--------------------------------------------------------------------------------------------------------------------------

Instant Scenery 2 – Object Placer – Flight1 Payware - $29.95 at this writing (June, 2011)

http://www.flight1.com/products.asp?product=instscen2

--------------------------------------------------------------------------------------------------------------------------

Please send questions, comments or suggestions to…

allardjd@earthlink.net


Top