I'd like to automate the following process in the GUI:
Select -> Select Objects By Map Layer -> Obstacle:obstacle
In my scene I have lots that are being generated over a river, despite the obstacle map being correctly applied (because certain roads that are going across the river, in the imported OSM data I'm using, cause CE to think that these are valid spots for lot creation). It's pretty easy in the GUI to select these lots and then set their shapeCreation attribute to off, but I'm trying to automate this process.
Seems like there should be a "setSelectionByMapLayer()" command 🙂
0] make an empty list for the stuff to select later on 1] Get all shapes in the layer 2] loop over all shapes 3] for each shape : 4] get the attribute value you have set up to select the shape via the GUI ( the boolean ) 5] if attr == True : selectionList.append(shape) 6] after loop : select your list content.
I ended up using a somewhat different implementation but you helped get me going on the right track:
def SelectAllBlocksInObstacleMap(): ''' turn off blocks if vertices are in obstacle map defined areas ''' Obstacle = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Obstacle'")) allBlocks = ce.getObjectsFrom(ce.scene, ce.isBlock) for o in allBlocks: verts = ce.getVertices(o) if verts: x = verts z = verts sampleSpot = ce.sampleBooleanLayerAttribute(Obstacle, "obstacle", x, z) if sampleSpot: ce.setAttribute(o, '/ce/block/shapeCreation', False)
as you can see, what I was missing was knowing to use the sampleBooleanLayerAttribute command, so once I figured that out, I was able to proceed- although your implementation seems a bit cleaner, so I might give that a try as well. 🙂