<?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: Passing variable to another script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/passing-variable-to-another-script/m-p/583687#M45774</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to set the output parameter at the end of PythonTest.py:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14405094159459672 jive_macro_code jive_text_macro" data-renderedposition="29_8_912_16" jivemacro_uid="_14405094159459672" modifiedtitle="true"&gt;&lt;P&gt;arcpy.SetParameter(1, outFC_Project)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;TrackBuilderVersion2_x64.py can use it as an input:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14405095107341523 jive_text_macro" data-renderedposition="87_8_912_16" jivemacro_uid="_14405095107341523" modifiedtitle="true"&gt;&lt;P&gt;outFC_Project = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Aug 2015 13:33:25 GMT</pubDate>
    <dc:creator>JonMorris2</dc:creator>
    <dc:date>2015-08-25T13:33:25Z</dc:date>
    <item>
      <title>Passing variable to another script</title>
      <link>https://community.esri.com/t5/python-questions/passing-variable-to-another-script/m-p/583686#M45773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to make a point layer from a csv file with AIS data (Automated Identification System, i.e., shipping data) . Then I want to make lines using a script called &lt;A href="http://coast.noaa.gov/digitalcoast/tools/track-builder" rel="nofollow noopener noreferrer" target="_blank"&gt;TrackBuilder&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have two python scripts: PythonTest.py to make the points and TrackBuilderVersion2_x64.py to make the lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know how to tell python to use the variable outFC_Project in TrackBuilderVersion2_x64.py&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error I get is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;exceptions.NameError: name 'outFC_Project' is not defined&lt;/PRE&gt;&lt;P&gt;PythonTest.py:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#import modules
import arcpy
import os
from arcpy import env
import TrackBuilderVersion2_x64

#Set env settings
env.workspace = "E:/DensityMaps/DensityMapsTest.gdb/"
arcpy.env.overwriteOutput =True

#Define variables
monthTable = "E:/test_division/division_finale2014/file_list_months_weeks/scope_ais_december.csv"
monthPoints = "monthPoints"
x_coords = "long"
y_coords = "lat"

out_Layer = "monthLayer"
path_outLayer = "E:/DensityMaps/"

saved_Layer = "E:/DensityMaps/monthlayer.lyr"
outFC = "MonthFC"
outFC_Project = outFC+"_Project"

#set spatial reference
spRef =arcpy.SpatialReference("WGS 1984")

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Process
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeXYEventLayer_management(monthTable, x_coords, y_coords, out_Layer, spRef, "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Save to layer file
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Copy features to FC
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(saved_Layer,outFC)

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set output coordinate system. 3035 = LAEA
&amp;nbsp;&amp;nbsp;&amp;nbsp; outCS = arcpy.SpatialReference(3035)

&amp;nbsp;&amp;nbsp; #Project to LAEA
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(outFC, outFC_Project, outCS)

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Calling trackbuilder
&amp;nbsp;&amp;nbsp;&amp;nbsp; TrackBuilderVersion2_x64

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Delete temporary files
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management('monthLayer')
&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(saved_Layer)

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Check messages
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(arcpy.GetMessages())

except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()

print 'Script completed'&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TrackBuilderVersion2_x64.py (only first lines, see the complete script in attachment):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Import PythonTest.py to get the variable month
import PythonTest
#print "Testing printing "+PythonTest.outFC


print "Printing test "+PythonTest.outFC_Project
#Path to input points (broadcast feature class)
sInputFile = outFC_Project

#ID field name (can keep as is most likely)
sID_Field = "mmsi"


#DaeTime field name (can keep as is most likely)
sDT_Field = "timestamp_pretty"

#Path to output workspace (file geodatabase)
sOutWorkspace = r"E:/DensityMaps/DensityMapsTest.gdb"

#name of output trackline feature class
sOutName = "MonthTest"


#Break Track line method option (comment/uncomment the selected option)
sLineMethod = "Maximum Time and Distance"
#sLineMethod = "Time Interval"


#Maximum Time in minutes (keep as string in quotes, use 0 if using Time Interval method, default = 60)
sMaxTimeMinutes = "600"


#Maximum Distance in miles (keep as string in quotes, use 0 if using Time Interval method, default = 6)
sMaxDistMiles = "150"


#Time Interval in hours (keep as string in quotes, use 0 if using Maximum Time and Distance method, default = 24)
sIntervalHours = "0"


#Include Voyage Attributes (comment/uncomment the selected option)
#sAddVoyageData = "true"
sAddVoyageData = "false"


#Voyage Table (path to voyage table) - OPTIONAL
#voyageTable = r"D:\AISTrackBuilder\Test\test.gdb\Voyage"


#Voyage Matching Option (comment/uncomment the selected option) - OPTIONAL
#voyageMethod = "Most Frequent"
#voyageMethod = "First"


#Include Vessel Attributes (comment/uncomment the selected option)
#sAddVesselData = "true"
sAddVesselData = "false"


#Vessel Table (path to vessel table) - OPTIONAL
#vesselTable = r"D:\AISTrackBuilder\Test\test.gdb\Vessel"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:05:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/passing-variable-to-another-script/m-p/583686#M45773</guid>
      <dc:creator>ManuelFrias</dc:creator>
      <dc:date>2021-12-12T01:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable to another script</title>
      <link>https://community.esri.com/t5/python-questions/passing-variable-to-another-script/m-p/583687#M45774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to set the output parameter at the end of PythonTest.py:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14405094159459672 jive_macro_code jive_text_macro" data-renderedposition="29_8_912_16" jivemacro_uid="_14405094159459672" modifiedtitle="true"&gt;&lt;P&gt;arcpy.SetParameter(1, outFC_Project)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;TrackBuilderVersion2_x64.py can use it as an input:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14405095107341523 jive_text_macro" data-renderedposition="87_8_912_16" jivemacro_uid="_14405095107341523" modifiedtitle="true"&gt;&lt;P&gt;outFC_Project = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 13:33:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/passing-variable-to-another-script/m-p/583687#M45774</guid>
      <dc:creator>JonMorris2</dc:creator>
      <dc:date>2015-08-25T13:33:25Z</dc:date>
    </item>
  </channel>
</rss>

