Exporting object attributes from CityEngine to Scene Layer Package problem

3255
7
05-13-2017 01:04 PM
RonYu
by
New Contributor

Hi,

   I want to export building models from CityEngine to Scene Layer Package format, so I can upload them onto Esri cloud service. After uploading the SPK file onto Esri cloud service, I use Scene Viewer to open the file. 

   For each building model in CityEngine, I added object attributes and I want to have these object attributes available in scene viewer's popup window. I used Report feature in CityEngine to export these object attributes. 

   Then I got this problem, when I open the SPK file in Scene Viewer. I can see the object attribute fields in the popup window, but the values are not correct. 

I have tried different scenarios: 

Multiple building models in one SPK,

   I have one shape layer in CityEngine which has 10 building models. I want to export this shape layer to a single SPK file. All these building models have the same attribute fields and each building model has its own values. I exported these buildings into one SPK file (SPK1).  Then I uploaded and opened SPK1 in Scene Viewer, this SPK1 has all the building information correctly linked to each building. Then I modified one of the object attribute values of a building and exported these buildings into a new SPK file (SPK2). After uploaded and opened SPK2 in Scene Viewer, all building information were changed, some buildings have no value; some building have incorrect values shown up in popup window; some building information are duplicated on different buildings. 

   I also tried to upload 2 or 3 buildings models together, but when I opened it in Scene Viewer, object attributes were still wrong. 

   One time I exported three SPK files for a same set of building models, I uploaded and opened them in Scene Viewer. All Building information are mismatched. Even I clicked on the same building, the attribute values shown in popup window are different between each SPK file. 

One building model in one SPK,

   In my CityEngine's scene, I have 110 building models. I picked few building models and exported them into separate SPK files. Then I uploaded these SPK files onto Esri cloud service. I checked each SPK file separately in Scene Viewer, their object attributes are correctly shown in the popup window.  If I use this method to export, then I will have 110 SPK files, which makes no sense.

   So my problem is I want to export multiple building models with object attributes from CityEngine to SPK format, so I can view building information in popup windows in Scene Viewer. 

Can somebody please help me to solve this problem?

Thank you very much.

Sincerely,

Ron

0 Kudos
7 Replies
CherylLau
Esri Regular Contributor

Maybe there are export options that could help get the desired numbers?

There is an export option Feature Granularity that has two options:

* One Feature Per Shape

* One Feature Per Leaf Shape

Imagine that you have initial 2D shape for the building footprint onto which you apply a rule that creates buildings with floors.  On each floor, the area of that floor is reported.  The first option will export one report for each building that is the sum of the floor areas of the building (GFA).  The second option lets you export a report per leaf shape.  If the floors are the leaf shapes, the area of each floor is reported separately for each floor, so if you click on the third floor, the popup will tell you the area of the third floor.  If you click on the seventh floor, then you'll get the area for the seventh floor.  The numbers you see in the popup depend on the export options and also on how you set up your reports in the rules.

Esri Scene Layer Package (spk) Export 

RonYu
by
New Contributor

I tried using "One Feature Per Leaf Shape" option while exporting, however, all object attributes are still incorrect when I opened the file in Scene Viewer. 

0 Kudos
CherylLau
Esri Regular Contributor

I'm not sure why the numbers are incorrect.  I've created a simple example in which I applied the following rule to two buildings.  I selected both buildings and exported them to a single spk using "One Feature Per Leaf Shape", uploaded the spk to my agol account, and published it as a scene layer.  In the scene viewer, when clicking on a floor of either building, a popup window displays the floor number and the area of the floor.  In CityEngine, I printed the floor areas of each floor, and the numbers in the Console match the numbers in the Scene Viewer.  Does this code also work for you?

attr height = 20
attr floor_height = 4

Lot -->
     extrude(height)
     split(y) { ~floor_height: Floor }*
     
Floor -->
     s(scope.sx - 0.5*scope.sx*split.index/split.total, '1, scope.sz - 0.5*scope.sz*split.index/split.total)
     center(xz)
     report("Floor Number", split.index+1)
     report("Floor Area", geometry.area(bottom))
     print(split.index+1 + ":\t" + geometry.area(bottom))

Here are some other notes that might help:

* When changing the height of my building in CityEngine, I needed to make sure the models were regenerated, export the spk again, upload the spk again, delete the old published scene layer, and publish the new spk again.  The scene layer did not automatically update.  I needed to delete the old one first and then publish again.

* Rule attributes and object attributes (as seen in the Inspector) are not exported to the spk.  Only values that are reported in the code are exported.

0 Kudos
RonYu
by
New Contributor

Here is my rule files look like: 

buildingRules.cga

version "2016.1"
import Default : "/ESRI.lib/rules/Buildings/Building_From_OpenStreetMap.cga"
import Report : "rules/reportAttr.cga"
attr Levels= 0
@StartRule 
Generate -->
 Report.Report
 Default.Generate‍‍‍‍‍‍‍‍

reportAttr.cga

version "2016.1"

attr name = ""
attr levels = 0
attr indoorModels = false
attr indoorLevels = ""

@StartRule     
Report -->
     report("name", name)
     report("levels", levels)
     report("indoorModels", indoorModels)
     report("indoorLevels", indoorLevels)
     
     ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The building rule is used to generate buildings from footprints and report its object attributes. 

Attributes in the reportAttr.cga are added using Object Attribute Panel in Inspector. 

Below is the screenshot of cityEngine showing all object attributes are correctly connected with attributes in the Rule files. 

When uploading SPK onto Esri cloud, I always delete the old one with the same filename before uploading. 

0 Kudos
CherylLau
Esri Regular Contributor

I cannot reproduce the problem.  Exporting after changing object attributes works for me.  I started with the 5 object attributes in your screenshot and set different values for them for each building.  I exported this to an spk (with one feature per shape), and the popups displayed the correct reported info.  Then, I changed the object attributes Report.indoorLevels, Report.levels, and Report.name for one of the buildings, regenerated all models, and exported again to a new spk.  The second export also worked, and the popups display the changed info for the changed building, and the other buildings are also correct.

On the second export screen, sometimes you don't see the options.  Just click Back once and then Next to get them to appear.  Then, click finish.

Did the simple example above work for you?  Set the height to different values for each building.

https://community.esri.com/message/687983-re-exporting-object-attributes-from-cityengine-to-scene-la... 

0 Kudos
TessOldemeyer
Occasional Contributor

From * Rule attributes and object attributes (as seen in the Inspector) are not exported to the spk.  Only values that are reported in the code are exported:

Is there a straightforward way to export all model attributes (one feature per shape) to a slpk?

0 Kudos
CherylLau
Esri Regular Contributor

Yes and no.  No, you cannot export rule attributes or object attributes directly through export dialog window.  However, yes, you can export them by writing reports that report the values you desire to be exported.

This is done this way so that the user has control over which object attributes and/or rule attributes are visible in the scene created by an slpk.  Often users do not want the scenes cluttered with all the object attributes in the shape.  This way the user can write reports to report the desired values with the desired names for those values.  Yes, it requires more work to write the reports if you want all attributes reported, but it gives the user more flexibility in choosing what values should be exported and visible.