The interface for scripting the CityEngine.
Methods defined here:
addAnalysisLayer
addAnalysisLayer(self, name):
Add a layer that can contain analysis objects.
@param name: The name to give the new layer. [str]
@return: The new analysis layer.
@example:
# create a new analyis layer in the current scene.
ce.addAnalysisLayer('My Analysis Layer')
addAttributeLayer
addAttributeLayer(self, name, texture = None, heightmap = None, useGeoRef = False):
Adds a new attribute layer to the current CityEngine scene.
@param name: The name of the new attribute layer. [str]
@param texture: The texture to be used for the layer or null if no texture. (default = None). [str]
@param heightmap: The height to be used for the layer or null if no heightmap. (default = None). [str]
@param useGeoRef: If true, and the texture or heightmap contains georeference information, the layer will be positioned using the georeference data. If both contain georeference information the heightmap wins. (default = False). [True/False]
@return: The added layer.
@example:
# add a new attribute Layer with name 'new attribute layer', and no texture
l = ce.addAttributeLayer('newAttributeLayer')
# add a new terrain attribute Layer with name 'Terrain',
# and the files map.png and elevation.png for texture and heightmap using georeferenced position
l = ce.addAttributeLayer('Terrain', "maps/map.png", "maps/elevation.png", True)
# and set the layer attributes to define an elevation
ce.setLayerAttributes(l, "attr elevation = map_01(brightness, 0.0, 100.0)")
addGraphLayer
addGraphLayer(self, name):
Adds a new graph layer to the current CityEngine scene.
@param name: The name of the new graph layer. [str]
@return: The added layer.
@example:
# add a new shape Layer with name 'new graph layer'
ce.addGraphLayer('new graph layer')
addScenario
addScenario(self, scenarioName, scenarioId):
Adds a scenario with the given name and id.
@param scenarioName: Name of the new scenario. [str]
@param scenarioId: Id of the new scenario (max 4 characters, will be truncated if longer). [str]
@return: Returns the id (max 4 characters) of the new scenario, or None if the operation failed. [str]
@example:
scenarioId = '4'
scenarioName = 'Scenario 4'
ce.addScenario(scenarioName,scenarioId)
addScriptMenuItems
addScriptMenuItems(self, scriptPath):
Adds one or more scripts to the script menu.
@param scriptPath: Absolute filesystem path to the script. [sequence of str]
@return: True if all scripts have been successfully added, false otherwise. [True/False]
@example:
# Scripts can be used from inside or outside the workspace
# Add the script located at path to the menu
print ce.addScriptMenuItems([path])
addShapeLayer
addShapeLayer(self, name):
Adds a new shape layer to the current CityEngine scene.
@param name: The name of the new shape layer. [str]
@return: The added layer.
@example:
# add a new shape Layer with name 'new shape layer'
ce.addShapeLayer('new shape layer')
addStaticModelLayer
addStaticModelLayer(self, name):
Adds a new static model layer to the current CityEngine scene.
@param name: The name of the new static model layer. [str]
@return: The added layer.
@example:
# add a new static model layer name 'Landmarks',
l = ce.addStaticModelLayer('Landmarks')
alignGraph
alignGraph(self, graph, settings = None):
Align graph network.
@param graph: The set of graph objects to align.
@param settings: The align settings. Omit to use default settings. (default = None).
@example:
#align the graph layer 'streets' to the 'Heightmap' layer
graph = ce.getObjectsFrom(ce.scene, ce.withName('streets'))
settings = AlignGraphSettings()
settings.setHeightmap('Heightmap')
ce.alignGraph(graph, settings)
alignShapes
alignShapes(self, shapes, settings = None):
Aligns a set of shapes.
@param shapes: The set of shapes to align.
@param settings: The align settings. Omit to use default settings. (default = None).
@example:
# align shapes of layer 'Lots' to layer 'Heightmap'
lotLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Lots'"))
settings = AlignShapesSettings()
settings.setHeightmap('Heightmap')
settings.setAlignFunction(AlignShapesSettings.TRANSLATE_TO_MIN)
ce.alignShapes(lotLayer, settings)
alignStaticModels
alignStaticModels(self, models, settings = None):
Aligns a set of static models.
@param models: The set of static models to align.
@param settings: The align settings. Omit to use default settings. (default = None).
@example:
# align static models in layer 'Landmarks' to layer 'Heightmap'
staticModelLayer = ce.getObjectsFrom(ce.scene, ce.isStaticModelLayer, ce.withName("'Landmarks'"))
settings = AlignStaticModelsSettings()
settings.setHeightmap('Heightmap')
ce.alignStaticModels(staticModelLayer, settings)
alignTerrain
alignTerrain(self, shapes = None, settings = None):
Aligns the terrain to the specified shapes.
@param shapes: The shapes to align the terrain to (default = None).
@param settings: (Optional) The AlignTerrainSettings to apply. Omit to use default values. (default = None).
@example:
# Aligns the terrain to the given shapes to apply to
ce.alignTerrain( ce.getObjectsFrom(ce.scene, ce.isShape) )
analyzeGraph
analyzeGraph(self, layer, settings = None):
Runs the analyze graph tool.
@param layer: A graph layer or street segments to analyze .
@param settings: The analyze graph settings. Omit to use default settings. (default = None).
@example:
# analyze the connectivity of the given segments or graph layers
graph = ce.getObjectsFrom(ce.scene, ce.isGraphLayer)
ce.analyzeGraph(graph)
cleanupGraph
cleanupGraph(self, graph, settings = None):
Cleanup graph networks (intersect segments and merge nodes).
@param graph: The initial set of street graph objects to clean.
@param settings: The cleanup settings. Omit to use default settings. (default = None).
@example:
# cleanup alls graph layers in scene
cleanupSettings = CleanupGraphSettings()
cleanupSettings.setIntersectSegments(True)
cleanupSettings.setMergeNodes(True)
cleanupSettings.setMergingDist(10)
cleanupSettings.setSnapNodesToSegments(True)
cleanupSettings.setSnappingDist(10)
cleanupSettings.setResolveConflictShapes(True)
graphlayer = ce.getObjectsFrom(ce.scene, ce.isGraphLayer)
ce.cleanupGraph(graphlayer, cleanupSettings)
cleanupShapes
cleanupShapes(self, shapes, settings = None):
Applies the cleanup shape tool to given shape(s).
@param shapes: The set of shapes to cleanup.
@param settings: The cleanup settings. Omit to use default settings. (default = None).
@example:
# Tidies the geometry of the given shape(s)
shape = ce.getObjectsFrom(ce.scene, ce.withName("'newShape'"))
ce.cleanupShapes(shape)
closeFile
closeFile(self, workspacePath = None):
Closes the currently open CityEngine scene or given workspace file.
@param workspacePath: Workspace path of the file to close or null to close current scene. (default = None). [str]
@example:
# close the scene newcity.cej
ce.closeFile('scenes/newcity.cej')
combineShapes
combineShapes(self, shapes):
Combines all the selected shapes into a single shape.
@param shapes: The set of shapes to combine.
@return: result.
@example:
# Combine the given lot shapes into a single shape
combinedShape = ce.combineShapes( [ ce.findByOID("90dd0000-0030-1bbc-4fe5-86e1dfcd11b4"),ce.findByOID("90dd0000-0030-1bbc-4fe4-0d46dfcd11b4") ] )
computeEdgeAttributes
computeEdgeAttributes(self, shapes, settings = None):
Compute edge attributes for a set of shapes from nearby (visible) shapes or streets.
@param shapes: A collection of shapes to compute the edge attributes for.
@param settings: The compute edge attributes settings. Omit to use default settings. (default = None).
@example:
# Compute edge infos with default settings for shape 'Block 1'
shapes = ce.getObjectsFrom(ce.scene, ce.isShape, ce.withName("'Block 1'"))
ce.computeEdgeAttributes(shapes)
computeFirstStreetEdges
computeFirstStreetEdges(self, shapes):
Sets the first edge and street edges of a set of shapes from nearby roads.
@param shapes: The set of shapes to find first and street edges for, and the streets edges to fit to.
@example:
# set first edge of static shape, and assign street edge attributes. If no shapes are selected, all visible shapes are used. If no street segments are selected, all visible segments are used.
shapes = ce.getObjectsFrom(ce.scene, ce.isShape, ce.withName("'Block 1'"))
ce.computeFirstStreetEdges(shapes)
convertModelsToShapes
convertModelsToShapes(self, models):
Convert models to shapes.
@param models: The models to convert.
@return: The created shapes.
@example:
#convert models to static shapes
models = ce.selection()
shapes = ce.convertModelsToShapes(models)
print "new shape converted from model: "+ce.getName(shapes[0])
convertToStaticShapes
convertToStaticShapes(self, objects):
Creates a static shape from the selected dynamic shapes.
@param objects: A collection of dynamic shapes or graph layers to convert to static shapes.
@return: The created mesh layer.
@example:
# convert dynamic shapes to static shapes
shapes = ce.getObjectsFrom(ce.scene, ce.isShape)
staticShapesLayer = ce.convertToStaticShapes(shapes)
copy
copy(self, toCopy, delete = False, layer = None):
Copy the selected objects. Can also be used to move the objects to a new layer.
@param toCopy: The objects to copy.
@param delete: If true the original objects are deleted. (default = False). [True/False]
@param layer: The layer to copy the objects to; without this argument objects remain on their existing layers. (default = None).
@return: The new objects. [sequence]
@example:
# Copies selected objects either on the same layer, or between different layers. If the
# requested layer isn't of a compatible type, the objects are copied into the existing layer
result = ce.copy ( ce.getObjectsFrom( graphLayer, ce.isGraphSegment ) )
ce.move (result, [-30, 0, 20]);
#copy the segments to a different layer
graphLayer2 = ce.addGraphLayer('streets_c2')
result = ce.copy ( ce.getObjectsFrom( graphLayer, ce.isGraphSegment ), False, graphLayer2 )
ce.move (result, [-200, 0, 20]);
# copy the entire layer
graphLayer3 = ce.copy (graphLayer2)[0]
ce.setName(graphLayer3, "streets_c3")
ce.move (ce.getObjectsFrom( graphLayer3), [-200, 0, 20]);
# move a segment to a different layer using delete=True
result = ce.copy ( getObjectsFrom(graphLayer3, ce.isGraphSegment)[1], True, graphLayer )
ce.move (result, [370, 0, 0]);
# segments are invalid on a shape layer, so remain on the original layer
shapeLayer = ce.addShapeLayer('streets_shapes')
result = ce.copy ( getObjectsFrom(graphLayer3, ce.isGraphSegment), False, shapeLayer )
ce.move (result, [-60, 0, 20]);
createGraphSegments
createGraphSegments(self, layer, vertices):
Create connected graph segments.
@param layer: The graph layer to add the segments to, or 'None' in order to create a new layer.
@param vertices: An array of (unstructured) floating point values. [sequence of float]
@return: The list of created graph segments. [sequence]
@example:
# create two graph segments on new layer 'streets'
graphlayer = ce.addGraphLayer('streets')
vertices = [400,0,-200,400,0,-280,480,0,-290]
graph = ce.createGraphSegments(graphlayer, vertices)
vertices = [420,0,-220,350,0,-220]
graph = ce.createGraphSegments(graphlayer, vertices)
createShape
createShape(self, layer, vertices):
Create shape.
@param layer: The shape layer to add the shape to, or 'None' in order to create a new layer.
@param vertices: An array of (unstructured) floating point values. [sequence of float]
@return: The created shape.
@example:
# create an shape by specifying a vertex list
vertices = [0,300,0,0,300,200,300,300,200,300,300,0]
shape = ce.createShape(None, vertices)
ce.setName(shape, "my Shape")
createStaticModel
createStaticModel(self, layer, pos, staticModelFile):
Create static model.
@param layer: The static model layer to add the static model to, or 'None' in order to create a new layer.
@param pos: An array of three floating point values. [sequence of float]
@param staticModelFile: The filename of the static model. [str]
@return: The created static model.
@example:
# create a new static model from file antenna_1.obj into layer 'Landmarks' at position [-1000,0,2000]
# staticModelFile must be an absolute workspace path
landmarkLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Landmarks'"))[0]
staticModelFile = "/general/assets/obj/antenna_1.obj"
staticModel = ce.createStaticModel(landmarkLayer, [-1000,0,2000], staticModelFile)
print "staticModel: ", staticModel
createViewCorridor
createViewCorridor(self, observerPoint, POI, layer):
Add a View Corridor to the scene.
@param observerPoint: A double list representing the observer position. [sequence of float]
@param POI: A double list representing the point of interest. [sequence of float]
@param layer: The analysis layer in which the View Corridor should be created.
@return: The new View Corridor object.
@example:
# create a View Corridor object with the observer at (20, 0, 0) and the point of interest (-20, 10, 10).
ce.createViewCorridor([ 20, 0, 0], [-20, 10, 10], None)
createViewDome
createViewDome(self, observerPoint, radius, layer):
Add a View Dome to the scene.
@param observerPoint: A double list representing the observer position. [sequence of float]
@param radius: The radius of the View Dome. [float]
@param layer: The analysis layer in which the View Dome should be created.
@return: The new View Dome object.
@example:
# create a View Dome object with the observer at (20, 30, 10) and the radius 20.
ce.createViewDome([ 20, 30, 10], 20, None)
createViewshed
createViewshed(self, observerPoint, poI, layer):
Add a Viewshed to the scene.
@param observerPoint: A double list representing the observer position. [sequence of float]
@param poI: A double list representing the point of interest. [sequence of float]
@param layer: The analysis layer in which the Viewshed should be created.
@return: The new Viewshed object.
@example:
# create a Viewshed object with the observer at (20, 0, 0) and the point of interest (-20, 10, 10).
ce.createViewshed([ 20, 0, 0], [-20, 10, 10], None)
curveAutoSmooth
curveAutoSmooth(self, objects, settings = None):
Runs the curves auto smooth tool.
@param objects: A collection of graph nodes and/or edges .
@param settings: The curves auto smooth settings. Omit to use default settings. (default = None).
@example:
# automatically set curve handles depending on threshold angle
segments = ce.getObjectsFrom(ce.scene, ce.isGraphSegment)
settings = CurveAutoSmoothSettings()
settings.setThresholdAngle(30)
settings.setHorizontalOptimize(True)
ce.curveAutoSmooth(segments, settings)
deleteAttribute
deleteAttribute(self, objects, name):
Deletes the named object attribute.
@param objects: The objects to delete the attribute from.
@param name: The attribute name. [str]
@example:
# delete the attribute height from the currently selected objects
ce.deleteAttribute(ce.selection(), 'height')
delete
delete(self, object = None):
Deletes objects or a workspace file.
@param object: Objects or a file to delete, or null for current selection. (default = None).
@example:
# delete all objects in scene
ce.delete(ce.getObjectsFrom(ce.scene))
exit
exit(self, save = False):
Safely shuts down CityEngine and optionally saves any open scene.
@param save: If true, any open scene will be saved. (default = False). [True/False]
exportRPK
exportRPK(self, settings):
Creates a rule package according to settings.
@param settings: The rule package settings.
@example:
# export a CGA file to a rule package
settings = RPKExportSettings()
settings.setRuleFile("/general/rules/rpkassets_simple.cga")
settings.setFile(ce.toFSPath("/general/data/rpk/rpkassets_simple_01.rpk"))
settings.setAddFilesAutomatically()
ce.exportRPK(settings)
export
export(self, objects, settings, interactive = False):
Export the given objects.
@param objects: The objects to be exported.
@param settings: The export settings.
@param interactive: Run the export interactive (let user finish dialog). (default = False). [True/False]
@example:
# batch generate and export selected shapes as obj with default settings
settings = OBJExportModelSettings()
ce.export(ce.selection(), settings)
findByOID
findByOID(self, oid):
Get an object specified by a specific Object IDentifier
@param oid: The OID string
@return: The objects with the given ID, or null if no such object exists
@example:
# returns the object with given Object Identifier, if any
object = ce.findByOID(oid)
ce.setSelection (object)
fitStreetWidths
fitStreetWidths(self, objects, settings = None):
Runs the fit street widths to shapes tool.
@param objects: A collection of graph nodes and/or edges .
@param settings: The fit widths to shapes settings. Omit to use default settings. (default = None).
@example:
# Settings specify how streets widths are increased to meet static geometry
segments = ce.getObjectsFrom(ce.scene, ce.isGraphSegment)
ce.fitStreetWidths(segments)
segments = ce.getObjectsFrom(ce.scene, ce.isGraphSegment)
# optional use of settings:
settings = FitStreetWidthSettings()
settings.setAdjustStreetOffsets(False)
settings.setMinStreetWidth(1)
settings.setMaxStreetWidth(50)
settings.setAdditionalMargin(1)
settings.setSidewalkScale("DONT")
ce.fitStreetWidths(segments, settings)
generateBridges
generateBridges(self, objects, settings = None):
Runs the generate bridges tool.
@param objects: A collection of graph nodes and/or edges .
@param settings: The generate bridges settings. Omit to use default settings. (default = None).
@example:
# Organise crossing streets vertically so they do not intersect. Takes hints from layer or absolute height attributes
graphlayer = ce.getObjectsFrom(ce.scene, ce.isGraphLayer, ce.withName("Streetnetwork"))[0]
segments = ce.getObjectsFrom(graphlayer, ce.isGraphSegment)
settings = GenerateBridgeSettings()
ce.generateBridges(segments, settings)
generateModels
generateModels(self, shapes, synchronous = True, updateSeed = False):
Generate the models for the selected shapes.
@param shapes: The set of shapes to use for generation.
@param synchronous: If true, the this operation will block until all models are generated. If false, the generation will take place in the background. (default = True). [True/False]
@param updateSeed: If true, the seed will be updated before generation. (default = False). [True/False]
@return: result. [sequence]
@example:
# generate models on selected shapes
ce.generateModels(ce.selection())
# generate models on selected shapes in async mode
ce.generateModels(ce.selection(), False)
get3DViews
get3DViews(self):
Gets the currently open 3D views.
@return: All open 3D views. [sequence]
@example:
# print list of currently opened 3D views
views = ce.get3DViews()
print views
getAnglesOfView
getAnglesOfView(self, object):
Returns the angles of view of the Viewshed or View Corridor object.
@param object: The Viewshed or View Corridor object to query.
@return: The angles of view the Viewshed object. [sequence of float]
@example:
# print the view angles for one of the Viewsheds in the scene.
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
angles = ce.getAnglesOfView(viewshed)
print "Horizontal:", angles[0], "Degrees, Vertical", angles [1], "Degrees"
getAttributeArrayAsDict
getAttributeArrayAsDict(self, object, name):
Get the named object attribute or None if the attribute does not exist. Array attributes are returned as dictionaries (using the array indices as keys).
@deprecated: Only for legacy scripts, use getAttribute instead.
@param object: The object to get the attribute from.
@param name: The attribute name. [str]
@param name: [str]
@return: The object attribute or None if the attribute does not exist.
@example:
# print street parameter 'streetWidth' of shape 'Lot 904 5426' as a dictionary
streetsegment = ce.getObjectsFrom(ce.scene, ce.withName("'Lot 904 5426'"))[0]
print ce.getAttributeArrayAsDict(streetsegment, 'streetWidth')
getAttributeLayerExtents
getAttributeLayerExtents(self, layer):
Returns the X-Z extents of an attribute layer.
@param layer: The attribute layer to get the extents from.
@return: List consisting of four values. [sequence]
@example:
# get position and size of the layer "Terrain"
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Terrain'"))[0]
print ce.getAttributeLayerExtents(l)
getAttributeList
getAttributeList(self, object):
Get a list of object attributes.
@param object: The object get the attribute list from.
@return: A list of object attribute names. [sequence]
@example:
# print a list of all attribute names of the currently selected object
print ce.getAttributeList(ce.selection()[0])
getAttributeSource
getAttributeSource(self, object, name):
Set the attribute source of the given attribute for the given objects.
@param object: The object to get the attribute source from.
@param name: The name of the attribute of which the source will be returned. [str]
@return: result.
@example:
# get source of attribute 'height'
print ce.getAttributeSource(ce.selection()[0], 'height')
getAttribute
getAttribute(self, object, name):
Get the named object attribute or None if the attribute does not exist. Array attributes are returned as lists.
@param object: The object to get the attribute from.
@param name: The attribute name. [str]
@return: The object attribute or None if the attribute does not exist.
@example:
# print value of object attribute 'height' of currently selected object
print ce.getAttribute(ce.selection()[0], 'height')
# print value of user-set rule parameter 'areaName' of currently selected object
print ce.getAttribute(ce.selection()[0], '/ce/rule/areaName')
# print block parameter 'shapeCreation' of block 'BlockSouth_8'
block = ce.getObjectsFrom(ce.scene, ce.withName("'BlockSouth_8'"))[0]
print ce.getAttribute(block, '/ce/block/shapeCreation')
# print street parameter 'streetWidth' of segment 'ShapeFile Segment 3148'
streetsegment = ce.getObjectsFrom(ce.scene, ce.withName("'ShapeFile Segment 3148'"))[0]
print ce.getAttribute(streetsegment, '/ce/street/streetWidth')
# print crossing parameter 'type' of node 'Shapefile Node 4496'
nodes = ce.getObjectsFrom(ce.scene, ce.withName("'Shapefile Node 4496'"))[0]
print ce.getAttribute(nodes, '/ce/crossing/type')
getColorGeometry
getColorGeometry(self, object):
Returns whether the visibility object colors the geometry or not.
@param object: The visibility object to query.
@return: True if the visibility object colors scene geometry. [True/False]
@example:
# print whether the first View Dome colors geometry in the scene.
dome = ce.getObjectsFrom(ce.scene, ce.isViewDome)[0]
print ce.getColorGeometry(dome)
getCurveHandle
getCurveHandle(self, segment, node):
Get the curve handle associated with a street segment.
@param segment: The street segment whose handle will by returned by this command.
@param node: Either the node associated with the start of the street, or the end. This specifies whether this command will return the first or second curve handle.
@return: The vector defining the direction and distance of the curve handle [x, y, z]. [sequence]
@example:
# Gets the location of curve handle at the node's end of the specified segment
graphLayer = ce.getObjectsFrom(ce.scene, ce.isGraphLayer)[0]
segment = ce.getObjectsFrom(graphLayer, ce.isGraphSegment)[0]
node = ce.getObjectsFrom(segment, ce.isGraphNode)[1]
direction = ce.getCurveHandle( segment, node)
getElevationOffset
getElevationOffset(self, layer):
Get the elevation offset of the specified layer.
@param layer: The layer whose elevation offset will be returned.
@return: The elevation offset of the layer. [float]
@example:
# prints the elevation offset of the layer "Terrain"
l = ce.getObjectsFrom(ce.scene, ce.isMapLayer, ce.withName("'Terrain'"))[0]
print ce.getElevationOffset(l)
getLayerAttributes
getLayerAttributes(self, layer):
Returns the attribute code of the specified layer.
@param layer: The layer to get the attributes from.
@return: Layer attributes. [str]
@example:
# print the layer attributes code of the layer "Terrain"
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Terrain'"))[0]
print ce.getLayerAttributes(l)
getLayerPreferences
getLayerPreferences(self, layer, preference):
Returns the specified group or layer preference.
@param layer: The layer or group to get the preference from.
@param preference: "Visible", "Locked", "Show Network", "Show Blocks", "Colored", "Color" . [str]
@return: Layer Preference. [True, False, None, list with 3 numbers].
@example:
# print the visible preference of one layer
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Heightmap'"))[0]
print ce.getLayerPreferences(l,"Visible")
# print the layer color of "Heightmap"
ce.setLayerPreferences(l, "Colored", True)
ce.setLayerPreferences(l, "Color", [0, 0, 1])
print ce.getLayerPreferences(l, "Color") # prints [0, 0, 1]
getLayer
getLayer(self, object):
Get the layer of the specified object.
@param object: The object to get the layer from.
@return: The object's layer or null if the object does not provide a layer.
@example:
# print the name of the layer containing the selected object
print ce.getLayer(ce.selection()[0])
getLighting
getLighting(self):
Returns the current lighting settings.
@return: The current light settings.
@example:
# get current lighting and print all information
lightSettings = ce.getLighting()
print lightSettings
getName
getName(self, object):
Get the name of the specified object (if the object has a name).
@param object: The object to get the name from.
@return: The object's name or null if the object does not provide a name. [str]
@example:
# print name of selected object
print ce.getName(ce.selection()[0])
getObjectsFrom
getObjectsFrom(self, container, *filters):
Get child objects from container with optional filters.
@param container: The parent container.
@param *filters: Optional filter constraints. [sequence of ]
@return: The filtered set of child objects.
@example:
# return list of objects from different containers, using optional filters
# if the argument is a list, it will be filtered given the specified filters.
# if the argument is a single object it will be expanded to adjacent objects, given the specified filters.
# all objects in selection
selectedObjects = ce.getObjectsFrom(ce.selection)
# all shapes in selection
selectedShapes = ce.getObjectsFrom(ce.selection, ce.isShape)
# all objects in the scene
allSceneObjects = ce.getObjectsFrom(ce.scene)
# all shapes in the scene
sceneShapes = ce.getObjectsFrom(ce.scene, ce.isShape)
# shapes with a specific name
myShape = ce.getObjectsFrom(ce.scene, ce.isShape, ce.withName("'my Shape'"))
# all generated models in scene
models = ce.getObjectsFrom(ce.scene, ce.isModel)
# all layers in the scene
layers = ce.getObjectsFrom(ce.scene, ce.isLayer)
# layers with a specific name / type
streetlayer = ce.getObjectsFrom(ce.scene, ce.withName("'Streetnetwork'"))[0]
lotLayers = ce.getObjectsFrom(ce.scene, ce.isShapeLayer, ce.withName("*New*"))
mapLayers = ce.getObjectsFrom(ce.scene, ce.isMapLayer)
# all objects in a layer
streetlayerObjects = ce.getObjectsFrom(streetlayer)
# a block with a specific name
block = ce.getObjectsFrom(ce.scene, ce.isBlock, ce.withName("BlockSouth_21"))[0]
# all files in a specific folder
files = ce.getObjectsFrom("/general/scenes/", ce.isFile)
# using a single object expands the selection
segments = ce.getObjectsFrom(streetlayer, ce.isGraphSegment)
segment = segments[0]
# the two adjacent nodes from a segment
segNodes = ce.getObjectsFrom(segment , ce.isGraphNode)
# the adjacent segments of a node
segments = ce.getObjectsFrom(segNodes[0] , ce.isGraphSegment)
# the 0, 1 or 2 blocks adjacent to a street segment
blocks = ce.getObjectsFrom(segments[0] , ce.isBlock)
# the surrounding street segments from a block
blockSegs = ce.getObjectsFrom(block , ce.isGraphSegment)
# the surrounding street nodes from a block
blockNodes = ce.getObjectsFrom(block , ce.isGraphNode)
# models from shapes
models = ce.getObjectsFrom(ce.scene , ce.isModel)
# the shapes associated with a model
modelShapes = ce.getObjectsFrom(models[0] , ce.isShape)
# lots shapes from a block
lots = ce.getObjectsFrom(block , ce.isShape)
# shapes from a node or segment
nodeShapes = ce.getObjectsFrom(blockNodes[0] , ce.isShape)
# the static model associated with a shape
staticModels= ce.getObjectsFrom(ce.scene , ce.isStaticModel)
# the shape associated with a static model
staticShapes= ce.getObjectsFrom(staticModels[0] , ce.isShape)
getObserverPoint
getObserverPoint(self, object):
Returns the observer position of the visibility object.
@param object: The visibility object to query.
@return: The observer position of the visibility object. [sequence of float]
@example:
# print the observer position of one of the view domes in the scene.
dome = ce.getObjectsFrom(ce.scene, ce.isViewDome)[0]
print ce.getObserverPoint(dome)
getOID
getOID(self, object):
Get the OID (Object IDentifier) of the specified layer or object.
@param object: The layer or layer object to get the OID from.
@return: The object's OID or null if the object is not of required type. [str]
@example:
# returns the unique Object IDentifier string of the given object
oid = ce.getOID( ce.getObjectsFrom( ce.scene, ce.withName("newShape") )[0] )
print oid
getPanorama
getPanorama(self):
Returns the current panorama settings.
@return: PanoramaSettings object containing the current state.
@example:
# get current Panorama settings and print all settings
panoramaSettings = ce.getPanorama()
print panoramaSettings
getParentGroup
getParentGroup(self, object):
get parent Group.
@param object: The Group or Layer .
@return: void.
@example:
# get the parent group of layer "Group Child"
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Group Child'"))[0]
parent = ce.getParentGroup(l)
print parent
getPOI
getPOI(self, object):
Returns the point of interest of the View Corridor object.
@param object: The View Corridor object to query.
@return: The point of interest of the View Corridor object. [sequence of float]
@example:
# print the point of interest of one of the View Corridors in the scene.
corridor = ce.getObjectsFrom(ce.scene, ce.isViewCorridor)[0]
print ce.getPOI(corridor)
getPosition
getPosition(self, objects):
Get the position of the specified objects (calculated as the centroid of all objects' vertices).
@param objects: The objects to get the position from.
@return: An list containing the center [x, y, z]. [sequence]
@example:
# print the absolute position in world coordinates of the selected object
print ce.getPosition(ce.selection()[0])
getRuleFileInfo
getRuleFileInfo(self, path):
Gets information about CGA or CGB rule file.
@param path: The path to the rule file (e.g. from getRuleFile). [str]
@return: The RuleFileInfo of the rule file.
@example:
# print all rule names found in rule file
info = ce.getRuleFileInfo('rules/extrude.cga')
for r in info['rules']:
print r['name']
getRuleFile
getRuleFile(self, shape):
Gets a shape's rule file.
@param shape: The shape to return the rule file from.
@return: result. [str]
@example:
# print rule file of selected shape
print ce.getRuleFile(ce.selection()[0])
getScenarioColor
getScenarioColor(self, scenarioId):
Returns the color of the given scenario.
@param scenarioId: Scenario id. [str]
@return: A String defining the hex value of the scenario color i.e. '#FF0000', or None if the scenario does not exist, (the Default Scenario has no color). [str]
getScenarioIds
getScenarioIds(self):
Lists the ids of all scenarios in the current scene.
@return: Returns an (ordered) list of scenario ids (max 3 characters) in the current scene. [sequence]
@example:
print ce.getScenarioIds()
getScenarioName
getScenarioName(self, scenarioId):
Returns the name of the scenario.
@param scenarioId: The id of the scenario. [str]
@return: The name of the scenario. [str]
@example:
scenarioId = '1'
print ce.getScenarioName(scenarioId)
getScenarios
getScenarios(self, sceneObject):
Lists all (non-default) scenarios where this object takes part.
@param sceneObject: Scene object to list the scenarios of.
@return: List of scenario ids, empty list if only part of default scenario. [sequence]
@example:
objects = ce.getObjectsFrom(ce.scene, ce.withName("'test3'"))
print ce.getScenarios(objects[0])
getSceneCoordSystem
getSceneCoordSystem(self):
Gets the scenes coordinate system.
@return: a string touple containing AUTH:CODE and label. None if not set.
@example:
# get the current scene coordinate system details
(authAndCode, label) = ce.getSceneCoordSystem()
print authAndCode
print label
getSceneHierarchy
getSceneHierarchy(self):
Gets scene hierarchy.
@return: Returns a tree object containing the root group and its children. The tree contains all layers and layer groups but not shapes, networks, blocks, etc.
@example:
# This example browses the tree, locks layers and unlocks layer groups.
# Layers and layer groups are set to visible.
# For layers that are graph layers networks and blocks are shown.
def processSceneElements(rootGroup):
for child in rootGroup.getChildren(None):
if ce.isLayer(child):
ce.setLayerPreferences(child, "Visible", True)
ce.setLayerPreferences(child, "Locked", True)
if ce.isGraphLayer(child):
ce.setLayerPreferences(child, "Show Network", True)
ce.setLayerPreferences(child, "Show Blocks", True)
if ce.isLayerGroup(child):
ce.setLayerPreferences(child, "Visible", True)
ce.setLayerPreferences(child, "Locked", False)
processSceneElements(child)
hierarchyRoot = ce.getSceneHierarchy()
processSceneElements(hierarchyRoot)
getSceneScenario
getSceneScenario(self):
Gets the scenario Id displayed by the scene.
@return: The id of the scenario displayed by the scene. [str]
@example:
print ce.getSceneScenario()
getSeed
getSeed(self, shape):
Gets a shape's seed.
@param shape: The shape to return the seed from.
@return: result.
@example:
# print seed of selected shape
print ce.getSeed(ce.selection()[0])
getStartRule
getStartRule(self, shape):
Gets the Start Rule for the given shape.
@param shape: The shape to return the Start Rule from.
@return: result. [str]
@example:
# print start rule of selected shape
print "Startrule:", ce.getStartRule(ce.selection()[0])
getTerrainMaxHeight
getTerrainMaxHeight(self, layer):
Returns the maximum height of the specified layer.
@param layer: Returns the elevation offset of the specified layer.
@return: The maximum height of the specified layer. [float]
@example:
# prints the maximum elevation of the layer "Terrain"
l = ce.getObjectsFrom(ce.scene, ce.isMapLayer, ce.withName("'Terrain'"))[0]
print ce.getTerrainMaxHeight(l)
getTerrainMinHeight
getTerrainMinHeight(self, layer):
Returns the minimum height of the specified layer.
@param layer: Returns the elevation offset of the specified layer.
@return: The minimum height of the specified layer. [float]
@example:
# prints the minimum elevation of the layer "Terrain"
l = ce.getObjectsFrom(ce.scene, ce.isMapLayer, ce.withName("'Terrain'"))[0]
print ce.getTerrainMinHeight(l)
getTiltAndHeadingAngles
getTiltAndHeadingAngles(self, object):
Returns the tilt and heading angles of the Viewshed object.
@param object: The Viewshed object to query.
@return: The tilt and heading angles of the Viewshed object. [sequence of float]
@example:
# print the tilt and heading for one of the Viewsheds in the scene.
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
angles = ce.getTiltAndHeadingAngles(viewshed)
print "Tilt:", angles[0],"Degrees, Heading", angles [1], "Degrees"
getTotalSolidAngle
getTotalSolidAngle(self, viewshed):
Get the total solid angle covered by the Viewshed.
@param viewshed: The Viewshed . [Analysis]
@return: result. [float]
@example:
# get the Total Solid Angle of the Viewshed
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
totalAngle = ce.getTotalSolidAngle(viewshed)
print "Viewshed 1 Total Solid Angle : ", totalAngle, "steradians"
getVersionBuild
getVersionBuild(self):
Gets VersionBuild field. CityEngine build number.
@return: Value of VersionBuild field. [int]
@example:
#print CityEngine build version
print ce.getVersionBuild()
getVersionMajor
getVersionMajor(self):
Gets VersionMajor field. CityEngine major number.
@return: Value of VersionMajor field. [int]
@example:
#print CityEngine major string
print ce.getVersionMajor()
getVersionMinor
getVersionMinor(self):
Gets VersionMinor field. CityEngine minor number.
@return: Value of VersionMinor field. [int]
@example:
#print CityEngine minor version
print ce.getVersionMinor()
getVersionString
getVersionString(self):
CityEngine version string.
@return: result. [str]
@example:
#print long CityEngine version string
print ce.getVersionString()
getVersion
getVersion(self):
Gets Version field. CityEngine version number.
@return: Value of Version field. [str]
@example:
#print CityEngine version
print ce.getVersion()
getVertices
getVertices(self, object):
Get the vertices of the specified object.
@param object: The object to get the vertices from.
@return: A list of (unstructured) floating point values of the object's vertices. [sequence]
@example:
# print the vertex list of the selected object to the console
print ce.getVertices(ce.selection()[0])
getViewDistance
getViewDistance(self, object):
Returns the view distance of the Viewshed or View Dome object.
@param object: The Viewshed or View Dome object to query.
@return: The view distance of the Viewshed or View Dome object. [float]
@example:
# print the view distance of one of the Viewsheds in the scene.
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
print ce.getViewDistance(viewshed)
getViewportScenario
getViewportScenario(self, view):
Gets the scenario id displayed in the given 3D View.
@param view: A 3D view obtained from get3DViews().
@return: The scenario id displayed in the given 3d View. [str]
@example:
print ce.getViewportScenario(ce.get3DViews()[0])
getVisibleSolidAngle
getVisibleSolidAngle(self, viewshed, requestedLayers):
Get the layers' visible solid angle from the viewshed.
@param viewshed: The Viewshed . [Analysis]
@param requestedLayers: An array of layers . [sequence of ]
@return: result. [sequence of float]
@example:
# get the Solid Angles of the Viewshed per Object Layer
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
panoramaLayer = ce.getObjectsFrom(ce.scene, ce.withName("'Panorama'"))[0]
newShapesLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'New Shapes'"))[0]
layers = [panoramaLayer,newShapesLayer]
solidAngles = ce.getVisibleSolidAngle(viewshed, layers)
print "Panorama : ", solidAngles [0], " steradians"
print "New Shapes: ", solidAngles [1], " steradians"
getWorkspaceRoot
getWorkspaceRoot(self):
Gets the workspace root.
@return: The workspace root ('/'). [str]
growStreets
growStreets(self, graph, settings = None):
Creates street network starting from an initial set of graph objects.
@param graph: The initial set of street graph objects to grow from.
@param settings: The street grow settings. Omit to use default settings. (default = None).
@example:
# grow streets on layer 'streets'
streetlayer = ce.getObjectsFrom(ce.scene, ce.withName("streets"))
growsettings = GrowStreetsSettings()
growsettings.setEnvironmentSettingsHeightmap('Heightmap')
growsettings.setEnvironmentSettingsObstaclemap('Obstacle')
ce.growStreets(streetlayer, growsettings)
importFile
importFile(self, filesystemPath, importSettings = None, interactive = False):
Imports objects into the current scene or creates a new scene from the import data.
@param filesystemPath: Path to the source file (must be a filesystem path). [str]
@param importSettings: The import settings to apply or null for default settings. (default = None).
@param interactive: Run the import interactively (open dialog and let user finish). (default = False). [True/False]
@return: A list of newly created layers. [sequence]
@example:
# import the dxf file 'sesame_streetsketch.dxf' into the scene
settings = DXFImportSettings()
settings.setScale(0.5)
settings.setOffset([10000,0,-10000])
ce.importFile(ce.toFSPath("/general/data/sesame_streetsketch.dxf"), settings)
importProject
importProject(self, projectPath, copy = False, newName = None):
Adds one project to the workspace and changes the name.
@param projectPath: Absolute filesystem path to the project. [str]
@param copy: Should the data be copied instead of linked. (default = False). [True/False]
@param newName: The name of the project after import. (default = None). [str]
@example:
# Add a project residing at path (without copying or renaming it).
ce.importProject(path)
# Copy the project residing at path and add it renamed to newName).
ce.importProject(path, True, newName)
insertGraphNodes
insertGraphNodes(self, segment, nodeVertices):
Insert a Node to a street segment.
@param segment: The street segment in which we will add nodes .
@param nodeVertices: Node Vertices to add e.g. [[1.0,2.0,3.0], [4.0,5.0,6.0]] .
@return: The New Node and the New Segment. [sequence]
@example:
newGeometries = ce.insertGraphNodes(segment, nodesToAdd)
for i in range(0, len(newGeometries)):
print "segment number", i, "First Node", ce.getVertices(newGeometries[i][1])[0:3];
print "segment number", i, "Second Node", ce.getVertices(newGeometries[i][1])[3:6];
inspect
inspect(self, objects):
Opens the inspector and selects the given objects.
@param objects: The objects to inspect.
@example:
# show 'sphere.obj' in the inspector view
ce.inspect('/general/assets/sphere.obj')
isAnalysisLayer
isAnalysisLayer(self, object):
Predicate that works in ce.getObjectsFrom(ce.scene, ce.isAnalysisLayer) to get all analysis layers.
@param object: The object to be tested.
@return: True if the object is an analysis layer. [True/False]
@example:
# get all analysis layers in the current scene.
ce.getObjectsFrom(ce.scene, ce.isAnalysisLayer)
isAutoDerive
isAutoDerive(self, object):
Predicate that tests if the given object is a generated model.
@param object: The object to be tested.
@return: True if the object is a model or false otherwise. [True/False]
isBlock
isBlock(self, object):
Predicate that tests if the given object is a block.
@param object: The object to be tested.
@return: True if the object is a block or false otherwise. [True/False]
@example:
# get list of current selection filtered by block
selectedBlocks = ce.getObjectsFrom(ce.selection, ce.isBlock)
isDefaultObjectsVisible
isDefaultObjectsVisible(self):
Returns whether the Default Objects are currently visible.
@return: True if Default Object visible, else False. [True/False]
@example:
print ce.isDefaultObjectsVisible()
isDefaultObject
isDefaultObject(self, sceneObject):
Determines if object is in Default Object Scenario.
@param sceneObject: Scene object.
@return: True if object is in Default Object Scenario, else False. [True/False]
@example:
objects = ce.getObjectsFrom(ce.scene, ce.withName("'test3'"))
ce.isDefaultObject(objects[0])
isEnvironmentLayer
isEnvironmentLayer(self, object):
Predicate that tests if the given object is an environment layer.
@param object: The object to be tested.
@return: True if the object is an environment layer or false otherwise. [True/False]
@example:
# create a list of all environment layers in the scene and print it
envLayers = ce.getObjectsFrom(ce.scene, ce.isEnvironmentLayer)
print len(envLayers), envLayers
isFile
isFile(self, workspacePath):
Predicate that tests if the given workspace path is an existing file.
@param workspacePath: Workspace path of the file to test . [str]
@return: True if the given workspace path is an existing file or false otherwise. [True/False]
@example:
# print a list of all files in the workspace directory 'general/assets/textures/facade/'
print ce.getObjectsFrom('/general/assets/textures/facade/', ce.isFile)
isFolder
isFolder(self, workspacePath):
Predicate that tests if the given workspace path is an existing folder.
@param workspacePath: Workspace path of the folder to test. [str]
@return: True if the given workspace path is an existing folder or false otherwise. [True/False]
@example:
# print a list of all folder in the workspace directory 'general/assets'
print ce.getObjectsFrom('/general/assets/', ce.isFolder)
isGraphLayer
isGraphLayer(self, object):
Predicate that tests if the given object is a graph layer.
@param object: The object to be tested.
@return: True if the object is a graph layer or false otherwise. [True/False]
@example:
# create a list of all graph layers in the scene and print it
graphLayers = ce.getObjectsFrom(ce.scene, ce.isGraphLayer)
print len(graphLayers), graphLayers
isGraphNode
isGraphNode(self, object):
Predicate that tests if the given object is a graph node.
@param object: The object to be tested.
@return: True if the object is a graph node or false otherwise. [True/False]
@example:
# get list of current selection filtered by graph node
selectedNodes = ce.getObjectsFrom(ce.selection, ce.isGraphNode)
isGraphSegment
isGraphSegment(self, object):
Predicate that tests if the given object is a graph segment.
@param object: The object to be tested.
@return: True if the object is a graph segment or false otherwise. [True/False]
@example:
# create list of graph segments and print it to the console
segments = ce.getObjectsFrom(ce.scene, ce.isGraphSegment)
print len(segments), "street segments in scene"
isInspector
isInspector(self, view):
Predicate that tests if the given 3D view is an inspector view. DEPRECATED.
@param view: A 3D view obtained from get3DViews().
@return: True if the given 3D view is an inspector view or false otherwise. [True/False]
@example:
# filter inspectors from list of views
inspectorviews = ce.getObjectsFrom(ce.get3DViews(), ce.isInspector)
print inspectorviews
isLayerGroup
isLayerGroup(self, object):
Predicate that tests if the given object is a layer group.
@param object: The object to be tested.
@return: True if the object is a layer group or false otherwise. [True/False]
@example:
# create a list of all group layers in the scene and print it
layerGroups = ce.getObjectsFrom(ce.scene, ce.isLayerGroup)
print len(layerGroups), layerGroups
isLayer
isLayer(self, object):
Predicate that tests if the given object is a layer.
@param object: The object to be tested.
@return: True if the object is a layer or false otherwise. [True/False]
@example:
# create a list of all layers in the scene and print it
layers = ce.getObjectsFrom(ce.scene, ce.isLayer)
print len(layers), layers
isMapLayer
isMapLayer(self, object):
Predicate that tests if the given object is a map layer.
@param object: The object to be tested.
@return: True if the object is an map layer or false otherwise. [True/False]
@example:
# create a list of all map layers in the scene and print it
mapLayers = ce.getObjectsFrom(ce.scene, ce.isMapLayer)
print len(mapLayers), mapLayers
isModel
isModel(self, object):
Predicate that tests if the given object is a generated model.
@param object: The object to be tested.
@return: True if the object is a model or false otherwise. [True/False]
@example:
# test if a object is a model
model = ce.getObjectsFrom(ce.selection(), ce.isModel)[0]
if ce.isModel(model) : print "is model"
else : print "is not a model"
isShapeLayer
isShapeLayer(self, object):
Predicate that tests if the given object is a shape layer.
@param object: The object to be tested.
@return: True if the object is a shape layer or false otherwise. [True/False]
@example:
# create a list of all shape layers in the scene and print it
shapeLayers = ce.getObjectsFrom(ce.scene, ce.isShapeLayer)
print len(shapeLayers), shapeLayers
isShape
isShape(self, object):
Predicate that tests if the given object is a shape.
@param object: The object to be tested.
@return: True if the object is a shape or false otherwise. [True/False]
@example:
# count all shapes in scene
shapes = ce.getObjectsFrom(ce.scene, ce.isShape)
print len(shapes)
# test if selected object is a shape
object = ce.selection()[0]
if ce.isShape(object) : print ce.getName(object)+" is a shape"
else : print ce.getName(object) + "is not a shape"
isStaticModelLayer
isStaticModelLayer(self, object):
Predicate that tests if the given object is a staic model layer.
@param object: The object to be tested.
@return: True if the object is a static model layer or false otherwise. [True/False]
@example:
# create a list of all static model layers in the scene and print it
staticModelLayers = ce.getObjectsFrom(ce.scene, ce.isStaticModelLayer)
print len(staticModelLayers), staticModelLayers
isStaticModel
isStaticModel(self, object):
Predicate that tests if the given object is a static model.
@param object: The object to be tested.
@return: True if the object is a static model or false otherwise. [True/False]
@example:
# print all static models in scene
staticModels = ce.getObjectsFrom(ce.scene, ce.isStaticModel)
print len(staticModels), staticModels
isViewCorridor
isViewCorridor(self, object):
Predicate that works in ce.getObjectsFrom(ce.scene, ce.isViewCorridor) to get all View Corridors.
@param object: The object to be tested.
@return: True if the object is a View Corridor object. [True/False]
@example:
# get all View Corridor objects from the scene.
ce.getObjectsFrom(ce.scene, ce.isViewCorridor)
isViewDome
isViewDome(self, object):
Predicate that works in ce.getObjectsFrom(ce.scene, ce.isViewDome) to get all View Domes.
@param object: The object to be tested.
@return: True if the object is a View Dome. [True/False]
@example:
# get all View Dome objects from the scene.
ce.getObjectsFrom(ce.scene, ce.isViewDome)
isViewport
isViewport(self, view):
Predicate that tests if the given 3D view is a CityEngine viewport. DEPRECATED.
@param view: A 3D view obtained from get3DViews().
@return: True if the given 3D view is an CityEngine viewport or false otherwise. [True/False]
@example:
# filter viewports from list of views
viewports = ce.getObjectsFrom(ce.get3DViews(), ce.isViewport)
print viewports
isViewshed
isViewshed(self, object):
Predicate that works in ce.getObjectsFrom(ce.scene, ce.isViewshed) to get all Viewsheds.
@param object: The object to be tested.
@return: True if the object is a Viewshed. [True/False]
@example:
# get all Viewshed objects from the scene.
ce.getObjectsFrom(ce.scene, ce.isViewshed)
isVisible
isVisible(self, object):
Predicate that tests if the given object is visible.
@param object: The object to be tested.
@return: True if the object is visible or false otherwise. [True/False]
@example:
# create a list of all visible layers in the scene and print it
visibleLayers = ce.getObjectsFrom(ce.scene, ce.isVisible)
print len(visibleLayers), visibleLayers
listProjects
listProjects(self):
Returns all loaded project names.
@return: The names of all currently loaded projects. [sequence of str]
@example:
# Print the name of all projects currently loaded in the workspace
print ce.listProjects()
# Print the filesystem path to the first project.
print ce.toFSPath("/" + ce.listProjects()[0])
listScriptMenuItems
listScriptMenuItems(self):
Lists the current content of the script menu.
@return: Retuns a (potentially empty) list of absolute filesystem paths. [sequence of str]
@example:
# List all script menu entries
print ce.listScriptMenuItems()
makeDefaultObject
makeDefaultObject(self, sceneObjects, newScenarios):
Assigns Scene Objects to Default Object and set Scenarios.
@param sceneObjects: Scene object or array of Scene objects to assign the scenarios to.
@param newScenarios: List of scenario ids to assign. If empty, the object will be assign to all scenarios.
@example:
objects = ce.getObjectsFrom(ce.scene, ce.withName("'test3'"))
scenariosIdList = ce.getScenarioIds()
# make Default Object + 1 scenario
ce.makeDefaultObject(objects,scenariosIdList[0])
# make Default Object + 2 scenarios
ce.makeDefaultObject(objects,['1','2'])
# make Default Object + all scenarios
ce.makeDefaultObject(objects,[])
makeScenarioObject
makeScenarioObject(self, sceneObjects, newScenarios):
Assigns Scene Objects to Scenario Object and set Scenarios.
@param sceneObjects: Scene object or array of Scene objects to assign the scenarios to.
@param newScenarios: List of scenario ids to assign. If empty, the object will be assigned to all scenarios.
@example:
objects = ce.getObjectsFrom(ce.scene, ce.withName("'test3'"))
scenariosIdList = ce.getScenarioIds()
# make Default Object + 1 scenario
ce.makeScenarioObject(objects,scenariosIdList[0])
# make Scenario Object + 2 scenarios
ce.makeScenarioObject(objects,['1','2'])
# make Scenario Object + all scenarios
ce.makeScenarioObject(objects,[])
mergeGraphNodes
mergeGraphNodes(self, destinationNode, nodesToMerge):
merge a list of nodes into another.
@param destinationNode: The street node in which the nodes will be merged .
@param nodesToMerge: Array of Nodes, or one Node .
@return: The Resulting Node .
@example:
ce.mergeGraphNodes(destinationNode, nodeToMerge)
mergeLayers
mergeLayers(self, object):
Merges the layers of the same type together.
@param object: The layers to merge. If other objects are specified, the objects' layers are merged as well.
@return: The newly merged layers. [sequence]
@example:
# merges the selected layers of the same type to a single layer
lotlayer = ce.getObjectsFrom(ce.scene, ce.isShapeLayer, ce.withName("'Lots_1'"))[0]
streetshapelayer = ce.getObjectsFrom(ce.scene, ce.isShapeLayer, ce.withName("'Street Shapes_1'"))[0]
mergedLayers = ce.mergeLayers([lotlayer, streetshapelayer])
move
move(self, objects, t, objectSpace = False, pivot = None):
Move (translate) the current selection or the specified objects.
@param objects: The objects to be moved.
@param t: XYZ translation vector.
@param objectSpace: Transform in object space. (default = False). [True/False]
@param pivot: Set pivot for transformation. (default = None).
@example:
# move the selected object in world coordinates by 10 in x and 600 in y axis
object = ce.selection()[0]
t = [10,600,0]
ce.move(object, t)
newFile
newFile(self, workspacePath, interactive = False):
Creates a new workspace file.
@param workspacePath: Workspace path of the file to create. [str]
@param interactive: Run the new dialog interactively (let user finish). (default = False). [True/False]
@return: The created file.
@example:
# create a new scene newcity.cej in the current project
ce.newFile('scenes/newcity.cej')
openFile
openFile(self, workspacePath = None):
Opens a file in the workspace.
@param workspacePath: Workspace path of the file to open or null to show a file dialog. (default = None). [str]
@return: The newly opened window.
@example:
# open the scene city.cej in the project general
ce.openFile('/general/scenes/city.cej')
openView
openView(self, view):
Opens workspace view.
@param view: One of ['VIEWPORT','INSPECTOR','NAVIGATOR']. [str]
@example:
# open inspector view
ce.openView("INSPECTOR")
project
project(self):
Gets the current CityEngine project name.
@return: the current CityEngine project name. [str]
@example:
#print name of current CityEngine project
print ce.project()
#print absolute path iof current CityEngine project
print ce.toFSPath(ce.project())
refreshFolder
refreshFolder(self, refreshPath):
Refreshes the given local (workspace) path, updating the user interface and resources available to the current state of the filesystem.
@param refreshPath: Workspace path to refresh. [str]
@example:
# refresh a specific folder
ce.refreshFolder('/general/rules/')
refreshWorkspace
refreshWorkspace(self):
Refreshes the workspace.
@example:
# refresh the workspace (check for new and modified files)
ce.refreshWorkspace()
removeFromScenario
removeFromScenario(self, sceneObject, scenarioId):
Removes one or many objects from one scenario.
@param sceneObject: Scene object or array of Scene objects to exclude the scenarios to.
@param scenarioId: The id of the scenario. [str]
@return: True, if the object was successfully removed from scenarios. False, if the operation failed (e.g. object was of wrong type). [True/False]
@example:
objects = ce.getObjectsFrom(ce.scene, ce.withName("'test3'"))
ce.removeFromScenario(objects,'1')
removeHoles
removeHoles(self, shapes):
Remove holes from selected shapes.
@param shapes: The set of shapes to remove the holes from.
@example:
# remove the holes of the shape
ce.removeHoles(ce.findByOID("90dd0000-0030-1bbc-4fe5-86e1dfcd11b4"))
removeProject
removeProject(self, projectName):
Removes the project from the workspace (not from disk).
@param projectName: Name of the project. [str]
@example:
# Remove the project loaded as projectName. The files are not deleted.
ce.removeProject(projectName)
removeScenario
removeScenario(self, scenarioId):
Removes the scenario with the given id and delete all scene objects which were only associated with this scenario.
@param scenarioId: The id of the scenario to remove. [str]
@return: True, if the scenario was successfully removed. False, if the scenario did not exist. [True/False]
@example:
scenarioId = '4'
ce.removeScenario(scenarioId)
removeScriptMenuItems
removeScriptMenuItems(self, scriptPaths):
Removes one or more scripts from the scripts menu.
@param scriptPaths: List of absolute filesystem paths. [sequence of str]
@return: True if all scripts have been successfully removed, false otherwise. [True/False]
@example:
# Remove the script at absolute location path
print ce.removeScriptMenuItems([path])
renameProject
renameProject(self, currentName, newName):
Renames a currently loaded project.
@param currentName: Current name of the project. [str]
@param newName: New name of the project. [str]
@example:
# Rename a project from oldName to newName.
ce.renameProject(oldName, newName)
resetShapeAttributes
resetShapeAttributes(self, object):
Runs the reset shape attribute tool.
@param object: The shape(s) to reset the attribuets of .
@example:
# resets the start rule for dynamic shapes
shapes = ce.getObjectsFrom(ce.scene, ce.isShape)
ce.resetShapeAttributes(shapes)
resetTerrain
resetTerrain(self, shapes = None, settings = None):
Returns the X-Z extents of an attribute layer.
@param shapes: (Optional) The shapes to under which to reset the terrain (if the appropriate Constraint is set). (default = None).
@param settings: (Optional) The ResetTerrainSettings to apply. Omit to use default values. (default = None).
@example:
# reverts any changes to all terrains
ce.resetTerrain()
reverseNormals
reverseNormals(self, shapes):
Reverses the normals of the given shape(s).
@param shapes: The set of shapes to reverse the normals of.
@example:
# reverses the normals of the given shapes
shape = ce.getObjectsFrom(ce.scene, ce.withName("'newShape'"))
ce.reverseNormals(shape)
rotate
rotate(self, objects, r, objectSpace = False, pivot = None):
Rotate the current selection or the specified objects.
@param objects: The objects to be rotated.
@param r: XYZ rotation vector.
@param objectSpace: Transform in object space. (default = False). [True/False]
@param pivot: Set pivot for transformation. (default = None).
@example:
# rotate the selected object 70 degrees around the global y axis using its local center
object = ce.selection()[0]
r = [0,70,0]
ce.rotate(object, r)
sampleBooleanLayerAttribute
sampleBooleanLayerAttribute(self, layer, name, x, z):
Returns the sampled value of an layers boolean attribute at given X-Z location.
@param layer: The layer to sample from.
@param name: The attribute name. [str]
@param x: The X position. [float]
@param z: The Z position. [float]
@return: Sampled value. [True/False]
@example:
# get value of bool attribute "obstacle" in attribute layer "Obstacle" at position x=25, z=30
obstacleLayer = ce.getObjectsFrom(ce.scene, ce.withName("'Obstacle'"))[0]
print ce.sampleBooleanLayerAttribute(obstacleLayer, "obstacle", 25, 30)
sampleFloatLayerAttribute
sampleFloatLayerAttribute(self, layer, name, x, z):
Returns the sampled value of an layers float attribute at given X-Z location.
@param layer: The layer to sample from.
@param name: The attribute name. [str]
@param x: The X position. [float]
@param z: The Z position. [float]
@return: Sampled value. [float]
@example:
# get value of float attribute "elevation" in attribute layer "Heightmap" at position of the shape 'myShape'
heightmapLayer = ce.getObjectsFrom(ce.scene, ce.withName("'Heightmap'"))[0]
shape = ce.getObjectsFrom(ce.scene, ce.isShape, ce.withName("'myShape'"))[0]
pos = ce.getPosition(shape)
print ce.sampleFloatLayerAttribute(heightmapLayer, "elevation", pos[0], pos[2])
sampleStringLayerAttribute
sampleStringLayerAttribute(self, layer, name, x, z):
Returns the sampled value of an layers string attribute at given X-Z location.
@param layer: The layer to sample from.
@param name: The attribute name. [str]
@param x: The X position. [float]
@param z: The Z position. [float]
@return: Sampled value. [str]
@example:
# get value of string attribute "name" in shape layer "LotsSouth" at position x=25, z=30
lotLayer = ce.getObjectsFrom(ce.scene, ce.withName("'areaLayer'"))[0]
print ce.sampleStringLayerAttribute(lotLayer, "areaName", 25, 30)
saveFile
saveFile(self, workspacePath = None):
Saves an open file.
@param workspacePath: Workspace path of the file to save or null to save the current scene. (default = None). [str]
@example:
# save the open scene
ce.saveFile()
scale
scale(self, objects, s, objectSpace = False, pivot = None):
Scale the current selection or the specified objects.
@param objects: The objects to be scaled.
@param s: XYZ scale vector or uniform scale value.
@param objectSpace: Transform in object space. (default = False). [True/False]
@param pivot: Set pivot for transformation. (default = None).
@example:
# scale the selected object in world x and z axes using its local center
object = ce.selection()[0]
s = [8,1,7]
ce.scale(object, s)
scene
scene(self):
Gets the current CityEngine scene.
@return: the current CityEngine scene.
@example:
# print the name of the currently opened scene
print ce.scene()
#get a list of all shapes in the scene
shapes = ce.getObjectsFrom(ce.scene, ce.isShape)
selectContinuousGraphObjects
selectContinuousGraphObjects(self, object, maxAngle):
Select graph objects adjacent and .
@param object: The initial street segments .
@param maxAngle: Connected graph edges which are parallel or have an angle lower than this value are said to be continuous and are therefore selected (in degrees). [float]
@return: result. [sequence]
@example:
#find continuous graph segments with angle tolerance 25 and change their widths
segment = ce.findByOID('a5300000-0030-1bbc-bdcd-b3a0439a11b2')
continuousStreet = ce.selectContinuousGraphObjects(segment, 60)
ce.setSelection(continuousStreet)
ce.setAttributeSource(continuousStreet, "/ce/street/streetWidth", "OBJECT")
ce.setAttribute(continuousStreet, "streetWidth", 35)
selection
selection(self):
Gets the current CityEngine selection.
@return: The current CityEngine selection. [sequence]
@example:
# print a list of selected objects to the console
print ce.selection()
separateFaces
separateFaces(self, shapes):
Separates all the faces in the selected shapes.
@param shapes: The set of shapes whose faces will be separated.
@return: The newly created faces. [sequence]
@example:
shape = ce.combineShapes( [ ce.findByOID("90dd0000-0030-1bbc-4fe5-86e1dfcd11b4"),ce.findByOID("90dd0000-0030-1bbc-4fe4-0d46dfcd11b4") ] )
# Separate the faces of the 'newShape'
newShapes = ce.separateFaces(shape)
setAnglesOfView
setAnglesOfView(self, object, hAngle, vAngle):
Sets the angles of view of the Viewshed or View Corridor object.
@param object: The Viewshed or View Corridor object to update.
@param hAngle: The horizontal angle of view. [float]
@param vAngle: The vertical angle of view. [float]
@example:
# set the angles of view of a View Dome to 90 degrees horizontally and 45 degrees vertically.
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
ce.setAnglesOfView(viewshed, 90, 45)
setAttributeLayerExtents
setAttributeLayerExtents(self, layer, extents):
Returns the X-Z extents of an attribute layer.
@param layer: The attribute layer to set the extents to.
@param extents: An list of four floating point values. [sequence of float]
@example:
# set position (0,20) and size (3000,4000 of the layer "Terrain"
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Terrain'"))[0]
ce.setAttributeLayerExtents(l, [0,20,3000,4000])
setAttributeSource
setAttributeSource(self, objects, name, source):
Set the attribute source of the given attribute for the given objects.
@param objects: The objects to set the attribute source to.
@param name: The name of the attribute of which the source will be set. [str]
@param source: The new attribute source. Either 'OBJECT' for object source, 'USER' for user source, 'RULE' for rule source, 'SHAPE' for shape source, 'DEFAULT' for default source, or an attribute layer for an attribute layer.
@example:
# Change the rule parameter source of 'height' to OBJECT
ce.setAttributeSource(ce.selection(), '/ce/rule/height', 'OBJECT')
# Change the rule parameter source of 'areaName' to layer 'areaLayer'
areaLayer = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'areaLayer'"))[0]
ce.setAttributeSource(ce.selection(), '/ce/rule/areaName', areaLayer)
setAttribute
setAttribute(self, objects, name, value):
Set the named object attribute to the given value(s) for the given objects.
@param objects: The objects to set the attributes to.
@param name: The attribute name. [str]
@param value: The new attribute value or sequence or map.
@example:
# add or overwrite object attribute 'area' with value 5 on selected object
ce.setAttribute(ce.selection()[0], 'height', 12)
# add or overwrite object attribute array 'streetWidth' on selected object
ce.setAttribute(ce.selection()[0], 'streetWidth', [0,0,12,0])
# set block parameter 'shapeCreation' of block 'BlockSouth_8' to false
# and make sure parameter source is USER
block = ce.getObjectsFrom(ce.scene, ce.withName("'BlockSouth_8'"))[0]
ce.setAttribute(block, '/ce/block/shapeCreation', False)
ce.setAttributeSource(block, '/ce/block/shapeCreation', "USER")
# set street parameter 'streetWidth' on segment 'ShapeFile Segment 3148' to 20
# and make sure parameter source is USER
streetsegment = ce.getObjectsFrom(ce.scene, ce.withName("'ShapeFile Segment 3148'"))[0]
ce.setAttribute(streetsegment, '/ce/street/streetWidth', 20)
ce.setAttributeSource(streetsegment, '/ce/street/streetWidth', "USER")
# set crossing parameter 'type' on all nodes to Roundabout
# and make sure parameter source is USER
nodes = ce.getObjectsFrom(ce.scene, ce.isGraphNode)
ce.setAttribute(nodes, '/ce/crossing/type', "Roundabout")
ce.setAttributeSource(nodes, '/ce/crossing/type', "USER")
setColorGeometry
setColorGeometry(self, object, colorGeometry):
Sets whether the visibility object colors scene geometry.
@param object: The visibility object to update.
@param colorGeometry: Whether to color geometry or not. [True/False]
@example:
# set that the View Dome should not color geometry in the scene.
dome = ce.getObjectsFrom(ce.scene, ce.isViewDome)[0]
ce.setColorGeometry(dome, False)
setCurveHandle
setCurveHandle(self, segment, node, dir):
Set the curve handle associated with a street segment.
@param segment: The street segment whose handle will by changed by this command.
@param node: Either the node associated with the start of the street, or the end. This specifies whether this command will change the first or second curve handle.
@param dir: The vector defining the direction and distance of the curve handle [x, y, z].
@example:
# Sets the location of curve handle at the node's end of the specified segment
graphLayer = ce.getObjectsFrom(ce.scene, ce.isGraphLayer)[0]
segment = ce.getObjectsFrom(graphLayer, ce.isGraphSegment)[0]
node = ce.getObjectsFrom(segment, ce.isGraphNode)[1]
ce.setCurveHandle( segment, node, [-50,50,-50])
setCurveSmooth
setCurveSmooth(self, objects):
Set curve to smooth state.
@param objects: A collection of graph nodes and/or edges.
@example:
# set curve handles to smooth state
segments = ce.getObjectsFrom(ce.scene, ce.isGraphSegment)
ce.setCurveSmooth(segments)
setCurveStraight
setCurveStraight(self, objects):
Set curve to straight state.
@param objects: A collection of graph nodes and/or edges.
@example:
# set curve handles to sraight state
segments = ce.getObjectsFrom(ce.scene, ce.isGraphSegment)
ce.setCurveStraight(segments)
setElevationOffset
setElevationOffset(self, layer, offset):
Set the elevation offset of the specified layer.
@param layer: The layer to set the attributes to.
@param offset: The offset to be set. [float]
@example:
# sets the elevation offset of the layer "Terrain" to 100
l = ce.getObjectsFrom(ce.scene, ce.isMapLayer, ce.withName("'Terrain'"))[0]
print ce.setElevationOffset(l, 100)
setFirstEdge
setFirstEdge(self, shape, firstEdge):
Specifies the first edge of a shape.
@param shape: The shape to specify the first edge of.
@param firstEdge: The index of the new first edge. [int]
@example:
# Increment the first edge of the selected shape by one
selectedShape = ce.getObjectsFrom(ce.scene, ce.withName("'newShape'"))[0]
print ce.getVertices(selectedShape)
ce.setFirstEdge(selectedShape, 1)
print ce.getVertices(selectedShape)
setLayerAttributes
setLayerAttributes(self, layer, code):
Set the attribute code of the specified layer.
@param layer: The layer to set the attributes to.
@param code: The function attribute code to be set. [str]
@example:
# set the attribute elevation in the layer attribute code of the layer "Terrain"
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Terrain'"))[0]
ce.setLayerAttributes(l, "attr elevation = brightness*150")
setLayerPreferences
setLayerPreferences(self, layer, preference, value):
Set Group or Layer Preference.
@param layer: The Group or Layer .
@param preference: "Visible", "Locked", "Show Network", "Show Blocks", "Colored", "Color" . [str]
@param value: True, False or color (list of 3 numbers [0..1] or string #RRGGBB) .
@example:
# set visibility of the layer "Heightmap"
l = ce.getObjectsFrom(ce.scene, ce.isLayer, ce.withName("'Heightmap'"))[0]
ce.setLayerPreferences(l, "Visible", True)
# enable coloring of layer "Heightmap"
ce.setLayerPreferences(l, "Colored", True)
# set color of the layer "Heightmap" via hex string
ce.setLayerPreferences(l, "Color", "#00FF00")
# set color of the layer "Heightmap" via float list
ce.setLayerPreferences(l, "Color", [1.0, 0.0, 0.0])
# disable coloring of layer "Heightmap"
ce.setLayerPreferences(l, "Colored", False)
setLighting
setLighting(self, settings = None):
Sets the lighting settings to the supplied settings.
@param settings: The light settings to be set. (default = None).
@example:
# set the lighting to the default values
lightSettings = LightSettings()
ce.setLighting(lightSettings)
setName
setName(self, objects, name):
Set the name of the specified object.
@param objects: The objects to set the name to.
@param name: The name to be set. [str]
@example:
# set name of selected object to 'new Shape'
ce.setName(ce.selection()[0], 'my Shape')
setObserverPoint
setObserverPoint(self, object, observerPoint):
Sets the observer position of the visibility object.
@param object: The visibility object to update.
@param observerPoint: The desired observer position as a list of 3 floating point values. [sequence of float]
@example:
# update the observer position of one of the view domes in the scene to (30, 40, 50).
dome = ce.getObjectsFrom(ce.scene, ce.isViewDome)[0]
ce.setObserverPoint(dome, [30, 40, 50])
setPanorama
setPanorama(self, settings = None):
Updates the panorama settings to match the supplied settings.
@param settings: A PanoramaSettings object containing the requested panorama settings. (default = None).
@example:
# resets the panorama settings to default
panoramaSettings = PanoramaSettings()
ce.setPanorama(panoramaSettings)
setPOI
setPOI(self, object, poI):
Sets the point of interest of the View Corridor object.
@param object: The View Corridor object to update.
@param poI: The desired poi as a list of 3 floating point values. [sequence of float]
@example:
# sets the point of interest of a View Corridor to (20, 30, 40).
corridor = ce.getObjectsFrom(ce.scene, ce.isViewCorridor)[0]
ce.setPOI(corridor, [20, 30, 40])
setPosition
setPosition(self, objects, position):
Set the position of the specified objects.
@param objects: The layer or layer objects to set the position to.
@param position: An list containing the center [x, y, z] .
@example:
# set the absolute position in world coordinates of the selected object
object = ce.selection()[0]
position = [0,0,1000]
ce.setPosition(object, position)
setRuleFile
setRuleFile(self, shapes, workspacePath = None, hasToExist = False):
Assigns a rule file to shapes.
@param shapes: The set of shapes to assign the rule file to.
@param workspacePath: The workspace path of the CGA rule file to assign, or None to interactively select a file. (default = None). [str]
@param hasToExist: Assign the CGA rule file only if it exists. (default = False). [True/False]
@example:
# assign the rulefile extrude.cga to all selected shapes
ce.setRuleFile(ce.selection(), 'extrude.cga')
setScenarioColor
setScenarioColor(self, scenarioId, color):
Assigns a color to a scenario. It is not possible to set a color to the Default Scenario.
@param scenarioId: Scenario id. [str]
@param color: A String defining the color e.g. '#FF0000'. [str]
@example:
scenariosId = ce.getScenarioIds()
ce.setScenarioColor(scenariosId[0],'#FF0000')
setScenarioId
setScenarioId(self, oldScenarioId, newScenarioId):
Assigns a new Id to a scenario. A scenario Id has to be unique in the scene.
@param oldScenarioId: Old scenario id. [str]
@param newScenarioId: New scenario id. [str]
@example:
oldScenarioId = '1'
newScenarioId = '1B'
ce.setScenarioId(oldScenarioId,newScenarioId)
setScenarioName
setScenarioName(self, scenarioId, scenarioName):
Assigns a name to a scenario.
@param scenarioId: The id of the scenario. [str]
@param scenarioName: Scenario name. [str]
@example:
scenarioId = '1'
scenarioName = 'Scenario 1'
ce.setScenarioName(scenarioId,scenarioName)
setScenarioOrder
setScenarioOrder(self, newIds):
Sets the scenario order. Unknown ids will be ignored. Scenarios not listed anymore will be deleted.
@param newIds: List of scenario ids. [sequence]
@return: True, if all ids have been reordered. False, if the list was not complete or contained unknown ids. [True/False]
@example:
scenarioIds = ['1','2','3']
ce.setScenarioOrder(['1','2','3'])
setSceneCoordSystem
setSceneCoordSystem(self, description):
Sets the current scene coordinate system (does NOT relocate the scene).
@param description: The coordinate system description als AUTH:CODE, proj4 or WKT format. [str]
@example:
# set scene coordinate system with proj4 string
proj4 = '+proj=lcc +lat_1=34.03333333333333 +lat_2=35.46666666666667 +lat_0=33.5 +lon_0=-118 +x_0=2000000 +y_0=500000 +datum=NAD83 +units=m +no_defs +__auth=EPSG +__code=26945'
ce.setSceneCoordSystem(proj4)
# set scene coordinate system with WKT format
wkt = 'PROJCS["NAD_1983_StatePlane_California_V_FIPS_0405",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",2000000.0],PARAMETER["False_Northing",500000.0],PARAMETER["Central_Meridian",-118.0],PARAMETER["Standard_Parallel_1",34.03333333333333],PARAMETER["Standard_Parallel_2",35.46666666666667],PARAMETER["Latitude_Of_Origin",33.5],UNIT["Meter",1.0]]'
ce.setSceneCoordSystem(wkt)
# set scene coordinate system with AUTH:CODE
ce.setSceneCoordSystem("EPSG:26954")
ce.setSceneCoordSystem("No_Projection:Meter")
setSceneScenario
setSceneScenario(self, defaultObjectsVisible, scenarioId):
Sets the scenario displayed by the scene.
@param defaultObjectsVisible: True if Default Scenario has to be displayed, else False. [True/False]
@param scenarioId: The id of the scenario. [str]
@example:
scenarioId = '1'
selectDefaultVisible = True
ce.setSceneScenario(selectDefaultVisible,scenarioId)
setSeed
setSeed(self, shapes, seed = None):
Sets the seed of shapes.
@param shapes: The set of shapes to set the seed.
@param seed: The new seed to be set or None to reset the seed. (default = None).
@example:
# set seed of selected shape to 1234
ce.setSeed(ce.selection()[0], 1234)
setSelection
setSelection(self, objects):
Sets the current CityEngine selection to the given object(s).
@param objects: The objects to select.
@example:
# select shape with name 'new Shape'
shapes = ce.getObjectsFrom(ce.scene, ce.withName("'new Shape'"))
ce.setSelection(shapes)
# clear selection
ce.setSelection(None)
setStartRule
setStartRule(self, shapes, rule):
Sets the Start Rule for the given shapes.
@param shapes: The set of shapes to set the Start Rule.
@param rule: The new Start Rule. [str]
@example:
# set start rule of selected shape to 'Park'
ce.setStartRule(ce.selection()[0], 'Park')
setStreetEdges
setStreetEdges(self, shape, edges):
Specifies the streetWidth values for a shape.
@param shape: The shape to specify streetWidths for.
@param edges: The street widths of adjacent streets, or -1 for none. [sequence of float]
@example:
# Set the streetWidth object attributes of the selected shape
selectedShape = ce.getObjectsFrom(ce.scene, ce.withName("'newShape'"))[0]
ce.setStreetEdges(selectedShape, [1,0,1,2,-1,-1,1,2])
setTerrainMaxHeight
setTerrainMaxHeight(self, layer, maxHeight):
Sets the maximum height of the specified layer.
@param layer: The layer to set the attributes to.
@param maxHeight: The height to be set. [float]
setTerrainMinHeight
setTerrainMinHeight(self, layer, minHeight):
Sets the minimum height of the specified layer.
@param layer: The layer to set the attributes to.
@param minHeight: The height to be set. [float]
setTiltAndHeadingAngles
setTiltAndHeadingAngles(self, object, tilt, heading):
Sets the tilt and heading angles of the Viewshed object.
@param object: The Viewshed object to update.
@param tilt: The tilt angle. [float]
@param heading: The heading angle. [float]
@example:
# set the tilt and heading angle of a View Dome to be 45 degrees down and 120 degrees from north.
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
ce.setTiltAndHeadingAngles(viewshed, -45, 120)
setVertices
setVertices(self, object, vertices):
Set vertices of the specified object.
@param object: The object to set the vertices to.
@param vertices: An list of (unstructured) floating point values. The size of the array must be the same as the size of array that getVertices returns. [sequence of float]
@example:
# modify the vertices of the selected object by specifying a vertex list
object = ce.selection()[0]
vertices = [10,0,0,0,0,20,30,0,40,50,0,0]
ce.setVertices(ce.selection()[0], vertices)
setViewDistance
setViewDistance(self, object, distance):
Sets the view distance of the Viewshed or View Dome object.
@param object: The Viewshed or View object to update.
@param distance: The view distance. [float]
@example:
# sets the view distance of a View Dome to be 60m.
viewshed = ce.getObjectsFrom(ce.scene, ce.isViewshed)[0]
ce.setViewDistance(viewshed, 60)
setViewportScenario
setViewportScenario(self, view, scenarioId):
Sets the scenario displayed in one 3D View.
@param view: A 3D view obtained from get3DViews().
@param scenarioId: The id of the scenario. [str]
@example:
scenarioId = '1'
ce.setViewportScenario(ce.get3DViews()[0],scenarioId)
showDashboard
showDashboard(self):
show Dashboard.
@return: .
simplifyGraph
simplifyGraph(self, objects, settings = None):
Runs the simplify graph tool. Fits curves to straight streets.
@param objects: A collection of graph nodes and/or edges .
@param settings: The simplify graph settings. Omit to use default settings. (default = None).
@example:
# Fit curves to short, straight street segments
graphlayer = ce.getObjectsFrom(ce.scene, ce.isGraphLayer, ce.withName("Streetnetwork"))[0]
segments = ce.getObjectsFrom(graphlayer, ce.isGraphSegment)
settings = SimplifyGraphSettings()
settings.setThresholdAngle(10)
ce.simplifyGraph(segments, settings)
splitGraphNodes
splitGraphNodes(self, node, nodeSegments):
Insert a Node to a street segment.
@param node: The street node to duplicate .
@param nodeSegments: segments to split .
@return: The New Node and the New Segment.
@example:
ce.splitGraphNodes(node, segment)
subdivideShapes
subdivideShapes(self, shapes, settings = None):
Subdivides a set of shapes using a block to lot algorithm.
@param shapes: The set of shapes to subdivide.
@param settings: The subdivision settings. Omit to use default settings. (default = None).
@return: The new lot shapes. [sequence]
@example:
# subdivide shapes in scene
shapes = ce.getObjectsFrom(ce.scene, ce.isShape, ce.withName("'Block 1'"))
subdsettings = SubdivideShapesSettings()
subdsettings.setLotAreaMax(800)
ce.subdivideShapes(shapes, subdsettings)
subtractShapes
subtractShapes(self, shape, shapes):
Boolean subtract of the first shape from the other shapes.
@param shape: The shape to perform boolean subtraction with (subtrahend).
@param shapes: The set of shapes to perform boolean subtraction upon (minuend).
@example:
# subtract the first shape from the others
shape = ce.subtractShapes( ce.findByOID("90dd0000-0030-1bbc-4fe5-86e1dfcd11b4"), [ ce.findByOID("90dd0000-0030-1bbc-4fe4-0d46dfcd11b4") ] )
textureShapeTool
textureShapeTool(self, objects, settings):
Runs the fit shape texturing tool.
@param objects: A collection of shapes .
@param settings: The shape texturing tool settings.
@example:
shapes = ce.getObjectsFrom(ce.scene, ce.isShape, ce.withName("'Block 1'"))
ta = TexturingSettings()
ta.setTextureFile("maps/map.png")
ce.textureShapeTool(shapes[0], ta)
toFSPath
toFSPath(self, workspacePath):
Converts the local (workspace) path to an absolute file system path.
@param workspacePath: Workspace path to convert to a absolute file system path. [str]
@return: An absolute file system path. [str]
@example:
# print the absolute path of the file 'scenes/city.cej' to the console
print ce.toFSPath('scenes/city.cej')
unionShapes
unionShapes(self, shapes):
Boolean union of all the selected shapes into a single shape.
@param shapes: The set of shapes to perform boolean union upon.
@return: result.
@example:
# unify the two shapes
shape = ce.unionShapes( [ ce.findByOID("90dd0000-0030-1bbc-4fe5-86e1dfcd11b4"), ce.findByOID("90dd0000-0030-1bbc-4fe4-0d46dfcd11b4") ] )
upload
upload(self, settings):
Uploads a file to ArcGIS Portal.
@param settings: The upload settings.
@return: result. [str]
@example:
# upload a 3ws to an ArcGIS portal
uploadsettings = PortalUploadSettings()
uploadsettings.setFile("/general/models/3ws/materialTest58.3ws")
uploadsettings.setTitle("3ws_Script_Upload")
uploadsettings.setDescription("3ws from apidoctest script cga0")
uploadsettings.setUrl(URL)
uploadsettings.setUsername(username)
uploadsettings.setPassword(password)
ce.upload(uploadsettings)
waitForUIIdle
waitForUIIdle(self):
Wait until the user interface is idle (e.g. no UI action is running, all animations have finished and all generated models are visible).
@example:
# pause script until frame() finishes
views = ce.getObjectsFrom(ce.get3DViews())
views[0].frame()
ce.waitForUIIdle()
print "frame finished"
withName
withName(self, pattern):
Matches for a given file name pattern.
@param pattern: The pattern. [str]
@return: A matcher for the given pattern.
@example:
# get a list of all scene objects whose name starts with 'Lot'
lotobjects = ce.getObjectsFrom(ce.scene, ce.withName("'Lot*'"))
print lotobjects
# get object whose name is exactly 'new Shape'
lot = ce.getObjectsFrom(ce.scene, ce.withName("'new Shape'"))
print lot
withScenario
withScenario(self, id, defaultObjects = True):
Predicate that works in ce.getObjectsFrom(ce.scene, ce.isShape, ce.withScenario('scenario id').
@param id: The scenario id to test against. Can be None, in this case only default objects will be returned. [str]
@param defaultObjects: If True, default objects visible in this scenario are also returned. Default value is True. (default = True). [True/False]
@return: True if the object is visible in the given scenario.
@example:
scenarioId = '1'
objects = ce.getObjectsFrom(ce.scene,ce.withScenario(scenarioId,True))
Constants
This class defines the following constants:
INSPECTOR = 'INSPECTOR'
NAVIGATOR = 'NAVIGATOR'
VIEWPORT = 'VIEWPORT'