How to get a value from another python script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Verlaat

    How to get a value from another python script

    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:
    Code:
    import arcgisscripting
    gp = arcgisscripting.create(9.3)
    intable = gp.GetParameterAsText(0)
    infield = gp.GetParametersAsText(1)
    
    # open cursor
    rows = gp.searchcursor(intable)
    row = rows.next()
    fval = row.GetValue(infield)
    gp.SetParameterAsText(2, str(fval))
    and this is the second one.

    Code:
    import sys, string, os, arcgisscripting
    
    gp = arcgisscripting.create()
    gp.AddToolbox("filepath/Data Management Tools.tbx")
    gp.AddToolbox("filepath/Mark Toolbox.tbx")
    
    String = ? #This has to be the value from the GetValue script
    VCI_Laag = "filepath\\Symbology_Files\\"+String +".lyr"
    Grondsoorten_Verzadigd = "Grondsoorten_Verzadigd"
    
    gp.ApplySymbologyFromLayer_management(Grondsoorten_Verzadigd, VCI_Laag)
    The Dutch words are filenames.

    Could anyone help me?
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    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:
    Code:
    file_name = "data.txt"
    fileObj = open(file_name, 'w')
    fileObj.write(str(favl))
    fileObj.close()
    Second script:
    Code:
    fval = open(file_name).read()

    Comment

    Working...