Lot --> setback(0.1) {streetSide: nil | remainder : test(comp.index)} test(compIndex) --> case streetWidth(0) > 0 && streetWidth(1) > 0 : building case streetWidth(0) > 0 && streetWidth(2) > 0 : building case streetWidth(0) > 0 && streetWidth(3) > 0 : building case streetWidth(1) > 0 && streetWidth(1) > 0 : building case streetWidth(1) > 0 && streetWidth(2) > 0 : building case streetWidth(1) > 0 && streetWidth(3) > 0 : building case streetWidth(2) > 0 && streetWidth(1) > 0 : building case streetWidth(2) > 0 && streetWidth(2) > 0 : building case streetWidth(2) > 0 && streetWidth(3) > 0 : building case streetWidth(3) > 0 && streetWidth(1) > 0 : building case streetWidth(3) > 0 && streetWidth(2) > 0 : building case streetWidth(3) > 0 && streetWidth(3) > 0 : building else : nil building--> offset(-2, inside) extrude(rand(3,15))
attr streetWidth(i) = 0 LotInner --> NIL Lot --> CornerRecursion(geometry.nVertices - 1, 0) CornerRecursion ( edgeID, nStreetEdges ) --> case edgeID >= 0 : case streetWidth(edgeID) > 0 : #print (edgeID) CornerRecursion ( edgeID - 1, nStreetEdges + 1 ) else: #print (edgeID) CornerRecursion ( edgeID - 1, nStreetEdges ) else: case nStreetEdges >= 2 : IsCornerLot else: IsNotCornerLot IsCornerLot --> color("#ff0000") IsNotCornerLot --> color("#00ff00")
Hi! I know a lot of time has passed since this original thread was created, but I'm really struggling with the solution above. The solution is completely logical, and I can follow what the code is intending to do just fine. The only problem is...the streetWidths returned on any lot I run the code on just return 0! I'm missing something, but I'm not sure what. The streetwidth values are there in the Object Attributes in the Inspector when I select the lot, so why isn't the code returning them?!
Can anyone out there help, because this is driving me crazy!!
The rule works for me if I apply it to dynamic lot shapes generated inside street blocks. Can you be more specific about the problem? Do you see the streetWidth attr as a rule attribute in the Inspector? Does rule attribute's value match the value of the object attribute streetWidth? What is the exact code that returns 0? What prints if you insert print(streetWidth(0)) as the first line of the Lot rule? What is your input shape?
Note that the rule only counts whether the lot has two or more edges that border a street. This means that it won't work in some cases such as when a lot borders streets on two opposite sides but isn't a corner lot.
Hmm...I am revisiting this now and, inexplicably, the streetWidth attributes are now being picked up. I'm not sure whether it is a system reboot, the update to CityEngine 2019 I performed or (let's be honest) some kind of user error, but at least the attributes are now coming through.
Ultimately, it doesn't look as though it's going to be of use to me, as the streets in my scene can be quite curvy, so any corresponding lot incorrectly gets picked up as a corner lot (as shown below)
Thank so much for your help though!