Export Selections Sets via Python?

2769
3
06-08-2016 02:52 PM
ThomasMoore6
New Contributor II

I'm looking to batch export my Selection Sets so that each set is it's own export. I cannot find in the documentation whether this is something that can be done, or how to do it.

To be specific, my plan was to create an array with all the selection set names, then use a simple for loop to go through the array. If anyone knows how, I would much appreciate it.

Thanks in advance.

0 Kudos
3 Replies
LR
by
Occasional Contributor III

You can do script-based exporting*. I did some selection based exporting myself but don't recall being able to pick selection sets. Instead I gave all shapes in the different sets the same Name and used that to selected them (ce.getObjectsFrom --> ce.withName).

* http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/manual/export/expor...

0 Kudos
ThomasMoore6
New Contributor II

I, too, have tried this, but it never works. A lot of my python export scripts never work. Maybe you can spot what I'm doing wrong in the code below, which has been altered to fit this situation better.

    exportSettings = FBXExportModelSettings()
    exportSettings.setOutputPath("path to my exports")
    exportSettings.getMeshGranularity("PER_MATERIAL")
    exportSettings.setGlobalOffset([-322000, 0, 4306000])
    shapes = ce.getObjectsFrom(ce.scene, ce.withName("'Buildings_1'"))
    exportSettings.setBaseName("Buildings_1")
    ce.export(shapes, exportSettings)

If I feed this exact script line by line into the console, it works, but doesn't select via the name and exports whatever is selected.

0 Kudos
LR
by
Occasional Contributor III

You have to set the selection, under line 5 add this:

ce.setSelection(shapes)