Hi @hoya ,
I had issues trying to load your data. One of the SHP files did not load. In any case, I've simplified the code to load any SHP file from the designated data folder.
See if it work on your machine. Here's the updated script:
'''
Created on Dec 13, 2022
@author: Plfontes
'''
from scripting import *
# get a CityEngine instance
ce = CE()
fileLocation = "data/" # where the SHP file are locate on your CE project folders
# import the SHP files into the scene
def importSHPStack():
shpFiles = ce.getObjectsFrom(fileLocation, ce.isFile)
shpFilesFiltered = list(filter(lambda x: x.endswith('shp'), shpFiles))
for shpFile in shpFilesFiltered:
settings = SHPImportSettings()
ce.importFile(ce.toFSPath(shpFile), settings)
# run the union shape command
def unionShapes():
objects = ce.getObjectsFrom(ce.scene, ce.isShape)
for o in objects:
shape = ce.unionShapes(objects)
def deleteEmptyShapeLayers():
shapeLayers = ce.getObjectsFrom(ce.scene, ce.isShapeLayer)
for s in shapeLayers:
if len(ce.getObjectsFrom(s, ce.isShape)) == 0:
ce.delete(s)
if __name__ == '__main__':
importSHPStack()
unionShapes()
deleteEmptyShapeLayers()
Cheers,