embedding attributes into .obj in Maya...or Max Is it possible?

3390
11
09-12-2012 08:03 AM
SahakSahakian
New Contributor
Hi.

I wonder if there is a way to add attribute such as building height or roof type onto footprint .obj files from within Maya or Max?

How does one go about adding an attribute that City Engine can read/show and be usable like shown in the tutorial files?

Does it have to be in shape format? And if there are other software that allow for adding this attribute before importing?

Is there tutorials that show how one can add building height attribute to a polygonal building footprint before importing to City Engine?

EDIT: I did some searching and found out that these attributes live in an external to the polygons database, table.dbf file. Is there scripts or exporters that anyone is aware of that allows these attributes ( buildingHeight, buildingType ) to be added and exported from within Maya, Max, Sketchup?

Thank you.
0 Kudos
11 Replies
MatthiasBuehler1
Frequent Contributor
hi !

yes, .shp, file .gdb or .osm allow you to import such attributed.

.obj / .dae / .fbx cannot be used for this.

you could use Python scripting to assign specific attributes to specific shapes though.
0 Kudos
SahakSahakian
New Contributor
hi !

yes, .shp, file .gdb or .osm allow you to import such attributed.

.obj / .dae / .fbx cannot be used for this.

you could use Python scripting to assign specific attributes to specific shapes though.



Thank you for hopeful reply.

Forgive my lack of in depth knowledge on inner workings of attributes between software.

Is it possible to write a Python script (with a GUI) that enables
assignment of specific attributes to (selected) polygonal shapes inside of Maya
and export a .gdb file to later tie it to imported .obj files? Or would one also need to
write a .shp exporter?  

If yes. How wold the workflow be?

Could you please sketch out a rough guide to steps involved in such process?
I have a set of building footprints in Maya that have no attributes associated to them.
And I want to be able to import them and use attributes for building height etc. for generation of
models.

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

Another question is if it it possible to assign the attributes to imported or hand drawn footprints from within City Engine?
I guess one wold need to be able to generate the database .gdb file in City Engine....

If yes. How? Is there a tutorial on this that I have missed?

If no. Is there a guide (preferably a tutorial) on how does one assign the attributes and exports it out before importing it to City Engine?

And which software has features for assigning attributes and exporting .shp?

Esri Suite are a bit overwhelming for me at this point. And I haven't found a straight forward
explanation for this process. Please refer to or make a step by step tutorial (if possible) on how one does add attributes to shapes or imported polygons. I get lost in all the options, menus and complexity of ArcGIS. I only need to add attributes and export from it. Is there a tutorial on this?

I am hoping for a easy way to assign attributes to footprints and export it out for importing into City Engine. And footprints I have at his point are "dumb" polygonal objects in Maya...Please advice.

Thanks in advance.

S.
0 Kudos
MatthiasBuehler1
Frequent Contributor
When trying to bring attributed footprints from Maya to CityEngine, I'd try the following :


Write a MEL (or PY) script, which:
- grabs all vertices of the footprint
- grabs the xyz coordinated
- the attributes you want
- and spits out the Python code you can directly run in CE to :

- produce new footprints
- and assign the attributes.

I've done things like this before, so it's possible .. 😉

Are you fluent in MEL coding ? How about Python in CityEngine ?
0 Kudos
SahakSahakian
New Contributor
Thank heavens...

I wold not say I a fluent in MEL or Python, but with hard work I can find my way around using the help and Script Editor if I know what to look for 😛

Wold you be kind enough to share if possible the script(s) you used before so that I have some kind of a head start?

Would it be much easier if I were to draw the shapes directly inside of City Engine?
How wold I go about adding attributes to shapes drawn inside of City Engine?
I don't mind redrawing the footprints all over again, it might be less of a headache 😛

Cheers
S
0 Kudos
MatthiasBuehler1
Frequent Contributor
I guess it all also depends on what type of attributes you need.

In CityEngine, you can create attributes manually, create/set them with Python or set them with images via Map Layers. E.g. use a bitmap's brightness to drive values between 50 and 200 or whatever.

Let me know what precise attributes you need, then I may think of something more intuitive.


Cheers !

Matt
0 Kudos
SahakSahakian
New Contributor
For now it is enough with building height and roof type and street width..

The building heights are known values so imageLayer route would not be useful.

Perhaps set them with Python.

Is it to follow the Python scripting page in the manual and do? :


>>>
//Assuming a block is selected


>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.setAttribute(block,"/ce/block/shapeCreation", False)
>>> ce.setAttributeSource(block,"/ce/block/shapeCreation", "USER")
>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.setAttribute(block,"buildingHeight", 27)

//??

Does this generate a .gdb file or is the attribute than handled internally?

Cheers!

Hopefully it will get me started to do more advanced...
0 Kudos
MatthiasBuehler1
Frequent Contributor
this code just sets an attribute value to 27 on a block. that does not export anything.

other question:

how does that height information get into Maya ? do you define the values there or do you otherwise import it there ?

I just need to know the desired pipeline better.
0 Kudos
SahakSahakian
New Contributor
The height information in Maya is from building models from Google Warehouse.

I want to proceduralise those models. To be able to Rule  😜

And later to export through Python for importing into a game engine. Most likely UDK.

Cheers
0 Kudos
MatthiasBuehler1
Frequent Contributor
how do you actually store the attribute ?

I assume you have 1 mesh for each building footprint which contains e.g. an 'Extra Attribute'. (?)

m.
0 Kudos