Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data import scripting #816

Open
Spfeil2 opened this issue Sep 25, 2023 · 2 comments
Open

data import scripting #816

Spfeil2 opened this issue Sep 25, 2023 · 2 comments

Comments

@Spfeil2
Copy link

Spfeil2 commented Sep 25, 2023

Blender and OS versions

Blender 3.2.1 Windows 10

Describe the bug

Is it possible to perform data import (.shp with BlenderGIS) through the scripting interface?

How to Reproduce

I'm working on a project in which I automate the conversion of building footprints and floor plans (shapefiles) into 3D building models using Blender. Currently, I import the shapefiles manually, but I also want to automate this step.
Thank you in advance!

Error message

@SerLinkzero
Copy link

SerLinkzero commented Oct 7, 2023

I actually ran into a similar need of batch-importing rasters a few days ago. I found a solution from issue #754

Likewise, you can simply call the bpy.ops.importgis.shapefile operator from your script, just like this:

import bpy

shp_files = [#List of shp file paths]
for path in shp_files:
    bpy.ops.importgis.shapefile(filepath=path)

Note that you need to use keyword arguments (i.e. filepath= is mandatory). The filepath parameter is the minimal requirement to import a shapefile. You could use the below parameters as needed:

filepath="",            # Shapefile path.
shpCRS="",              # CRS of the shapefile.
elevSource="GEOM",      # Determine the source of elevation. Can be None, "GEOM", "OBJ", "FIELD"
objElevName="",         # If elevSource == "OBJ", the object name used for elevation.
fieldElevName="",       # If elevSource == "FIELD", the attribute field to determine elevation.
fieldExtrudeName="",    # The field name of the attribute used to extrude the faces. Leave blank if extrusion is not needed.
fieldObjName="",        # If separateObjects == True, the attribute field to name the generated objects.
extrusionAxis='Z',      # Extrusion direction. Can be "NORMAL", "Z"
separateObjects=False   # Import features as separate objects.

@Spfeil2
Copy link
Author

Spfeil2 commented Oct 16, 2023

perfect, this is what I was looking for. Thank you very much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants