BVEStation

Author Topic: TUTORIAL: Convert SketchUp Files to CSV Format (Other Formats Possible)  (Read 546 times)

Offline GG_Train

  • New Recruit
  • *
  • Posts: 24
  • Gender: Male
  • BVEStation Member and Developer
    • View Profile
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

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

STEP 2

Conversion.zip 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".

STEP 3

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.

OTHER NOTES

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 SketchUPXML2CSV.zip and SketchUPXML2CSVEnhanced.zip.  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:

https://www.mediafire.com/folder/44rq6sqd9e6287h,r2c6z6p3ulx87ip,8y7gaww777p2quw/shared
« Last Edit: October 08, 2017, 12:31:06 am by GG_Train »
Joe