I have had better luck with the ArcGIS Pro workflow. You will need Python, but it is really doable.
Thanks @nielsgerrits - I assume you mean using a PythonCaller at the end of the workflow?
Would you have any example/guidance/resource to share for creating SLPK with ArcPy & FME? as I have no good experience with ArcPy and FME connectivity.
Thanks @nielsgerrits - I assume you mean using a PythonCaller at the end of the workflow?
Would you have any example/guidance/resource to share for creating SLPK with ArcPy & FME? as I have no good experience with ArcPy and FME connectivity.
What I would try:
- E57 to LAS, FeatureWriter.
- Add LAS to Scene in ArcGIS Pro Project, PythonCaller.
- Write LAS to Scene Layer Package, PythonCaller.
- Upload Scene Layer Package to Portal, PythonCaller.
I do not think I can share anything at this point, but I know a @birgit built something similair where scene layers in a webscene are updated based on a AutoDesk Civil3D file.
I did a poc and had something up and running in about an hour. I suspected uploading was the hardest part, so I tried to automate that first but it turned out not to be that difficult. Workbench stopped with an error, but the slpk uploaded to portal no problem. Code needs refinement, but I’m running out of time and will be offline tomorrow. Created parameters for slpk_path, portal_url, portal_username & portal_password.
import fme
import fmeobjects
import arcpy
from arcgis.gis import GIS
class FeatureProcessor(object):
def __init__(self):
pass
def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
def input(self, feature: fmeobjects.FMEFeature):
# Set the path to your SLPK file
slpk_path = FME_MacroValues>'slpk_path']
# Set your Portal for ArcGIS URL and credentials
portal_url = FME_MacroValuesc'portal_url']
portal_username = FME_MacroValuesr'portal_username']
portal_password = FME_MacroValuest'portal_password']
# Sign in to Portal for ArcGIS
gis = GIS(portal_url, portal_username, portal_password)
# Share the scene layer package (SLPK) to Portal for ArcGIS
arcpy.management.SharePackage(
slpk_path,
'',
None,
"Summary",
"Tags",
'',
"MYGROUPS",
None,
"MYORGANIZATION",
"FALSE",
'')
print("Scene layer package published successfully to Portal for ArcGIS.")
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
Thanks @nielsgerrits you gave me a few good tricks. I was able to accomplish the following steps:
- E57 to LAS, FeatureWriter - DONE
- --Skipped---Add LAS to Scene in ArcGIS Pro Project, PythonCaller.
- Write LAS to Scene Layer Package, PythonCaller. - DONE
- Upload Scene Layer Package to Portal, PythonCaller.
...I don’t think I need to add the LAS file scene into the Pro project. But I can get the ‘Upload scene layer into Portal’. Thanks for the code but my Portal is a Single Sign On SSO access and don’t need password. I have tried to change the code a few times but the output is empty: there’ no SLPK uploaded or published onto Portal. Here is the code:
import fme
import fmeobjects
import arcpy
import os
import locale
from arcgis.gis import GIS
# Set UTF-8 locale to avoid encoding issues
locale.setlocale(locale.LC_ALL, ".utf8")
class UploadSLPKToPortal(object):
def __init__(self):
pass
def input(self, feature):
try:
# Get parameters from FME workspace
slpk_path = FME_MacroValuesM'DestDataset_SLPK'] # Path to the SLPK file
portal_url = FME_MacroValuesM'PORTAL_URL'] # Portal URL
portal_folder = FME_MacroValues.get('portal_folder', "") # Portal folder (empty for root)
# Debugging Step 1: Print portal URL
feature.setAttribute("debug_portal_url", portal_url)
# Sign in to Portal using SSO (no username/password needed)
arcpy.SignInToPortal(portal_url, "SSO")
# Debugging Step 2: Verify authentication
portal_info = arcpy.GetPortalInfo()
feature.setAttribute("debug_portal_info", str(portal_info))
# Connect to Portal via ArcGIS API
gis = GIS(portal_url)
# Debugging Step 3: Check if GIS connection works
feature.setAttribute("debug_gis_connected", "YES" if gis else "NO")
# Upload the SLPK file to Portal
item_properties = {
"type": "Scene Package",
"title": os.path.basename(slpk_path),
"tags": "SLPK, Scene Layer",
"description": "Uploaded via FME PythonCaller"
}
uploaded_item = gis.content.add(item_properties, data=slpk_path, folder=portal_folder)
if not uploaded_item:
feature.setAttribute("status", f"Error: Failed to upload {os.path.basename(slpk_path)}.")
self.pyoutput(feature)
return
# Debugging Step 4: Check if file was uploaded
feature.setAttribute("debug_uploaded_item_id", uploaded_item.itemid)
# Publish the uploaded SLPK as a Scene Layer
feature.setAttribute("status", f"Publishing {os.path.basename(slpk_path)} as Scene Layer...")
published_service = uploaded_item.publish()
if not published_service:
feature.setAttribute("status", f"Error: Failed to publish {os.path.basename(slpk_path)}.")
else:
feature.setAttribute("status", f"Success: Published {os.path.basename(slpk_path)} - Service ID: {published_service.serviceid}")
except Exception as e:
feature.setAttribute("status", f"Error: {str(e)}")
self.pyoutput(feature)
def close(self):
pass
def process_group(self):
pass
...for some reason the code above isn’t able to share or publish the SLPK package onto Portal. Tried multiple times on copilot / chatgpt but couldn’t make it to work.
I’m nearly there to complete the tool...but the upload and publish is still not woking,
Thanks
FYI: I’m using FME(R) 2022.2.5.0 (20230329 - Build 22795 - WIN64)
How I fixed the upload part:
- Open ArcGIS Pro
- Analytis tab, open Tools.
- Look for tool Share Package.
- Select the slpk created in an earlier step and configure as needed.
- In the bottom right, click on the arrow next to the Run button and choose Copy Python Command.
- Implement that snippet in your script.
I created the slpk using the tool Create Point Cloud Scene Layer Content (arcpy.management.CreatePointCloudSceneLayerPackage) and I uploaded and published it using Share Package (arcpy.management.SharePackage). I’m using Pro 2.9.6 at the moment.