Create list index from values

1915
9
08-11-2021 08:05 AM
KennethLindhardt1
Occasional Contributor II

Well the subject is not perfect created 🙂

Hi everyone, I have something I can't wrap my head around.

The core model is not created from CityEngine, but is an shapefile import from a CAD system, so it's presplit. 

So I have all the floors split out before going into CityEngine and I want to create a floor index, the lowest floor index = 0 and then going up.

I can filter it out, so I can print the height from the terrain. so I need 3 meters to be index "0", 6 meters to be "1"

and so on.

Can this be accomplished ?

The screenshot is from a very simple model. Other models also has the floor split in X/Z direction, they are not all equal 3 meters in floor height.

So I need it to be lowest height from ground index 0, next lowest height index 1 and so on.
ElevatioIndex.png

Thanks.

0 Kudos
9 Replies
plfontes
New Contributor III

I'm not sure if I've got your question right, but you can assign an attribute 'index' for each feature (floor) in your shapefile before importing to CE and then use this as the object attribute within CE for your height calculations (assuming these are imported as separate shapes/models) .
I hope this helps.

0 Kudos
KennethLindhardt1
Occasional Contributor II

Thank you plfontes, I think that you got my question right, however in this particular workflow I'm trying to get to work, the input are from multiple architects, and I don't want to do this manually and I can't ask the architects about doing this before they deliver, then I would need to explain it every time.

So I would really need it to understand the sort order from the terrain. 

0 Kudos
by Anonymous User
Not applicable

Thinking through this some, if your model is as simple as that photo, I'd probably start with seeing if I could:

https://doc.arcgis.com/en/cityengine/latest/cga/cga-comp-function.htm

 

const Floor_Index = comp(f){horizontal :  comp.index}

Building --> print(Floor_Index)

 

 

See if that matches the # floors you have.   You can then set up a more detailed matrix with height above terrain.

0 Kudos
KennethLindhardt1
Occasional Contributor II

Thanks Brian, unfortunately the models are not that simple.

Since it's divided into sub units, departments and stuff, the comp split will create an index for each unit, and not only the floor. I also need the index the facades the same way, and in this simple case, it would then give me 4 comp.index for the ground floor.

Thank you

0 Kudos
by Anonymous User
Not applicable

I think you could work with that for setting up an array manually.   The comp.index may reference the sub-shapes of each floor but you can manually input the floor.index into a new array.   

 

const SubShape_Index = comp(f){horizontal :  comp.index}

Building --> print(SubShape_Index)

=[1,
  2,
  3,
  etc.]

 

If the comp.index from your model isn't too large, I'd manually setup the array using that info, with comp.index on the left, and floor.index manually inputted on the right.

 

Floor_Index = 
[1,1,
2,1,
3,1,
4,1,
5,2,
6,2,
7,2,
8,2,
etc.]

 

 Possibly use Microsoft Excel to speed up this process since it has predictive text for pattern recognition.  Using this array you could gather information on both the subshape index and the floor index.  Your next step would be to access each column in array for further functions.

Here is how that is done:

https://doc.arcgis.com/en/cityengine/latest/tutorials/tutorial-21-csv-import.htm

 

0 Kudos
by Anonymous User
Not applicable

Also, another strategy might work: 

This one would allow you to color the floors vertically, whereas, the above strategy would allow you to gather data about the floors.   You could integrate both into one code to meet separate projects goals.   With this one, you could still try doing a comp(f){horizontal...} to see if it catches the horizontal floors within that split (if you needed too).

 

 

attr FloorHeight = 3

Building-->
      split(y){FloorHeight: Floor(split.index)}*

Floor(ind)-->
      your next function for each indexed floor

 

 

 

0 Kudos
KennethLindhardt1
Occasional Contributor II

Hi Brian, sorry for the late reply, I appreciate you effort. The situation is that the comp, don't create the index in the right way always, when it's not create with CE. So the top floor would have a lower index. I'll check if I somehow can split in y and get the index, It totally make sense, however I think it will be a bit difficult to get to work, the way the models are structure. Thanks you so much, I'll right a reply with my recursion thought, maybe someone can see what I'm missing 😉

0 Kudos
KennethLindhardt1
Occasional Contributor II

I had hope to be able to use a recursion, but I can't get that to work as intended.

My first thought was to  look at creating a list, but I can't see how that should be done.

I'm confident that it is possible, but still struggling with it 🙂

0 Kudos
KennethLindhardt1
Occasional Contributor II

So my thoight with doing a recursion is to get the floors into the right order, so by doing something like the one below, I will take the lowest floor and pass through to Next() Right now I'm passing through a zero (0) on each of the floors going through. I need the zero to raise by one every time it comes through the Next rule, and I would actually also like it to print out how many times it's looping through the Next rule.

Right now I'm looping through the floors 1 meter at the time 20 times, but only 6 floors are passing through the loop, since they match the meterMeasure. 

ListEscape(floorHeight,BlHeight,meterMeasure) -->
	case meterMeasure == floorHeight :  Next(floorHeight,BlHeight,meterMeasure,0)
			else : listRecursion(floorHeight,BlHeight,meterMeasure)
		
listRecursion(floorHeight,BlHeight,meterMeasure) -->
			case meterMeasure == 20 : NIL
				else : ListEscape(floorHeight,BlHeight,meterMeasure+1) 
		
		
Next(floorHeight,BlHeight,meterMeasure,ZeroIndex) -->

	Next2(ZeroIndex)

 

0 Kudos