Select to view content in your preferred language

Assign color depending on a part of an object attribute string

4160
3
01-26-2015 06:27 AM
KennethLindhardt
Deactivated User

Hi all,

I’m looking for a way to search on a part of an object attributes string, and the assign a color. I’ve been working on importing IFC into CE thru ArcMap, and it works, but I would like to create a rule that color the objects depending on some of the text in the object attributes. Normally, if you got a wall, Wall will be a part of the Object type name like: “Basic Wall:Foundation - 305 Concrete:29243” or “Basic Wall:CORR:145059”

If I would like every Shape containing Wall in the string to be white, but any Shape containing “Glazed” to be blue, could I do that in a rule? 

0 Kudos
3 Replies
MatthiasBuehler
Deactivated User

hey ..

use string lists.

they're described in CGA docs. check out the CGA file where they are defined in the ce.lib project's rules directory. file called _ce_.cga

Note this project can be shown in CE:

Navigator > White triangle window > Customize View .. > UNcheck CityEngine 'Hide library'

Matt

Matthias Buehler

Head of 3D Technologies

twitter: @MattB3D

-----------------------------------

Garsdale Design Limited

matthias.buehler@garsdaledesign.co.uk

www.garsdaledesign.co.uk

0 Kudos
by Anonymous User
Not applicable

Yes, this is possible, and frequently used in our example rules. Start by looking at the CGA operation "subString" then the related functions listed. If that doesn't get you results, then come back and post again. You will need a delimiter in the string to surround your values with.

0 Kudos
KennethLindhardt
Deactivated User

Thanks,

I’m sorry guys, I have been through the help file the String Utility Functions, String Functions and String List Utility Functions, and I can’t not come from what I’m reading, to what I need. I’m probably misunderstanding the help file.

To summarize what I see:

subString:

                      Will take a value between the positions you describe ex. Lets say exterior wall is the input from the attr substring("exterior Wall", 8, 12)= Wall, but if the input is “Brick Wall” the 8 to 12 won’t get me wall.

Find:

                             Seems to would be what I’m looking for, if I could create them like case in an attr, but that don’t seems to be possible. And then it will calculate how many times wall will be in a string. In some cases I could expect wall multiply times in a string.

Without being right, this is what I’m looking for:

                            

                             @range(“Wall”,”Glazed”)

                             Attr ObjectType = “Wall”

                             Attr Blah =

                                                          Case ObjectType == “*Wall*” : color(“Green”)

                                                          Case ObjecyType == “*Glazed*” : color(“blue”)

                                                          Else : something

The * being a wildcard, so there could be anything in front and after.

Did I explain my self probably the first time, or am I totally misunderstanding you and the helpfile 😉

Nice with the _ce_.cga, I will defiantly have a look of what is going on in those files 

0 Kudos