<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Publishing script tool as Geoprocessing Service - Input turned as Constant Value in Publishing and Managing Services Questions</title>
    <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364999#M1090</link>
    <description>&lt;P&gt;It looks like you did not include the complete code, aside from the indentation problem. If you are setting up a "Script" then you specify parameters in the Toolbox. If you are setting up a Python Toolbox then there is code that wraps around what you posted. The imports at the top then the class definition for the Python Toolbox and the class for the tool.&lt;/P&gt;&lt;P&gt;If you post the whole thing (with correct indentation) then I can paste it into my editor and try it out. Then maybe I can help with the actual error.&lt;/P&gt;&lt;P&gt;When you open the "code" window here, make sure you select "Python" before you paste your code into it. That's probably why it removed all the indentation. It defaults to "C". (Bad choice)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Dec 2023 17:30:53 GMT</pubDate>
    <dc:creator>Brian_Wilson</dc:creator>
    <dc:date>2023-12-29T17:30:53Z</dc:date>
    <item>
      <title>Publishing script tool as Geoprocessing Service - Input turned as Constant Value</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364708#M1086</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;A tool created for conversion, worked fine on ArcGIS Pro, but while/when published the Input value changed to constant value,&amp;nbsp;need kindly help&lt;/P&gt;&lt;P&gt;Environment: ArcGIS Pro 3.2.1, ArcGIS Enterprise 11.1&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def getParameterInfo(self):
"""Define the tool parameters."""
params = [
arcpy.Parameter(displayName="Input CAD File",
name="in_cad",
datatype="DECadDrawingDataset",
parameterType="Required",
direction="Input"),
arcpy.Parameter(displayName="Output JSON File",
name="out_json",
datatype="DEFile",
parameterType="Required",
direction="Output")
]
return params

def execute(self, parameters, messages):
"""The source code of the tool."""
in_cad = parameters[0].valueAsText
out_json = parameters[1].valueAsText

desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')

newpath = desktop+str(r'\output')
if not os.path.exists(newpath):
os.makedirs(newpath)

arcpy.env.workspace = desktop+r"\output\fGDB.gdb"

# Set local variables

out_folder_path = desktop+str(r"\output" )
out_name = "fGDB.gdb"

# Execute Create FileGDB, temp

arcpy.CreateFileGDB_management(out_folder_path, out_name)

#####################################

# Process: CAD to Geodatabase
arcpy.CADToGeodatabase_conversion(in_cad, out_folder_path+'/'+out_name, "FClass", "1000", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 11258999068426.2;-1073.7418235 4194304001953.12;-100000 10000;8.98315284119522E-09;0.001;0.001;IsHighPrecision")

#####################################

# Process: Iterate Feature Classes

datasets = arcpy.ListDatasets(feature_type='feature')
datasets = [''] + datasets if datasets is not None else []

for ds in datasets:
for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
path = os.path.join(arcpy.env.workspace, ds, fc)
print(path)

#####################################

# Process: Features To JSON
arcpy.FeaturesToJSON_conversion(fc, out_json, "FORMATTED", "NO_Z_VALUES", "NO_M_VALUES", "GEOJSON")

#####################################

# Execute Delete FileGDB

arcpy.Delete_management(newpath)
return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 11:51:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364708#M1086</guid>
      <dc:creator>User35489</dc:creator>
      <dc:date>2023-12-28T11:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing script tool as Geoprocessing Service - Input turned as Constant Value</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364789#M1087</link>
      <description>&lt;P&gt;First thing that pops out at me is the indentation is wrong. Did that change when you uploaded it to this web site or is it really like that. I don't know if I got the for loops indented correctly around line 52....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
import arcpy

def getParameterInfo(self):
    """Define the tool parameters."""
    params = [
        arcpy.Parameter(displayName="Input CAD File",
        name="in_cad",
        datatype="DECadDrawingDataset",
        parameterType="Required",
        direction="Input"),
        arcpy.Parameter(displayName="Output JSON File",
        name="out_json",
        datatype="DEFile",
        parameterType="Required",
        direction="Output")
    ]
    return params

def execute(self, parameters, messages):
    """The source code of the tool."""
    in_cad = parameters[0].valueAsText
    out_json = parameters[1].valueAsText

    desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')

    newpath = desktop+str(r'\output')
    if not os.path.exists(newpath):
        os.makedirs(newpath)

    arcpy.env.workspace = desktop+r"\output\fGDB.gdb"

    # Set local variables

    out_folder_path = desktop+str(r"\output" )
    out_name = "fGDB.gdb"

    # Execute Create FileGDB, temp

    arcpy.CreateFileGDB_management(out_folder_path, out_name)

    #####################################
    # Process: CAD to Geodatabase
    arcpy.CADToGeodatabase_conversion(in_cad, out_folder_path+'/'+out_name, "FClass", "1000", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 11258999068426.2;-1073.7418235 4194304001953.12;-100000 10000;8.98315284119522E-09;0.001;0.001;IsHighPrecision")

    #####################################
    # Process: Iterate Feature Classes

    datasets = arcpy.ListDatasets(feature_type='feature')
    datasets = [''] + datasets if datasets is not None else []

    for ds in datasets:
        for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
            path = os.path.join(arcpy.env.workspace, ds, fc)
            print(path)

    #####################################
    # Process: Features To JSON
    arcpy.FeaturesToJSON_conversion(fc, out_json, "FORMATTED", "NO_Z_VALUES", "NO_M_VALUES", "GEOJSON")

    #####################################
    # Execute Delete FileGDB

    arcpy.Delete_management(newpath)
    return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 17:51:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364789#M1087</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2023-12-28T17:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing script tool as Geoprocessing Service - Input turned as Constant Value</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364922#M1088</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/403473"&gt;@Brian_Wilson&lt;/a&gt;&amp;nbsp;Indentation is correct in the code, somehow it got posted wrong, all without indents. The tool worked fine in ArcGIS Pro.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 07:40:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364922#M1088</guid>
      <dc:creator>User35489</dc:creator>
      <dc:date>2023-12-29T07:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing script tool as Geoprocessing Service - Input turned as Constant Value</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364924#M1089</link>
      <description>&lt;P&gt;Even while publishing, it has got the same issue.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="User35489_0-1703835908888.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90114i895BF02DBDD452AE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="User35489_0-1703835908888.png" alt="User35489_0-1703835908888.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 07:45:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364924#M1089</guid>
      <dc:creator>User35489</dc:creator>
      <dc:date>2023-12-29T07:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing script tool as Geoprocessing Service - Input turned as Constant Value</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364999#M1090</link>
      <description>&lt;P&gt;It looks like you did not include the complete code, aside from the indentation problem. If you are setting up a "Script" then you specify parameters in the Toolbox. If you are setting up a Python Toolbox then there is code that wraps around what you posted. The imports at the top then the class definition for the Python Toolbox and the class for the tool.&lt;/P&gt;&lt;P&gt;If you post the whole thing (with correct indentation) then I can paste it into my editor and try it out. Then maybe I can help with the actual error.&lt;/P&gt;&lt;P&gt;When you open the "code" window here, make sure you select "Python" before you paste your code into it. That's probably why it removed all the indentation. It defaults to "C". (Bad choice)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 17:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1364999#M1090</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2023-12-29T17:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing script tool as Geoprocessing Service - Input turned as Constant Value</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1365135#M1091</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/403473"&gt;@Brian_Wilson&lt;/a&gt;&amp;nbsp;Please find below. Thanks for your interest.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: utf-8 -*-

import arcpy


class Toolbox:
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "toolbox"
        self.alias = "toolbox"

        # List of tool classes associated with this toolbox
        self.tools = [Tool]


class Tool:
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "DWGtoGEOJSON"
        self.description = ""

    def getParameterInfo(self):
        """Define the tool parameters."""
        params = [
            arcpy.Parameter(displayName="Input CAD File",
                            name="in_cad",
                            datatype="DECadDrawingDataset",
                            parameterType="Required",
                            direction="Input"),
            arcpy.Parameter(displayName="Output JSON File",
                            name="out_json",
                            datatype="DEFile",
                            parameterType="Required",
                            direction="Output")
        ]
        return params

    def isLicensed(self):
        """Set whether the tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter. This method is called after internal validation."""
        return

    def execute(self, parameters, messages):
        """The source code of the tool."""
        in_cad = parameters[0].valueAsText
        out_json = parameters[1].valueAsText
        
        desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop') 

        newpath = desktop+str(r'\output') 
        if not os.path.exists(newpath):
            os.makedirs(newpath)

        arcpy.env.workspace = desktop+r"\output\fGDB.gdb"

        # Set local variables

        out_folder_path = desktop+str(r"\output" )
        out_name = "fGDB.gdb"

        # Execute Create FileGDB, temp

        arcpy.CreateFileGDB_management(out_folder_path, out_name)

        #####################################

        # Process: CAD to Geodatabase
        arcpy.CADToGeodatabase_conversion(in_cad, out_folder_path+'/'+out_name, "FClass", "1000", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 11258999068426.2;-1073.7418235 4194304001953.12;-100000 10000;8.98315284119522E-09;0.001;0.001;IsHighPrecision")

        #####################################

        # Process: Iterate Feature Classes

        datasets = arcpy.ListDatasets(feature_type='feature')
        datasets = [''] + datasets if datasets is not None else []

        for ds in datasets:
            for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
                path = os.path.join(arcpy.env.workspace, ds, fc)
                print(path)

        #####################################

        # Process: Features To JSON
        arcpy.FeaturesToJSON_conversion(fc, out_json, "FORMATTED", "NO_Z_VALUES", "NO_M_VALUES", "GEOJSON")

        #####################################

        # Execute Delete FileGDB

        arcpy.Delete_management(newpath)        
        return

    def postExecute(self, parameters):
        """This method takes place after outputs are processed and
        added to the display."""
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 06:14:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1365135#M1091</guid>
      <dc:creator>User35489</dc:creator>
      <dc:date>2023-12-30T06:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing script tool as Geoprocessing Service - Input turned as Constant Value</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1370082#M1092</link>
      <description>&lt;P&gt;Further in research,&lt;BR /&gt;&lt;BR /&gt;CAD file data type is considered as a &lt;STRONG&gt;non-simple&lt;/STRONG&gt; feature. Thus it cannot be used as a user input.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://enterprise.arcgis.com/en/server/10.5/publish-services/windows/parameter-data-type-transformations.htm#ESRI_SECTION1_5C6000DB9B0341008B589D07782179CA" target="_blank"&gt;https://enterprise.arcgis.com/en/server/10.5/publish-services/windows/parameter-data-type-transformations.htm#ESRI_SECTION1_5C6000DB9B0341008B589D07782179CA&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 07:14:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/publishing-script-tool-as-geoprocessing-service/m-p/1370082#M1092</guid>
      <dc:creator>User35489</dc:creator>
      <dc:date>2024-01-15T07:14:34Z</dc:date>
    </item>
  </channel>
</rss>

