[014] How to Use First Edge & Street Edge Attributes in Esri CityEngine

Learn how to define shape edges and control procedural building orientations using street attributes.

In Esri CityEngine, First Edge and Street Edge attributes are essential for procedural modeling workflows because they define how buildings interact with surrounding streets. In this tutorial, we will explore the core concepts of the Shapes Menu in Esri CityEngine. You will learn how to configure First Edges and Street Edges, which are essential for aligning procedural buildings to street networks and generating highly realistic Digital Twins.

    The following short demonstration shows how First Edge orientation can be manually changed inside Esri CityEngine using the Set First Edge tool.

    Video Demonstration: Changing the First Edge orientation manually inside Esri CityEngine using the Set First Edge tool.

    Introduction to the CityEngine Shapes Menu

    Shapes are arguably the most important element in CityEngine. All procedural modeling is generated by applying CGA rules to these shapes. If you cannot manipulate shapes effectively, you essentially cannot generate 3D models.

    Over the next three tutorials, we will explore the menus and features related to shapes. First, let's look at the available shape-related menus. Reviewing these options will give you a broad understanding of how shapes are handled in the software.

    [img 1 : CityEngine Shapes Menu and Inspector Panel Options]
    [img 1 : CityEngine Shapes Menu and Inspector Panel Options]

    Core Shape Creation and Modification Tools:

    • Rectangular Shape Creation: Create 2D rectangles.
    • Circular Shape Creation: Create 2D circles.
    • Push Pull Tool: Modify 2D/3D shapes (extrude faces, depress, or move edges/faces).
    • Guide Creation: Create reference guidelines.
    • Reverse Normals: Flip the direction of face normals (inside out/outside in).
    • Compute First/Street Edges: Automatically configure the starting edge and street-facing edges.
    • Compute Edge Attributes: Assign detailed edge attributes based on proximity conditions.
    • Set First Edge: Designate a specifically selected edge as the "First Edge."
    • Set Street Edges: Designate a specifically selected edge as a "Street Edge."
    • Separate Faces: Detach connected faces based on their shared edges.
    • Combine Shapes: Group selected shapes into one (preserves internal edges of intersecting areas).
    • Union Shapes: Merge shapes via boolean addition (removes internal edges of intersecting areas).
    • Subtract Shapes: Perform a boolean subtraction between shapes.
    • Offset Shapes: Create parallel lines inside or outside a shape, similar to the offset function in CAD software.
    • Remove Holes: Fill empty holes inside complex polygons.
    • Convert Models to Shapes: Convert rule-generated models or imported 3D objects back into editable 2D/3D shapes.
    • Cleanup Shapes: Simplify geometry by adjusting edge angles and vertex spacing tolerances.
    • Crop Image: Correct perspective distortion in building photos for the Facade Wizard. 
    • Texture Shapes: Apply simple image mapping directly to shapes without writing CGA rules.
    • Assign Rule File: Apply a CGA rule file to a shape.
    • Generate Models: Convert the shape into a 3D model using the assigned rule.
    • Re-Generate all Models: Update and regenerate all modeled shapes currently visible in the viewport.
    • Update Seed: Apply a new random seed value to randomize procedural generation.
    • Reset Seed: Revert to the original random seed value.
    • Delete Models: Delete the selected generated models.
    • Reset attributes and style: Revert attributes and styles back to their initial rule settings.

    These are the core features of the Shapes menu. Most of them are intuitive enough to understand with just a brief description, so we won't cover every single one in depth today.

    Understanding the "First Edge"

    Today, we will focus on the edge-related features that are heavily used when coding CGA rules: Compute First/Street Edges, Compute Edge Attributes, Set First Edge, and Set Street Edges. The remaining green highlighted menus will be covered in the next session.

    The "First Edge" is simply the first line segment drawn when creating a polygon. It does not have any magical properties; it simply represents the "0th" index edge. The term "First Edge" is just used for clarity within the interface.

    💡 Practical Tip: In CityEngine, polygon edges are always indexed in a counter-clockwise direction. If you draw polygons clockwise in AutoCAD or other GIS software, the face normals might flip when imported. Develop a habit of drawing polygons counter-clockwise when preparing data for CityEngine.

    Let's first identify where the First Edge is located visually.

    [img 2 : Identifying the First Edge gradient color in the Viewport]
    [img 2 : Identifying the First Edge gradient color in the Viewport]


    If you draw a rectangle and select it, you will notice that one of the edges has a slightly different color gradient. The color of the top line segment transitions from orange on the right to blue on the left. This specific line is your First Edge. (Remember, CityEngine structures polygons counter-clockwise).

    You can manually change this starting edge using the Set First Edge function. Simply select the desired edge and execute the command to redefine it as the First Edge.


    Working with Street Edges

    Now, let's explore the "Street Edge." A Street Edge is an edge that reflects the attributes of adjacent roads surrounding the shape. While every shape automatically has a First Edge, it may or may not have a Street Edge.

    For city blocks generated through an automated street network, Street Edges are created automatically. However, manually drawn shapes or imported footprints do not have Street Edges by default. To understand how basic street networks function, refer to [009] How to Generate Basic Streets in CityEngine.

    If you look at the Object Attributes in the Inspector Panel for the shape we just created manually, you will see it is completely empty.

    [img 3 : Empty Object Attributes Panel for a manually drawn shape]
    [img 3 : Empty Object Attributes Panel for a manually drawn shape]


    Exactly. Now, let's draw a road adjacent to our shape and add the road's attributes into the shape's Object Attributes.


    After drawing the road and executing Compute First/Street Edges, an array is generated in the Object Attributes tab. Be aware that even if your original First Edge was on the opposite side of the road, running this tool will automatically move the First Edge to align with the new Street Edge.

    [img 4 : Edge Indexing and Street Width Attributes mapped to the shape]
    [img 4 : Edge Indexing and Street Width Attributes mapped to the shape]


    As mentioned earlier, the First Edge is index 0, and the remaining edges follow a counter-clockwise order. In the Object Attributes tab, you can see that index 0 has a value of 7. This means the First Edge is adjacent to a road with a width of 7 meters.

    If we were to draw another road on the left side, the 1st edge (index 1) would also automatically receive a street width value.

    There is a specific threshold for how edges detect roads. Since edges are straight lines, they recognize adjacent roads within a certain angular tolerance from their endpoints. The attributes of the closest road within a 100-meter range in the edge's facing direction are applied. If there are roads on multiple sides, the edge closest to a road becomes the First/Street Edge.

    Note that the streetWidth value represented here accounts only for the vehicle lane width, excluding pedestrian sidewalks.

    Advanced Configuration: Compute Edge Attributes

    While Compute First/Street Edges simply maps the basic relationship between edges and streets, Compute Edge Attributes allows you to generate detailed edge attributes based on highly specific proximity conditions.

    Select a polygon adjacent to a road and execute Compute Edge Attributes. The following dialog box will appear, allowing for detailed configuration.

    [img 5 : Compute Edge Attributes Dialog Box settings]
    [img 5 : Compute Edge Attributes Dialog Box settings]


    Video Demonstration: Generating orientation, street category, and road-relative edge attributes using Compute Edge Attributes.

    Let's leave it at the default settings for now and observe how the generated Object Attributes differ from the previous tool. As you can see, a rich set of data is generated in the Object Attributes tab.

    [img 6 : Detailed Object Attributes showing orientations and categories]
    [img 6 : Detailed Object Attributes showing orientations and categories]


    First of all, notice that the position of the First Edge is not forcefully changed by this tool.

    It generates three main types of attributes corresponding to the edge indices:

    • orientations: Classifies whether the edge is facing the road (front), facing away (rear), or on the sides (side).
    • streetcategories: Identifies the specific hierarchy or type of the adjacent road (e.g., Major Edge, Minor Edge).
    • streetwidths: Shows the total width of the adjacent road, which includes both vehicle lanes and sidewalks in this specific tool's calculation.

    💡 Practical Tip: The generated attributes are fully editable! You can manually type and override these values directly within the Inspector Panel (e.g., changing a side to a front) to force specific architectural behaviors without physically modifying the underlying road network.

    Real-World Application Example

    So, when do we actually use this? Let's assume we have a layout of roads and building footprints configured like the image below.

    [img 7 : Figure 1 - Building Layout within a road loop]
    [img 7 : Figure 1 - Building Layout within a road loop]


    This layout was created by generating a road loop and manually drawing rectangles inside it. As mentioned earlier, manually drawn shapes only have a First Edge. Let's look at their current First Edge orientations.

    [img 8 : Figure 2 - Initial First Edge Positions facing randomly]
    [img 8 : Figure 2 - Initial First Edge Positions facing randomly]


    For the buildings in the top row, the First Edges are already facing the road. When we write our CGA rule, we can instruct CityEngine to generate main entrances on these First Edges.

    However, for the buildings in the bottom row, the First Edges are facing inward, away from the road. If we apply the exact same rule, the entrances will be generated on the back, offering no access from the street.

    You could manually fix this by using the Set First Edge tool one by one. But if you are dealing with hundreds or thousands of parcels, this manual process would be incredibly time-consuming.

    Logically, the building entrances should face outward towards the roads, as shown below. The technical challenge is how to programmatically identify the "front" of every building.

    [img 9 : Figure 3 - Logical Building Entrances pointing towards roads]
    [img 9 : Figure 3 - Logical Building Entrances pointing towards roads]


    By executing Compute First/Street Edges in this state, the alignments are automatically corrected as shown below.

    [img 10 : Figure 4 - First Edges correctly changed by Compute First/Street Edges]
    [img 10 : Figure 4 - First Edges correctly changed by Compute First/Street Edges]


    As you can see, the inward-facing First Edges have been automatically rotated to face the surrounding streets. If we select one of these footprints and inspect the generated Object Attributes:

    [img 11 : Figure 5 - Edge Order and streetWidth values updated]
    [img 11 : Figure 5 - Edge Order and streetWidth values updated]


    Information about the edge indexing and the adjacent street width is successfully generated. Even with just this basic data, you can generate highly logical and context-aware procedural buildings using your CGA rules.

    Now, let's revert to our initial state (from Figure 2) and run Compute Edge Attributes to extract more detailed, road-relative edge data.

    The image below shows the result of selecting all six rectangles and running `Compute Edge Attributes`. Notice that the First Edge locations were NOT forcefully altered this time.

    [img 12 : Detailed Object Attributes for Selected Shapes showing orientations]
    [img 12 : Detailed Object Attributes for Selected Shapes showing orientations]

    Let's select a single building footprint and closely examine the newly populated Object Attributes. Looking at the values mapped to the edge indices, the concept immediately becomes clear.

    In your CGA rules, you can dynamically query these attributes to trigger various architectural responses. For example, you can implement building setbacks, apply step-back zoning restrictions based on road width, or dynamically alter the direction of the main entrance based strictly on the front orientation.

    These edge attributes become extremely powerful once used inside CGA rules, allowing buildings to react intelligently to surrounding roads. Do not worry if you don't fully grasp how to write the code for this yet. These are concepts you will revisit and master once you become more comfortable with CGA rule scripting.

    The key takeaway for today is simply understanding what kind of Object Attributes are generated by analyzing the relationship between polygons and roads, and knowing that these attributes serve as the vital data foundation for your rule files.

    Next time, we will cover the remaining menus that we didn't have time to explore today. See you in Lecture 015!

    Next Post
    Related Posts

    If you have any questions, please leave a comment. Let's solve them together!


    [A Quiet Thought]

    "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice."
    — Christopher Alexander, A Pattern Language
    Continue Learning
    Explore complete tutorial collections for CityEngine and Global Mapper.

    Comments

    Popular posts from this blog

    029] How to Split Polygon Areas with Intersecting Lines in Global Mapper

    [008] How to Understand CGA Rule Structure in CityEngine (Beginner Guide)

    046] How to Create Parallel Offset Lines in Global Mapper