Extrude polygons in City Engine depending of their type attribute

4909
8
Jump to solution
09-01-2014 03:00 AM
IonutAlixandroae
Occasional Contributor

Hello,

I have downloaded some polygons from OSM and in their attributes table is a field named TYPE. I have populated that field with 2 types : blocks and houses.

I have imported the shapes into City Engine and after started a new cga rule. I set a Minimum Height of 30 and a Maximum Height of 50. Depending of their type I want to extrude my polygons : houses = 30 and blocks = 50.

My cga rule doesn`t work. Also, the source for type is the object attributes.

Could you help me please?

P.S.: the rule looks like this :

attr Type = "type"

attr MinHeight = 30

attr MaxHeight = 50

Footprint (type) -->

  case type == "bloc" : extrude (world.y, 50) Mass

  case type == "casa" : extrude (world.y, 30) Mass

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

You attribute value is lower case "bloc", but in the case structure, you are testing for upper case "Bloc". Everything is case sensitive. It is going to NIL in the else case.

Chris

View solution in original post

8 Replies
by Anonymous User
Not applicable

Hi,

This rule won't work, because the start rule (Footprint) cannot be parameterized with (type):

1. Change:  "Footprint (type) -->"  to  "Footprint -->" (does not need to be parameterized, since the Type attribute is like a global variable that is already visible anywhere in the rule.)

2. Change:   case type == "bloc"   to   case Type == "bloc", since Type is the case-specific attribute you are testing.

Does this work?

Chris

IonutAlixandroae
Occasional Contributor

I will try this immediately.

Another question if you could help me:

Let`s say that I have 2 types of attributes in my polygon attributes table : "blocks" and "houses" and I have already created 2 cga. rules named the same for those 2 types of buildings.

How should I write a new rule that in function of those 2 types of attributes, on those polygons would apply the another 2 types of rules?

( For those polygons that have "blocks" in attribute table to apply the "block" rule and for houses the same)

Thank you !

0 Kudos
by Anonymous User
Not applicable

If you already have two rules for each type you can use this (but both rules' Inspectors will be visible, which is not an intuitive UI):

import block: "Block.cga"

import house: "House.cga"

@Range("Block", "House")

attr Type = "Block"

BuildingFootprint -->

     case Type == "Block": block.YourBlockStartRule

     case Type == "House": house.YourHouseStartRule

     else: NIL

by Anonymous User
Not applicable

Also, you must have an "else" case for each case structure.

IonutAlixandroae
Occasional Contributor

import bloc : "Blocuri.cga"

import casa : "Case.cga"

@Range("bloc", "casa")

attr Type = "bloc"

Cladiri -->

  case Type == "Bloc":bloc.Bloc

  case Type == "Casa":casa.Casa1

  else : NIL

I`m not sure why is not working. I attached a print.Cladiri.jpg

0 Kudos
by Anonymous User
Not applicable

You attribute value is lower case "bloc", but in the case structure, you are testing for upper case "Bloc". Everything is case sensitive. It is going to NIL in the else case.

Chris

IonutAlixandroae
Occasional Contributor

Thank you !!

Ionut

0 Kudos
by Anonymous User
Not applicable

Thanks!

0 Kudos