Developing Importer for .SHP (or SHX) to SketchUp

Solved !!!

But when a bulding has the foundation (piede) under the value “0” (-xx) sketchup does not represent it…(red color)

The current iteration of the plugin creates the building outlines in the Z plane and uses whatever value you select from the database as the height of the building. This is not technically correct because it doesn’t take into account the elevation of the base of the building. It’s been on my to-do list for some time to allow the selection of both base elevation and building height. What makes this more difficult is that the datasets specify this geometry in different ways … some specify the bases and heights in elevations only (meaning you need to subtract the two to get the extrusion distance) while others specify the base as an elevation and the height measured from there (which is simply used as the extrusion distance). There are no overarching guidelines for what the numbers represent … they can be in meters, degrees, furlongs, or whatever (note that mixed units are not prohibited).

Can you tell me what “Gronda”, “Pied”, and “Altezza” represent in your data? And what units you are using and what datum they reference?

hi…

Got it … thanks! Let me see what I can do to allow your data to import properly …

thanks !!!
you are a King !!!

I’ve uploaded a New Version here. The database field selection should look like this now:

This will create the base at “Piede” and extrude the amount specified by “Altezza”. If you choose not to use the base field, the building footprint will be created at z = 0.

You are a king !!!
you give me a dream !!!

finally i can make a full 3d scene !!!

thankssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

1 Like

From the SketchUp 6 user’s manual (page 310):

Just wondering if anyone remembers this plugin? Whatever happened to it?

Hi !

Nice work, very usefull !

Is it possible to import lines, not polygons in order to model the topography ?

The data table of my SHP file contains a field of elevation and i would like to model the ground elevation with sandbox tools afterwards.

Thanks !

Do you have a sample SHP file? And the SHX and DBF files as well? If they are proprietary, you can send me a private message.

Maybe it would be easier with these simplified files !

test8.zip (250.6 KB)

I’ve modified the importer to work with polylines (type 3) as well as polygons (types 5 and 15).

The latest version is here.

I’ve tested it against your sample data using these settings:

Here’s the result:

The data is treated as unitless … I happened to have used an inch model to import this. Once the geometry is imported, you can use the Tape Measure tool to scale everything appropriately.

test8.skp (1.3 MB)

Great, it’s perfect !

Thanks a lot !

1 Like

Bonjour tout le monde!

I’ve been trying to use this plugin on Mac but no luck so far, though I have tried every fix I could read or think of. I am really desperate to make this work here as this would prove invaluable to our work!

So I am trying to import all buildings of a given area (Ostend, Belgium) and have them extruded using the building heights specified in the dbf file (in a column called: HN_MAX).
I first installed the version posted on Apr 12 and ran it right away. After selecting the .shp file it imported the polygons just fine, but only if I left the ‘Database:’ field on ‘No’. If I tried again with ‘Yes’, then just like Lolabelittle I wouldn’t make it to the second dialog box to specify the height field(s), and get the following error:

Error: #<NoMethodError: undefined method `unpack' for nil:NilClass>
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:175:in `spirix_shapefile_import_get_database'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:150:in `spirix_shapefile_import_get_input'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:107:in `spirix_shapefile_import'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:314

So I modified the ruby file at lines 150, 243 and 254 (copy/pasting the lines as suggested), renamed my ESRI files to Buildings.sth AND copied them to both Documents and Documents/tmp directories. Now after restarting Sketchup and retrying the import, I don’t even get the first dialog box upon selecting my .shp file. Instead I get:

Error: #<Errno::ENOENT: No such file or directory - /tmp/Buildings.shx>
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:285:in `initialize'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:285:in `open'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:285:in `spirix_shapefile_import_get_data'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:136:in `spirix_shapefile_import_get_input'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:107:in `spirix_shapefile_import'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:314

Then to be sure, I also applied John’s fix at line 126 as well, but still no luck.
So what am I doing wrong?

I would really appreciate some help. Thanks!
Cheers

These sort of issues is why this plugin is still in Beta :wink:

Since you don’t seem to mind editing the code, try starting with a fresh copy of the newest code (available here) and change the following lines to explicitly reference the three files needed:

Change line 157 from:

file = @@basename + ‘.dbf’

to:

file = ‘/tmp/building.dbf’

Change line 284 from:

file = @@basename + ‘.shx’

to:

file = ‘/tmp/building.shx’

change line 296 from:

file = @@basename + ‘.shp’

to:

file = ‘/tmp/building.shp’

another approach is to ‘hardcode’ the exact path…

one way to get the exact path is to open ‘Ruby Console’ in SU and drag the file from Finder into the bottom input field…

when you release the file it will give the full path…

copy it and paste it into jim’s rb file between a pair of double quotes

i.e. file = "/pasted/path/etc"

john

Great, thank you both for the quick reply!
So I downloaded Jim’s new file and went for the ‘hardcode’ way (I like that expression)
It does feel a little funny to browse for a file that’s already predetermined in the code…
Anyway here’s the error I now get upon selecting the shapefile:

Error: #<NameError: undefined local variable or method `“' for Spirix::ShapefilePolygonImporter:Module>
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:284:in `spirix_shapefile_import_get_data'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:136:in `spirix_shapefile_import_get_input'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:107:in `spirix_shapefile_import'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:314

In case it’s useful, here is the custom code I frankensteined: spirix_shapefile_importer.rb (14.2 KB)

Any further thoughts?

turn off “smart quotes” and that error should go away…

highlight >> right click should give that option…

there are post’s on that somewhere…

john

Surround the path/filename with single quote marks (').

spirix_shapefile_importer.rb (14.2 KB)

Nice, we’re making progress. Now it gets to the first dialog box again.
But if the Database option is set to yes, it gives the following error:

/Users/Dries/Documents/SHP2SKP/Buildings
Error: #<NoMethodError: undefined method `unpack' for nil:NilClass>
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:175:in `spirix_shapefile_import_get_database'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:150:in `spirix_shapefile_import_get_input'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:107:in `spirix_shapefile_import'
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/spirix_shapefile_importer.rb:314

spirix_shapefile_importer.rb (14.2 KB)
Thanks for the precious help!
Rx