Select to view content in your preferred language

Which Parameter data types in a Python toolbox For Selecting A Path

843
1
Jump to solution
06-19-2023 09:38 AM
BHK
by
Occasional Contributor

I need to select a SDE PATH based on user selection on Python toolbox at ArcGIS Pro 2.7.1 and use this path

fsnep

at the code for setting like

 

fc = 'Zone'
SDEDir = inputPath
arcpy.management.CalculateField(r"F:\\Pro\\AreaProject\\SEV_SDE.sde\\" + fc, 
                                "PROJECTT", 
                                ....
                                "PYTHON")

 

so the final code looks like

 

fc = 'Zone'
SDEDir = inputPath
arcpy.management.CalculateField(SDEDir  + fc, 
                                "PROJECTT", 
                                ....
                                "PYTHON")

 

Can you please let me know what data type I can use to grab the selected SDE Path? I already used File and Database Connection but they are not giving me the PATH

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor

Use a workspace and specify a remote database filter.  For a python toolbox (.pyt) this is:

 

import os
import arcpy

etc...

class Tool(object):

etc...

    def getParameterInfo(self):
        param0 = arcpy.Parameter(
            displayName="Input Workspace",
            name="in_workspace",
            datatype="DEWorkspace",
            parameterType="Required",
            direction="Input")
    
        # Set the filter to accept only remote/enterprise geodatabases
        param0.filter.list = ["Remote Database"]
    
        return [param0]
    
    def execute(self, parameters, messages):
        """The source code of the tool."""
        path = parameters[0].valueAsText
        fc = "Zone"
        fc_path = os.path.join(path, fc)

 

 

 

View solution in original post

1 Reply
Luke_Pinner
MVP Regular Contributor

Use a workspace and specify a remote database filter.  For a python toolbox (.pyt) this is:

 

import os
import arcpy

etc...

class Tool(object):

etc...

    def getParameterInfo(self):
        param0 = arcpy.Parameter(
            displayName="Input Workspace",
            name="in_workspace",
            datatype="DEWorkspace",
            parameterType="Required",
            direction="Input")
    
        # Set the filter to accept only remote/enterprise geodatabases
        param0.filter.list = ["Remote Database"]
    
        return [param0]
    
    def execute(self, parameters, messages):
        """The source code of the tool."""
        path = parameters[0].valueAsText
        fc = "Zone"
        fc_path = os.path.join(path, fc)