samedi 28 février 2015

Inline variable substitution in Model Builder using python code


I have an inline variable substiution which I would like to import into my Python script. Is that possible? I am trying to make a parameter within my path.


My path currently is "c:\Users\Jelle\Dropbox". Within Model Builder I can substitute 'Jelle' by using an inline variable subsitution (name) and call it through %name%. I would like to replace "Jelle" with other names but then within a Python script.


I have tried using GetParameterAsText and making the inline variable as a Parameter within Model Builder but I get an empty output: Here is the script which I tried for it:



import arcpy
username = arcpy.GetParameterAsText(0) #this is the inline variable 'name' which I am trying to call
input_table = "C:\\Users\\"+str(username)+"\\Dropbox"


Input_table gives the following return:



"C:\Users\\Dropbox"


Hence the 'username' variable is not returned


I have the feeling I should be using something else other than GetParameterAsText. Could someone help me out here?





Aucun commentaire:

Enregistrer un commentaire