I am using ModelBuilder and trying to get a user defined field from a user defined polygon. From this, I want to later populate a different field with calculated values in a model.
Is there a way to get a list of fields from the user defined polygon and use that value to populate the other field?
How would I go about using the user defined field in a VB expression within the calculate value tool?
newfield = [%field%]
?
-
2It might be helpful to post a screenshot of your model here. Have you looked at all into Python?GISHuman– GISHuman2014年08月11日 19:44:06 +00:00Commented Aug 11, 2014 at 19:44
-
1That expression should work, if you have a text parameter called "field". Have you tested it?nmpeterson– nmpeterson2014年08月11日 22:05:56 +00:00Commented Aug 11, 2014 at 22:05
-
1Yes, that should work, but why? There is so much danger in doing it this way as you're not picking a field from the feature class you're entering a string - a chance for typo's. Can you explain a bit more about what you're trying to do and hopefully I can come up with something a bit more robust.Michael Stimson– Michael Stimson2014年08月11日 23:03:50 +00:00Commented Aug 11, 2014 at 23:03
-
By a "user-defined polygon" are you meaning a Feature Set? And what do you mean by a "user-defined field"? Perhaps including some screenshots will make your question clearer.PolyGeo– PolyGeo ♦2014年08月12日 02:42:48 +00:00Commented Aug 12, 2014 at 2:42
1 Answer 1
If you want a field picker you have to code it in python.
The code is as follows:
# Import system modules
import arcpy
# Set the parameters
InputFeatureClass = arcpy.GetParameterAsText(0)
InputField = arcpy.GetParameterAsText(1)
arcpy.SetParameter(2, InputField)
And the tool is set as follows:
Input Feature Layer
- Data Type: Feature Layer (You might be using a Feature Set)
- Direction: Input
- Multivalue: No
Inputs Fields
- Data Type: Fields
- Direction: Input
- Multivalue: No
- Obtained from: Input Feature Layer
Output Field
- Data Type: Field
- Direction: Output
- Multivalue: No
It looks like this
Toolbox Script dialog
You should then be able to use this to return a field as a FIELD object, suitable for a input parameter to the Calculate Field tool. A model looks like this: Example Model
I hope that helps.
-
What a clever solution. Too bad model builder doesn't inherently support the 'obtained from' option in the parameter settings.\CStarbird– CStarbird2016年03月11日 01:16:34 +00:00Commented Mar 11, 2016 at 1:16