output order of the console

516
2
09-16-2023 06:24 PM
Status: Already Offered
desert
by
New Contributor III

hello. CityEngine Developers


I'm a newbie who recently started studying CGA.
I am practicing coding while watching the console window.

I noticed something strange.

Below is the code I wrote to see how the rule works.

 

Lot -->
	split(x){
		'.5 : print("1st") A |
		'.5 : print("2nd") B C
	}

A -->
	print("3rd")
	B
	C

B -->
	print("4th")
	

C -->
	print("5th") 

 

 

Let's look at the console output

 

1st
2nd
3rd
4th
5th
4th
5th

 

 

The console output from CityEngine looks like this

desert_0-1694912171093.png

The output is not what I expected.

 

Here's what I expected to see

 

1st
3rd
4th
5th
2nd
4th
5th

 

desert_1-1694912593814.png

The concept of CGA is procedural modeling, but the console does not follow the procedural concept.

 

You need to adjust the output order of the console.

It would be nice to be able to output additional messages to the console.
For example, displaying a "rule ended" message when there are no more subrules.

 

#rule started
1st
3rd
4th
5th
#rule ended

#rule started
2nd
4th
#rule ended

#rule started
5th
#rule ended

 

 

Also, I would like to see an "attribute value trace" button in the console window so I can see how the values of the declared variables are changing over the course of the rule. 

desert_1-1694933581573.png

 

Thank you!

Tags (1)
2 Comments
JonasObertuefer

Hi @desert,

Thanks for your question/idea.

Regarding the console output order:

While it is guranteed that always the same shapetree (which you see in the Model Hierachy) is generated, no particular order is guaranteed in which the print output of the rules appear in the console.  What you see in your nice picture is a breath-first order; your expectation is depth-first. None of them is right or wrong. In general you can not rely on a particular order here, in some situations (such as occlusion handling) this order might change.

Regarding "attribute value trace":

This is already possible. When you click on a specific shape in the shape tree of the Model Hierarchy a table of all attributes/values that the shape at that point has is displayed in the inspector:

modelHierarchyDisplayShapeAttributes.gif

Best,
Jonas

JonasObertuefer
Status changed to: Already Offered