Access to Meshes with Python

538
6
12-04-2012 12:12 AM
UrbanoDaniel
New Contributor
Hi,

I'm using a licensed version of CityEngine (Esri CityEngine 2012.1 build 120913 (release, win32-64bit)) which is registered to a Japanese account.

After using a cga-rule file to generate a shape I want to access the generated information in the Scene.

You help is much appreciated.
Tags (3)
0 Kudos
6 Replies
MatthiasBuehler1
Frequent Contributor II
Hi !

I need a little more info on what you need to do.

Select the objects ? Get reports ? ..

Did you see those :

http://video.arcgis.com/watch/1778/tutorial-10-python-scripting
http://video.arcgis.com/watch/1780/tutorial-12-scripted-report-export

?
0 Kudos
UrbanoDaniel
New Contributor
Hi,

I hope the picture helps understanding what I want. The left side in it shows for example a street before generating the models. There I have the information about the vertices of the edges of the highlighted shape.
The right side shows the street after generating the model of the shape. There I also want access to the information about the vertices required to separate the different textures of the street.

These information have to be somewhere since they are available to for example Unity (as Meshes) after exporting. I however want to access these information in CityEngine either with a main-script, or with an export-script.

Again, You help is much appreciated.
0 Kudos
MatthiasBuehler1
Frequent Contributor II
Hi.

To get those vertex coordinates you best use CGA's convert() function.

Check the docs on it.

So what I'd do is :

Cut the street geometry a little further until you basically have a tiny shape ( 1 x 1 cm) and then use convert() to get the desired coordinates.

Question : How precise do you need those positions ? Within 'millimeter range' or 'as precise as it gets' ?

Depending on that answer, strategies are a little different.


Cheers !

Matt
0 Kudos
UrbanoDaniel
New Contributor
Hi,

Thank you for your suggestion. Your help is much appreciated.

I would very much like to stay independent of the cga rule file for this.

As for the accuracy: I would like to get those meshes with its triangles, textures and uv-mapping in a similar accuracy as I would get them after exporting the whole thing to FXB and reading them from there.

I guess my problem is a little special.

I hope there is a solution to this.

Yet again, You help is much appreciated.
0 Kudos
MatthiasBuehler1
Frequent Contributor II
Hi !

The problem is that once the model is generated with CGA you have no more metadata available and 'just' a 3d mesh with a certain topology which you can not query with a certain intelligence.

Of course you can get the list of vertices for the mesh, but this helps nothing because you need the geometric metadata.

If your usecase is sensitive, feel free to PM me, I'll treat the stuff of course confidential. Maybe if I understand your needs better I can help further.

The road I described will provide you with very precise vertex positions, possibly also other data you need.

Let me know.

Matt
0 Kudos
RobertHexter
New Contributor III
The reporting mechanisms are your main access to data on a shape. You need to use cga to put the required information into those reports. You can put many types of data into reports depending on how you break your model down.

Reports are attached to resulting shapes (the final generated shape) or shape leaf's as they are generated.

The data that is in a report can be effectively collected at export using the script based exporter.
From experience I would advise you use the uuid's that are available for most things, record those into the report as the main method of data association.

Within the script based exporter you can create complex python data structures to store information extracted from those reports.
The information can then be written out too, for example, xml or Jason. As python works with these quite nicely.

You could then write a parser/reader script in Unity to parse the output xml report data and do the application functions I think you are aiming to do, for shader assignments and texture hookups etc.
0 Kudos