Hello, do you know if it is possible to extract the georeferenced territorial limits of a country to import them into AutoCAD as polylines using VBA?
Solved! Go to Solution.
Hello, do you know if it is possible to extract the georeferenced territorial limits of a country to import them into AutoCAD as polylines using VBA?
Solved! Go to Solution.
Solved by daniel_cadext. Go to Solution.
If you can use Python, you may be be able to find something with geopandas
from pyrx_imp import Rx, Ge, Gi, Db, Ap, Ed
import traceback
import geopandas
def PyRxCmd_doit():
try:
db = Db.curDb()
model = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite)
gdf = geopandas.read_file("E:/110m_cultural/ne_110m_admin_0_countries.shp")
#do MultiPolygon first
gdf0 = gdf.loc[gdf.geometry.geometry.type=='MultiPolygon']
for mp in list(gdf0.geometry):
for p in mp.geoms:
pline = Db.Polyline(list(p.exterior.coords))
pline.setColorIndex(1)
pline.setClosed(True)
model.appendAcDbEntity(pline)
gdf1 = gdf.loc[gdf.geometry.geometry.type=='Polygon']
for p in gdf1.geometry:
pline = Db.Polyline(list(p.exterior.coords))
pline.setColorIndex(2)
pline.setClosed(True)
model.appendAcDbEntity(pline)
except Exception as err:
traceback.print_exception(err)
If you can use Python, you may be be able to find something with geopandas
from pyrx_imp import Rx, Ge, Gi, Db, Ap, Ed
import traceback
import geopandas
def PyRxCmd_doit():
try:
db = Db.curDb()
model = Db.BlockTableRecord(db.modelSpaceId(), Db.OpenMode.kForWrite)
gdf = geopandas.read_file("E:/110m_cultural/ne_110m_admin_0_countries.shp")
#do MultiPolygon first
gdf0 = gdf.loc[gdf.geometry.geometry.type=='MultiPolygon']
for mp in list(gdf0.geometry):
for p in mp.geoms:
pline = Db.Polyline(list(p.exterior.coords))
pline.setColorIndex(1)
pline.setClosed(True)
model.appendAcDbEntity(pline)
gdf1 = gdf.loc[gdf.geometry.geometry.type=='Polygon']
for p in gdf1.geometry:
pline = Db.Polyline(list(p.exterior.coords))
pline.setColorIndex(2)
pline.setClosed(True)
model.appendAcDbEntity(pline)
except Exception as err:
traceback.print_exception(err)
Thank you, @daniel_cadext
Thank you, @daniel_cadext
Can't find what you're looking for? Ask the community or share your knowledge.