setGlobalOffset of python DAE export

701
2
Jump to solution
10-03-2018 08:17 AM
JDussault
New Contributor

I am trying to export a DAE centered at the point around a selection with a Python script.  When I do this manually with the export Wizard, I select "Center" to calculate the global offset.  The exported file then contains information with small numbers for the float_arrays, as it appears to have been centered correctly:

<float_array id="GeometrySource2-array" count="150">-1.274902462959289 0 5.1300048828125 -0.6110070943832397 0 4.382179498672486 -0.6110070943832397 2 4.382179498672486...[etc]</float_array>

When I imitate this with the following export options through python, it does not appear that the selection is being centered.  Can anyone advise me about the correct way to center a selection programmatically?

def exportDae(toExport, directory, name):
    settings = DAEExportModelSettings()
    # set the export path and name of associated files
    settings.setOutputPath(directory)
    settings.setBaseName(name)
    # beware, collada 1.5.x doesn't seem to work when exporting these
    settings.setCOLLADAVersion(colladaVersion)
    # create a node with shape's name
    settings.setCreateShapeGroups(True)
    # "Reuse asset instances, merge generated meshes by material"
    settings.setMeshGranularity("INSTANCED")
    # group by material type instead of with 5 billion little pieces
    settings.setMeshGranularity("PER_MATERIAL")

    # THESE ARE THE LINES WHERE I ATTEMPT TO CENTER THE SELECTION
    # "zero" the object(s) to remove geographic coordinates
    position = ce.getPosition(toExport)
    settings.setGlobalOffset(position)

    # export associated terrain
    settings.setTerrainLayers("TERRAIN_ALL_SELECTED")
    # export to a single file (instead of one per material)
    settings.setFileGranularity("MEMORY_BUDGET")
    # export the models but default to start shape if problem
    settings.setExportGeometry("MODEL_GEOMETRY_FALLBACK")
    # overwrite any existing files at that location!!!
    settings.setExistingFiles("OVERWRITE")
    # delineater for shape name clashes
    settings.setShapeNameDelimiter("_")
    # output log
    settings.setWriteLog(True)
    ce.export(toExport, settings)

This will contain float arrays with MUCH larger values, corresponding to the location of the shapefile, which indicates to me that "zeroing" my selection for the export was unsuccessful:

<float_array id="GeometrySource0-array" count="72">543176.7597654069 0 -3.281641101196114e6 543177.5401077866 0 -3.281641726548671e6 ...[etc]</float_array>

How can I implement the functionality of the "Center" button on the collada export dialogue in python?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
ThomasFuchs
Esri Regular Contributor

Thank you for your question.

The answer is, that the position needs to be subtracted to move the objects to the center.

    position = ce.getPosition(toExport)
    settings.setGlobalOffset([-position[0],-position[1],-position[2]])

View solution in original post

2 Replies
ThomasFuchs
Esri Regular Contributor

Thank you for your question.

The answer is, that the position needs to be subtracted to move the objects to the center.

    position = ce.getPosition(toExport)
    settings.setGlobalOffset([-position[0],-position[1],-position[2]])
JDussault
New Contributor

Thank you so much, that was the problem!! 

0 Kudos