Scale down whole scene keeping street width in proportion

10-14-2017 07:33 AM
Occasional Contributor

Hi all. 

Question: I created a street network by hand replicating an old map of a medieval town, some streets are wide other are very narrow. Then I grew secondary streets on it to add complexity. 

I now figured out I made the whole things way too big, because when I try to create shapes for lots on a real scale City Engine crashes. I guess it's too many geometries for my computer. City is supposed to be 20 miles long and 6.5 wide but I don't think this size is handable so I thought about reducing the overall size by half. 

Is there a way to scale down the whole street network keeping the streets in proportion? So that the street width and sidewalk width are scaled down too? 

Or maybe I'm doing something wrong and a 20 Miles * 6.5 should be doable..

Any advice is welcome  


0 Kudos
3 Replies
Esri Regular Contributor

hi Abele Giandoso

The area of your city 20 Miles * 6.5 should be doable. But since area is quite big, there might be too many polygons inside. Then you need to partition your scene into multiple scenes.

However, if you have modeled your City in the wrong scale, you can use the following python script to adjust the size of the street network:

from scripting import *

# get a CityEngine instance
ce = CE()

def scaleAttr(segments, attrList, scaleFactor):
    for s in segments:
        for a in attrList:
            value = ce.getAttribute(s, a)
            ce.setAttribute(s, a, value * scaleFactor)

if __name__ == '__main__':
    scaleFactor = 1/2
    scaleAttributes = ['/ce/street/laneWidth', '/ce/street/sidewalkWidthLeft', \
                       '/ce/street/sidewalkWidthRight', '/ce/street/streetOffset', \
    segments = ce.getObjectsFrom(ce.scene, ce.isGraphSegment)
    ce.scale(segments, [scaleFactor, 0, scaleFactor])
    scaleAttr(segments, scaleAttributes, scaleFactor)
Occasional Contributor

FANTASTIC! Thank you so much  this is really useful!!!

0 Kudos
Occasional Contributor

Hi Thomas

First of all thanks again for giving me the script back in October!.

I had to take a break from the project until now but finally I arrived to the point where I can implement the script you gave me.

Right now I select my script network and then I run the script you gave me (which I saved as .py using the create Pyton Module) pressing F9.

But instead o scaling by half the street width, the whole street networks get all jumbled up in a knot.

Before and after the script

It s the first pyton I run so I am definitively doing something wrong. Any help you may give on the subject would be greatly appreciated



0 Kudos