By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

How to get a value from another python script

P: n/a
Hi,

i'm trying to get a value from a Python script called getValue and use this value to select the correct symbology layer for a ArcGIS map.

This is the first code:
Expand|Select|Wrap|Line Numbers
  1. import arcgisscripting
  2. gp = arcgisscripting.create(9.3)
  3. intable = gp.GetParameterAsText(0)
  4. infield = gp.GetParametersAsText(1)
  5.  
  6. # open cursor
  7. rows = gp.searchcursor(intable)
  8. row = rows.next()
  9. fval = row.GetValue(infield)
  10. gp.SetParameterAsText(2, str(fval))
  11.  
and this is the second one.

Expand|Select|Wrap|Line Numbers
  1. import sys, string, os, arcgisscripting
  2.  
  3. gp = arcgisscripting.create()
  4. gp.AddToolbox("filepath/Data Management Tools.tbx")
  5. gp.AddToolbox("filepath/Mark Toolbox.tbx")
  6.  
  7. String = ? #This has to be the value from the GetValue script
  8. VCI_Laag = "filepath\\Symbology_Files\\"+String +".lyr"
  9. Grondsoorten_Verzadigd = "Grondsoorten_Verzadigd"
  10.  
  11. gp.ApplySymbologyFromLayer_management(Grondsoorten_Verzadigd, VCI_Laag)
The Dutch words are filenames.

Could anyone help me?
Nov 16 '10 #1
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
You could write the information to a disk file in the first script and read the data from the disk file in the second script. I will assume you will consistently be in a certain working directory, otherwise you would need the include the path in the file name.

First script:
Expand|Select|Wrap|Line Numbers
  1. file_name = "data.txt"
  2. fileObj = open(file_name, 'w')
  3. fileObj.write(str(favl))
  4. fileObj.close()
Second script:
Expand|Select|Wrap|Line Numbers
  1. fval = open(file_name).read()
Nov 16 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.