Jump to content

Export a Spline into Blender as a CSV to create Roads/Railways

Recommended Posts


This purpose of this tutorial is to show how to export  a Spline from Giants Editor to Blender using a CSV (Comma Selected Variable) file created by the Spline CSV Creator script and the Blender Add On csv_mesh_importer v0_7alpha4.

I will be using Blender 2.79 throughout this tutorial as that is the only version that supports the CSV mesh importer, however if you wish to use Blender 2.9 then I suggest you first open the CSV in a 2.79 version and save it then in Blender 2.9 append the csv object from the 2.79 file.

Updated scripts for SetTerrainHeight by spline, PaintTerrain by spline and the new Spline CSV creator script are available at the end of this tutorial in a zip file.

Spline CSV Creator script

The script creates a new spline aligned to the terrain from an existing one in the form of an xml compatible layout for the new spline to create an i3d and a seperate CSV file (Comma Selected Variable) in the form of a text file

for use with the csv_importer script in Blender (2.79 only at the moment) re-labelling the axis to convert the Giants Editor transform axis to the Blender format, X(Z) axis, Y(X) axis,  Z(Y) axis, Giants in brackets.

The script allows for the original spline to be created in 2d with less cv’s and away from the terrain, the new spline created can easily be used in any of the Spline Terrain/Paint/ Placement scripts.

Open map in GE

Create a spline and align it to the road network you wish to model.

As you can see by the following image there are only 5 cv’s  (including SE) on the spline to create the desired shape.



Open the Spline CSV Creator script in the script editor and set the number of points on the new spline you want to create.

These will depend

1. On the size of  the mesh you are going to use for your road (rail),

2. On the slope of the railway if using the script to create a rail bed (higher number will give a more gentle slope)

In this case I am using a 5m road section as an example, larger lengths can cause blockiness on tight corners to start with but this can be rectified later in Blender.



In the above image you can see the 5m setting  local mSplinePiece =5.0;  the spline has been selected and the script executed it also shows part of the new log entry ( Windows(C:)---Users--Computer name---AppData--Local--GIANTS Editor64bit 8.2.2-- editor_log.txt) detailing the new spline parameters.

If  AppData folder not visible then

Open File Explorer from the taskbar. 

Select View > OptionsChange folder and search options.

Select the View tab and, in Advanced settings, select Show hidden files, folders, and drives and OK.

The next step is to open a new blank file in Notepad ++ and copy paste the new i3d coding from the editor log


<?xml version="1.0" encoding="iso-8859-1"?>

up to and including 




    <Shape name="spline01" translation="0 0 0" nodeId="11" shapeId="11"/>



then save as spline.i3d (not xml)


Then copy/paste the csv data  (data only not axis text) into a new blank file in notepad++ (or normal notepad) and save as CSV.txt

Import the new spline. i3d into the map and it should appear at the location of the original spline but alligned to the terrain (I have named it spline01 for clarity) and as you can see by the following image the spline now contains cv’s at 5m spacing along its length aligned to the terrain.



In the next image I have used the TerrainHeight by spline script to level the terrain ready for the road, as the road is on the side of a hill I have offset the height on the sides.

To enable easier smoothing on the sides of the road a good rule of thumb is where possible to have the msideCount

1.5 times the size of the road texture width to alleviate any problems with the maps 2m terrain sections.




The first step is to download and install the csv_mesh_importer v0_7alpha.zip which is available along with the Installation instructions from here.


There are also detailed instructions and examples of how use the Add On at that link.
I have also included the Install and Importing instruction here.

Install Plugin

Download the csv_mesh_importer v07_alpha4.zip from the download link in the above address save and unzip the file
   Close Blender if active
Navigate to Windows(C:)—Programm Files—Blender Foundation—Blender—2.79 (or whichever version you have)—scripts—addons  and copy paste the csv_mesh_importer.py into addons. The script cannot be installed from zip as there is no init file.
Open Blender --Select File—User Preferences—import Export,  locate and select the checkbox next to CSV Mesh Importer then Save as Default.
Close Blender.
Re-Open Blender and set up as shown in the following image



Import CSV file

Select “Point list containing X.Y,Z columns in File Type menu
Select the folder icon at the end of the .csv File Path: selection box and browse to where you saved the CSV.txt file and click Accept (top left)
Ensure that comma[,] is selected in the Delimiter section
Click the Add Button and in the configuration box below
Select Create vertices only and in the pop up box select “Create vertices and edges (single line)”
The X,Y,Z column details can be left as is (the script has already allowed for the axis labelling).
In Object Name put csvSplineRoad.
Select import
The csvRoadSpline mesh will appear in the Scene panel at the top as a mesh,  select this and zoom out till you can see it
(it will be at the same  world location as it was in your map, hence the high camera clip distance ‘End 10km’ in the view menu). Do not change the location of this mesh as it will cause problems when aligning the finished road in GE.



Import your road section. obj , to avoid any problems with alignment ensure your road section is aligned along the X axis, rotate and Ctrl-A Apply Rotation and Scale if necessary.



Reselect csvSplineRoad and Alt –C  Curve from Mesh Text
Select edit mode – Vertex Select and select  the end vertice of the csvSplineRoad mesh. (corresponding to the start of the spline in GE in this case “E)” -- Shift-S Cursor to selected
Select Object mode – Shift-Ctrl-Alt-C  set Origin -Origin to 3d cursor

Select roadSection mesh - Shift-Ctrl-Alt-C  set Origin -Origin to 3d cursor- Shift-Ctrl-Alt-C  set Origin - Geometry to Origin
And you should see the following


Add Modifier –Array – Fit Type Fit Curve –select -csvSplineRoad – Relative Offset  X  1.0 – select Merge adjust distance so all your sections are joined.
Add Modifier—Curve – Object csvSplineRoad-- Deformation Axis X
You should now have a road aligned to your csvSplineRoad


Apply the Array Modifier and then the Curve Modifier.
Add  Modifier – Edge split and apply.
Ctrl-A --Apply Rotation and Scale

You can now delete the csvSplineRoad curve and ensuring the road section is selected  File—Export – Giants  i3d -the road section as Road_1.i3d
Open the Road_1.i3d in notepad++ and correct the texture path if necessary and resave

Open map in GE and import the Road_1.i3d, all that remains now is to reset the transform values to match Giants.
Note the Translate X and Z values and just replace the X with the Z value (as a minus value) and the Z with the X value and set the Rotate Y to -90.
The final Translate coordinates are also listed in the correct order and value in the last data line of the Spline1.i3d should you require a reference.




You will also probably have to increase the Translate Y by 0.4 or 0.5 to further align the road with the terrain due to anomalies with the 2m terrain sections of Giants maps and the levelling process.

Road junctions can be created in blender by importing all the various road sections as obj and aligning/texturing to suit, eventually exporting the road system as one mesh.

There are times when despite everything appearing correct the transforms can go slightly wrong, the following image show how to correct any problems with rotation/ translation of the object.

This needs to be done before applying any modifiers

In the following image I have added a cube as guide to correct the road section rotation to zero (which is what the terrain would be in GE after you have flattened it).




Then,  with the  roadSction selected adjust the rotation of the “X” axis,  not as you would expect the Y , looking at the screen,  this is because the modifiers have not been applied so the road section retains its original configuration (see the second image in this section). I find it better to adjust the value in the Transform Rotation panel as it gives better control over the movement.

Always make sure the csvSplineRoad curve is in the centre of the object you are modifying as this will cause problems when aligning the object in GE



Blender 2

Another method is to use the Curve tools in blender

Select the csvSplineRoad then Alt –C mesh to curve

In object mode (for clarity) Select curve section and set the values as shown in the following pic (bearing in mind the values will be half the final width)




Then go into edit mode Ctrl T (Tilt) 90



and finaly in object mode Alt C – mesh from curve



and texture as required, some fiddling about may be necessary when importing into GE but it should align in the same way as the the previous road section (the Translate X and Z values and just replace the X with the Z value (as a minus value) and the Z with the X value and set the Rotate Y to -90.)

Once you have the csv data in blender then it can be used for all sorts of other things like stream/river planes walls/fences anything that a spline can be used for.

Example workflow for  a railway set up.

Create the train loop spline in GE (do not connect it at the moment) export as i3d/csv (SplineCSV Creator)

Create new spline (xml) and import into GE (do not move it once imported)

Flatten terrain (setTerrainbyHeight)
Import csv data into blender, create track layout with a new object or use existing model, also any other items you want to follow the track (poles/fence etc)

Export as an i3d and import into GE and position

Add ground textures (Paint Terrain by spline)

Add trees bushes etc (Spline placement)

Finally use the new spline you created at the start as the train spline (suitable closed)



Updated and new scripts1.zip

Edited by WrinkleysRule
Added info to Blender CSV, corrected scripts
  • Thanks 2

Share this post

Link to post
Share on other sites

thanks for tutorial and updated scripts i was just searching for this yesterday.

one note  i get editor error  this is not a png. it comes from setTerrainHeightbySpline4 script.

Share this post

Link to post
Share on other sites

Apologise, the error is caused by this line "-- Icon:123" at the top of the script , for the moment just delete the 123 and save the script in the script editor.

I will update the zip later

Share this post

Link to post
Share on other sites

Not as far as I know, the following link is as much info as I have found regarding an update for this particular script



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...