I have a simple graph network on which I applied default Street_Modern_Standard.cga rule:
1) When I export this network as a graph object (line/centerline shapefile):
I lose attributes that are applied in cga rule:
And only the Object Attributes and Segment parameters are written:
2) However, when I export this graph as a shape (area shapefile):
all the cga rule attributes are written as shapefile attributes - but this exports roads footprints (areas) instead of lines (centerlines) which I want (for traffic navigation) as shown on the following image:
Why the .cga rule attributes don't get written when I export the graph as graph object (1st option)?
Is there any way how to export these .cga attributes as a line (centerline) using the 1st option or is it just a bug?
This is expected behavior. When exporting the graph network, only the nodes and edges of the graph are exported. Then, shapes for the streets, sidewalks, crossings, roundabouts, etc are generated dynamically from this graph. Rules are applied to shapes (and not graphs), so when a rule is applied to a street shape, the rule attributes are associated with the street shape. That's why exporting the street shapes gives you the rule attributes. Rules and rule attributes do not belong to graphs, so that's why they are not exported.
If you just want to export (File -> Export) for use in another CityEngine scene, you can export to a scene file (.cej), and this preserves the rule attributes. You'll have your graph network with dynamically generated shapes with the desired rule attribute values.
thanks for answer but is it possible to extract these .cga attributes somehow and save them into the centerline shapefile? (for example using python)
It will help me a lot with the traffic navigation - for example I specify in .cga rule attribute that a certain lane can only go straight (causing that this road segment will have texture with straight lines) and this information gets copied from .cga rule attribute also to object attribute somehow (maybe using python? - ce.setAttribute() ) from where it can be easily exported with lane shapefile
so this line shapefile will contain an information in its shapefile attribute that this lane can only go straight so it can be used for traffic to behave accordingly
is this possible?
It is possible to use python to write user set CGA rule attributes to the street segments. The street network can than be written to FGDB.
But you have to consider that the CGA rules are applied on the dynamic shapes. CityEngine creates these from street segments and street nodes. This is a 1:n relationship, since e.g. one street segment has a shape with "Street" as startrule and two shapes with "Sidewalk". So, if the left and the right sidewalk have different rule attributes, there will be a conflict.
For simplicity I just used the street shape in the example below:
from scripting import * import os # get a CityEngine instance ce = CE() def writeUserAttrToObject(shape,object): for ruleAttributeName in ce.getAttributeList(shape): print str(ce.getAttributeSource(shape, ruleAttributeName)) + ": " + \ ruleAttributeName + " = " + str(ce.getAttribute(shape, ruleAttributeName)) if str(ce.getAttributeSource(shape, ruleAttributeName)) == "USER": objAttributeName = os.path.split(ruleAttributeName) ruleAttributeValue = ce.getAttribute(shape, ruleAttributeName) setObjectAttribute(object,objAttributeName,ruleAttributeValue) ce.setAttributeSource(object, ruleAttributeName, 'OBJECT') def setObjectAttribute(object,attribute,value): if type(value) is int: ce.setAttribute(object, attribute, bool(value)) elif type(value) is float: ce.setAttribute(object, attribute, value) else: ce.setAttribute(object, attribute, str(value)) def writeFGDB(graph,file): exportSettings = FGDBExportGraphSettings() exportSettings.setFilename(file) ce.export(graph, exportSettings) if __name__ == '__main__': # prepare export of streetnetwork for graphSegment in ce.getObjectsFrom(ce.selection,ce.isGraphSegment): # graphSegment to streetShape is 1:n, ':0' is street streetShape = ce.findByOID(ce.getOID(graphSegment)+':0') writeUserAttrToObject(streetShape,graphSegment) # path of the output file file = ce.toFSPath("data/Complete_Street.gdb") writeFGDB(ce.selection(),file)