AnsweredAssumed Answered

How to correctly import a file, which is defined via the attributes?

Question asked by tobias.cervenka on Apr 8, 2016
Latest reply on Apr 10, 2016 by raze

Hello everybody


First of all: I'm a new user of CityEngine, so maybe this is a very basic question.. but I wasn't albe to find a good solution so far, that's the reason for my post here ;-)

I would like to create buildings with ground- and upperfloors (so that I can combine the groundfloors randomly with the upperfloors). For this, I created the CGA-Files with the help of the Facade Wizard. These rule files provide the upperfloor rules only, the groundfloors are definied in different rule files.


At the moment, I wrote the following CGA-Code to divide the buildings into a ground- and upperfloor. It would be now possible to import a specific rule file for the groundfloors (by using the command import i : "name.cga"). What I would like to do is, that I can change the rule files for the groundfloors via the attributes (so I don't need to go into every rule file and change the name manually). Is that even possible?



attr Building_Height = 25

attr GroundFloorHeight = 5

attr UpperFloorHeight = 3

attr UpperFloorRule = "name.cga"


import i : UpperFloorRule #this one does not work, it should just give you an idea what I want to do: importing the cga-file, which was entered in the attribute part (in this case: "name.cga"). It would work with "import i : name.cga" though.



    extrude (world.y, Building_Height) Building

Building -->

    split(y){GroundFloorHeight: GF | {~UpperFloorHeight: UF}* }


    extrude (world.y, GroundFloorHeight)

    comp(f) {side: i.Facade}


    extrude (world.y, UpperFloorHeight)

    comp(f) {side: Facade}

=============End of Code=============


Thanks very much for your inputs. Have a nice weekend.



EDIT: this is not the complete code (just because of "End of Code"), the Facade rule is defined in the same file (but not displayed here)