Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - GG_Train

Pages: [1]
Hi,  I would like to share with you the process of converting SketchUp files to CSV format.  This has been successful in thousands of conversions with the exception of ONE single failure due to hidden geometry causing null faces.  There are 2 versions of this conversion: the first will convert each SketchUp image to have triangular faces only; the second or enhanced version eliminates common sides of the triangles to create a many sided polygon.  The limitation here is that concave polygons will not render correctly in most cases.  This limitation is by design in OpenGL, so the best way to eliminate the concave polygons is to do it manually in SketchUp rather than via an external conversion program which would be very complicated to design and build for 100% accuracy.  It is much easier to add a few lines in SketchUp.

The results are never distorted and are on the proper axis.

STEP 1 contains the executable files SketchUPXML2CSV.exe and SketchUPXML2CSVEnhanced.exe.  Place them in a directory of your choice.

STEP 2 contains the Ruby Script files to act as Plugins for SketchUp 2017.  These files are bve_export.rb, bve_export_enhance.rb, and b3d_config.rb.  You edit and must substitute the directory name including drive letter of the location of the executable files in bve_export.rb and bve_export_enhance.rb.  All 3 files should be placed in the following directory "C:\Users\%USERNAME%\AppData\Roaming\SketchUp\SketchUp 2017\SketchUp\Plugins".


Close SketchUp if it is already opened.  Open up SketchUp again and you will notice the following added under Tools

Enhanced Export to BVE
Enhanced  Export Selected to BVE
Enhanced Export to BVE 2 Sides
Enhanced  Export Selected to BVE 2 Sides
Export to BVE
Export Selected to BVE
Export to BVE 2 Sides
Export Selected to BVE 2 Sides

As stated before the enhanced tools create polygons from common sided triangles while the standard version just uses the triangles. The Selected versions only convert the currently selected faces in SketchUp. 2 Sides outputs 2 sides of the face.  Trees and fire hydrants use 2 dimensional images that cross each other at right angles.  SketchUp files using images such as these require the 2 sides to be drawn.


The conversion process works as follows:  SKP ==> XML ==> CSV

The Ruby Script files convert SKP files to XML format using SketchUp's internal objects to cycle through the faces organized by material.  The executable files SketchUPXML2CSV.exe or SketchUPXML2CSVEnhanced.exe convert XML files to CSV format.  These executable files are created via Visual Studio 2017 C# solutions.  I have attached zip files and  Each contain the C# solution and source code for the appropriate conversion program.  Other solutions could be built for formats other than CSV.  The XML files can be deleted manually as they are never needed after the conversion is successful.  I could have put some code in place to perform that task automatically.  I may do so in the future.

If the conversion programs find a material name in SketchUp preceded by a #, it will also set an emissive color. This is useful for lighting.  For example, a material name of #Green which contains an RGB value of (0,255,0) will set an emissive color using the same RGB values.  When applied to a signal it would show a lighted green color.

NEVER use "<" or ">" characters in material names.  The XML loader will fail.  I may add code to substitute those characters with "[" and "]" respectively.

Textures using files have no prefixed directory.  The assumption is that the texture files reside in the same directory as the CSV file.

An example of a generation of concave polygons would be a ring or border. For the enhanced conversion to work correctly, rectangular borders must have their edges connected by a diagonal line to eliminate the concave polygon.  Rings have two circles whose edges must be connected by a line.  Also concave polygons can be eliminated by using the Fredo Tools Curviloft plugin in SketchUp.  I would use this plugin for subway door window borders.

The zip files are located here:,r2c6z6p3ulx87ip,8y7gaww777p2quw/shared


I have known of OpenBVE for some time and did some minimal work to get familiar with the product.  About 2 years ago I detailed a comprehensive fictional subway plan for Staten Island.  The details are here  One of the lines takes the existing 2nd Avenue plan and extends it to Staten Island via Governers Island and the Red Hook Tunnel to St. George, Staten Island using Brooklyn as an anchor.  The existing SIR route would be modified to handle subways with signals, new structures and expanding the right of way.

I would like to build my objects as detailed as possible, so I wrote a program to create vertices and faces using primitive objects (rectangle, circles, polygons, etc.).  Although I had success it was equivalent to blindly building objects.  I needed something visual.  Enter Sketchup.  I have become quite experienced in using this product over the last year and wanted to find a way to export from .skp files to .csv files recognizable by OpenBVE.  My success was limited until I found a plugin that extracted meshes, faces, and vertices.  This plugin generated an XML file and had a trial version conversion program that converted the XML format to B3D format.  Sadly there is no longer any support for this so I wrote my own conversion program to generate .csv object files.  The results were fantastic, but there are downsides where the triangulation of the polygons generate quite a lot of faces as well as some problems with reverse faces that can be corrected building the Sketchup model.

I have somewhat coded up the Tottenville yard, rendering it size-wise as closely as possible aided by Google Maps satellite view.  I have built custom signals and am investigating how to integrate them with the Signal namespace if at all possible.  For signal identifiers I will use the chaining for the current 2nd Avenue line.  One problem is that the distance markers go negative based on the current use of the IND zero point where a current signal at 72nd Street is marked as 1168.  So when the identifier goes negative, I will precede the number with an "M" for minus.

Other issues concern FPS which is not to high, barely cracking 20 with a CPU running full throttle and my laptop fan running at full steam.  I am using a nearly 5 year old Sony VAIO 2.2 GHz Quad Core i7 running under 64-bit Windows 7 Home Premium with 8GB of RAM.  My graphics card is the NVIDIA GeForce GT 540M with 4GB of memory.  Not sure if this is a problem.

Anyway here are some screen captures.

1. Regional Plan using Scribble Maps

2. Forward View showing signals, bumpers, and crossovers.

Pages: [1]