How to create a graph using python in CityEngine?

878
2
Jump to solution
11-03-2016 05:57 PM
RobertYu
New Contributor III

Hello,

I would like to create a graph (street) using the python interface.  I have this:

graphlayer = ce.addGraphLayer('streets')

vertices = [100,0,100, 1000,0,100, 1000,0,500, 100,0,500, 100,0,100]

graph = ce.createGraphSegments(graphlayer, vertices)

But the resulting graph is not "closed".  I have set the last vertex to be the same as the first, but that did not work.

I would like to also create the "Block" and the "Lots" automatically, as if I were using the GUI.

Thanks,

Robert

0 Kudos
1 Solution

Accepted Solutions
RobertYu
New Contributor III

It looks like running "cleanupGraph" does the trick.  Or is there a better way?

View solution in original post

2 Replies
RobertYu
New Contributor III

It looks like running "cleanupGraph" does the trick.  Or is there a better way?

ThomasFuchs
Esri Regular Contributor

In this case the "cleanupGraph" step is needed.

graphlayer = ce.addGraphLayer('streets')
vertices = [100,0,100, 1000,0,100, 1000,0,500, 100,0,500, 100,0,100]
graph = ce.createGraphSegments(graphlayer, vertices)

cleanupSettings = CleanupGraphSettings()
cleanupSettings.setIntersectSegments(True)
cleanupSettings.setMergeNodes(True)
cleanupSettings.setMergingDist(10)
cleanupSettings.setSnapNodesToSegments(True)
cleanupSettings.setSnappingDist(10)
cleanupSettings.setResolveConflictShapes(True)
ce.cleanupGraph(graphlayer, cleanupSettings)
0 Kudos