Hi,
I want to create a Dynamo script importing shapefiles into a Revit model.
Something similar was done in 2016, see the following link: Import Shapefiles with DynamoGIS – landarchBIM
Unfortanetely in Revit 2024 or 2025 the package “GIS” isn’t available anymore. Does anyone of you has an idea of a similar package which would help me with this script (especially the import of a shapefile)?
I know that “GIS2BIM” also reads and creates from GIS Data, but I need the workflow for existing shapefiles which were created by scans.
Thank you!
The package Elk works for bringing in GIS data in 2024 without issue, likely 2025 as well. Not sure if it works with shape files though.
The shapefile format is also very well documented here, so you could implement your own method.
And if you’re not feeling up to that, you could also look into Python based solutions. The .dyns here look fairly promising towards that end, but you may have to add the shapefile library to your Python instance: Dynamo/Shapefile to Dynamo at master · jonszcz/Dynamo · GitHub
Hi,
alternatively, maybe you can use the python geopandas library
example code
there may be a units problem to fix
import sys
import clr
clr.AddReference('ProtoGeometry')
import Autodesk.DesignScript.Geometry as DS
from Autodesk.DesignScript.Geometry import *
import sysconfig
sys.path.append(sysconfig.get_path("platstdlib"))
sys.path.append(sysconfig.get_path("platlib"))
import pandas as pd
import geopandas
import shapely
def geometry_to_polycurve(row):
global errors
lst_polyCurves = []
lst_geometry = row['geometry'].geoms if hasattr(row['geometry'], "geoms") else [row['geometry']]
for shape in lst_geometry:
try:
coords = shapely.get_coordinates(shape)
#print(coords)
ds_coords = [DS.Point.ByCoordinates(x, y) for x, y in coords]
ds_coords = Point.PruneDuplicates(ds_coords)
if len(ds_coords) > 0:
ds_poly = DS.PolyCurve.ByPoints(ds_coords)
lst_polyCurves.append(ds_poly)
except Exception as ex:
errors.append(ex)
return lst_polyCurves
file = IN[0]
gdf = geopandas.read_file(file)
centroid = gdf.dissolve().centroid
errors = []
# add an column to store dynamo geometry
gdf['PolyCurve'] = gdf.apply(geometry_to_polycurve, axis=1)
OUT = gdf['PolyCurve'].values.tolist()
2 Likes