Problem with shapefile export (Ghshp) - KeyNotFoundException - Python

Hello!

I’m trying to export some geometry with attributes to a shapefile. The plugin used is the Ghshp (https://www.food4rhino.com/app/ghshp). Unfortunately, it appears this error:

Runtime error (KeyNotFoundException): KeyError

Traceback:
line 238, in write_many, “< string >”
line 253, in script

I can’t tell what is wrong. Anyone to help? The GH file is attached.

Thank you in advance,
Kevin

exporting shp problem.gh (148.3 KB)

Judging from the code, the error seems to be produced by a missing or corrupt shp file. You have to provide an absolute/full filepath to the path input. Instead of using metahopper, why don’t you just use a standard Path (File Path) component to set your path?

1 Like

It still doesn’t work. The sollution that I found was to use another component, BearGIS

The export component works well, even it exports all data in string format. But it’s good enough.

Anyway, thanks!!

Hi Kevin, any chance you could share your procedure of exporting a .shp? I’ve tried both Ghshp and BearGIS and failed miserably. The same error pops up for me with Ghshp and BearGIS fails to collect data. I’m hoping to be able to manipulate a shapefile within Rhino and export it to .shp for further GIS analysis. Importing isn’t an issue, but exporting seems impossible.

Of course, Sara. By the way, I made it to work with ghshp component, that’s great because the shapefile structure works better.

Here is a gh file showing an export: example of ghshp shp export.gh (2.9 MB)

The main work is to get the tree paths’ structure right.

Hope it helps.

1 Like

Thank you so much, Kevin. I ended up using BearGIS, as I just couldn’t get ghshp to export properly, but your tip about tree structures and your .gh file were extremely helpful so once again, thank you! I’ll post my procedure below, in case anyone stumbles upon the same issue in the future.
shp_exporting.gh (403.9 KB)

1 Like

Hello from 2021.

Do you have some idea about exporting 3D volume as .shp file? @saraska @kevin.carvalho1
I have studied your files but I still don’t understand the needed format.
Rhino_Shp_Rhino6.gh (209.4 KB)

Hello, @c.zou

I’ve came back here because I had to deal with the same problem again. So sorry for the very late response. But, for the future: I had success inputing the shape_type with a Data component, as the following image:

It’s just a Data component with the 15 number in it, for polygons. It’s working well in another GIS softwares.

image

Hope it can help you or another someday.

Hello everyone
I’m trying to export some geometries with attributes to a shp file, GhShp is being used. I followed the instruction but I experienced an Error! I tested the gh example file uploaded by @kevin.carvalho1
but in my case I can’t solve it.

Hey Kevin,
Happy New Yeah :laughing:

Thanks for your answer. I’ve also found another solution with a plugin @IT
It lists the parameters of the SHP file and allows you to choose which parameter you need. Building height, building type, etc.

@kevin.carvalho1
Hi every one,
I used @kevin.carvalho1’s gh file, but I received such error:
"
Runtime error (PythonException): Either the target filepath, or any of shp, shx, or dbf must be set to create a shapefile.

Traceback:
line 1364, in init, “C:\Users\Amirreza\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts\shapefile.py”
line 173, in write_shapefile, “”
line 239, in write_many, “”
line 253, in script
"