Select to view content in your preferred language

Adding 3D Tiles to a Map/Scene via AddDataFromPath

1471
9
04-02-2024 10:25 AM
Labels (2)
Will_geoacuity
Emerging Contributor

In ArcGIS 3.2.2, I am trying to create a toolbox that would occasionally output a 3D Tiles file (in .3tz format). Using the AddDataFromPath method gives an error.

 

Here is my sample code done in the Python Window

import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
active_map = aprx.activeMap
arcpy.env.addOutputsToMap = True
active_map.addDataFromPath(r"path/to/3Dtiles.3tz")

And I get the following error (on both maps and scenes):

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
return fn(*args, **kw)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 3744, in addDataFromPath
return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path, web_service_type, custom_parameters,), True)))
RuntimeError: Failed to add data. Possible credentials issue.

I can successfully add the same .3tz file via the Add Data From Path buttons on the ribbon, but I wish to make an automated Python tool. The AddDataFromPath method works with .slpk files. Is there a separate tool I should use for 3D Tiles? 

 

Thanks!

Will

9 Replies
Andrew--Johnson
Esri Regular Contributor

Hi,

This works successfully on my end. This error "RuntimeError: Failed to add data. Possible credentials issue." looks like a permissions error although it is interesting that it works when you do it yourself instead of python. Can you try copying the 3tz file to a different folder location in case it is a permissions issue?

thanks,

Andrew

0 Kudos
Will_geoacuity
Emerging Contributor

Hi Andrew,

I tried from another folder location and same error. I also ran the program as administrator and got the same error. Do you know which credentials might be referred to?

0 Kudos
Andrew--Johnson
Esri Regular Contributor

Hi,

Ok so I installed ArcGIS Pro 3.2 and can confirm that I can reproduce the error you are running into. Earlier I was testing on a 3.3 build. Bad news it does appear to be a bug in python. Good news it appears to be fixed in 3.3 which will (tentatively) be released to the public in May. I can see if there was an issue that the python team fixed that may provide a workaround for you in 3.2. Let me check and get back to you.

thanks,

Andrew

0 Kudos
Will_geoacuity
Emerging Contributor

Awesome! Thank you Andrew. Standing by for Python workaround, and I look forward to installing 3.3 when it comes out.

Best,

Will

0 Kudos
Will_geoacuity
Emerging Contributor

I am also working with geopackages (.gpkg) and getting a similar error with Python when adding from AddDataFromPath. Do you know if this gets solved in 3.3 as well?

0 Kudos
Andrew--Johnson
Esri Regular Contributor

Hi,

Yes it does work with geopackages too. Still waiting to hear back from arcpy team if there is a workaround. Will let you know as soon as I hear.

thanks,

Andrew

0 Kudos
Cary67
by
New Contributor

Bump.  I'm experiencing same issue.

Thanks!

jorisfrenkel
Frequent Contributor

Same here! Using Pro 3.1.1. 

A workaround is to use the addLayer request:

layer = "C:\\folder\\folder\\...\\PolyOut.shp"
lyr_result = arcpy.MakeFeatureLayer_management(layer, "Layer_Test").getOutput(0)

map.addLayer(lyr_result)

0 Kudos
FredericPoliart_EsriAU
Frequent Contributor

you cannot use relative paths, it is considered a security issue (it seems)
Put the full path to your .gdb or your .sde file 

0 Kudos