POST
|
I figured it out. Using the ListFields fields function in the def updateParameters function you're able to access the field names of the input attribute table. Then you can pass those values to a 'for loop' and append them to a list, and then pass those list values into your Value Table. Another thing to keep in mind is how you've set up your Value Table columns. I set mine up requiring a field, a boolean 'true' or 'false', and a string. This required me to structure my list values as <field name, 'false', None> def getParameterInfo(self):
in_features = arcpy.Parameter(
displayName="Input Feature",
name="in_features",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input")
# Text field to request the name of the new layer
layerTitle = arcpy.Parameter(
displayName="New Layer Name",
name="layerTitle",
datatype="GPString",
parameterType="Required",
direction="Input")
# Setup Value Table
valueTable = arcpy.Parameter(
displayName="Value Table",
name="valueTable",
datatype="GPValueTable",
parameterType="Optional",
direction="Input")
valueTable.columns = [['field', 'Column Name'], ['GPBoolean', 'Hide Field?'], ['GPString', 'New Alias']]
valueTable.parameterDependencies = [in_features.name]
valueTable.filters[1].type = 'ValueList'
valueTable.filters[1].list = ['True', 'False']
# Add output location for layer file
outputParam = arcpy.Parameter(
displayName="Output Location",
name="outLocation",
datatype="GPFeatureLayer",
parameterType="Derived",
direction="Output")
outputParam.parameterDependencies = [in_features.name]
outputParam.schema.clone = True
params = [in_features, layerTitle, valueTable, outputParam]
return params
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
in_features = parameters[0].valueAsText
fields = arcpy.ListFields(in_features)
if parameters[0].value:
if not parameters[2].altered:
vtab = []
for i in fields:
vtab.append([i.name, "false", None])
parameters[2].values = vtab
return
... View more
09-07-2017
03:33 PM
|
0
|
0
|
1015
|
POST
|
I don't have a lot of experience with derived outputs, but my gut feeling is that the value table is not. However, the table does have parameter dependencies associated with the input feature class that populate the list of fields on the fly.
... View more
09-07-2017
08:01 AM
|
0
|
1
|
1015
|
POST
|
I'm sure this exists somewhere, but I've been unable to find an answer that works with my code. I'm trying to take the attribute field names that are assigned as parameter dependencies in my code and have them appear by default in the first column of my value table. See pics below: Any help would be great. I've also attached the code. Thanks! def getParameterInfo(self):
in_features = arcpy.Parameter(
displayName="Input Feature",
name="in_features",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input")
# Text field to request the name of the new layer
layerTitle = arcpy.Parameter(
displayName="New Layer Name",
name="layerTitle",
datatype="GPString",
parameterType="Required",
direction="Input")
# Setup Value Table
valueTable = arcpy.Parameter(
displayName="Value Table",
name="valueTable",
datatype="GPValueTable",
parameterType="Optional",
direction="Input")
valueTable.columns = [['field', 'Column Name'], ['GPBoolean', 'Hide Field?'], ['GPString', 'New Alias']]
valueTable.parameterDependencies = [in_features.name]
valueTable.filters[1].type = 'ValueList'
valueTable.filters[1].list = ['True', 'False']
# Add output location for layer file
outputParam = arcpy.Parameter(
displayName="Output Location",
name="outLocation",
datatype="GPFeatureLayer",
parameterType="Derived",
direction="Output")
outputParam.parameterDependencies = [in_features.name]
outputParam.schema.clone = True
params = [in_features, layerTitle, valueTable, outputParam]
return params
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
in_features = parameters[0].valueAsText
if parameters[0].value:
if not parameters[2].altered:
fields = arcpy.ListFields(in_features)
vtab = []
for field in fields:
if field.name != "u'OBJECTID" or field.name != "u'GEOMETRY'":
vtab.append([field.name])
parameters[2].values = vtab
return Thank you for you time and consideration! Cz
... View more
09-06-2017
04:34 PM
|
0
|
3
|
1777
|
POST
|
Hi everybody! I have a function which takes the XY coordinates from a point layer and then passes those coordinates to a couple of variables. Those values are then assigned to other values which compute 4 coordinate pairs which are meant to be used as a list of coordinates to a create polygon via the esri/geometry/Polygon module. Passing the values works like a charm and the additional variables are all defined. In fact the entire code runs, but it doesn't produce the desired results which is a square. Side note: I know it's the variables because if I assign some hard numeric values to the addPoly function and not the variables the desired polygon will be produced. Thanks for your time! Cz function addPoly(){ //assign values to the square coordinates var x1 = Number(xpoint + 201.168); var y1 = Number(ypoint + 201.168); var x2 = Number(xpoint + 201.168); var y2 = Number(ypoint - 201.168); var x3 = Number(xpoint - 201.168); var y3 = Number(ypoint - 201.168); var x4 = Number(xpoint - 201.168); var y4 = Number(ypoint + 201.168); //check to see if values were assigned alert("Your values are " + x1 + " " + y1); //add polygon symbology var polySymbol = new SimpleFillSymbol().setColor(null).outline.setColor("blue"); var polyLineSymbol = new SimpleLineSymbol(); var polygon = new Polygon({ "rings": [ [ [y1, x1], [y2, x2], [y3, x3], [y4, x4], [y1, x1] ] ], "spatialReference": { "wkid": 102100 } }); alert("graphic should add next"); map.graphics.add(new Graphic(polygon, polySymbol)); };
... View more
10-21-2015
03:44 PM
|
0
|
0
|
2381
|
POST
|
Hi Jeff, You wouldn't happen to have an example of how to use the document.createElement and element.appendChild would you? I've tried a couple things and this is as far as I can get. Here is the code that produces this result. I left out the element.appendChild because I'm not sure to which element I append the object. Thanks! Cz function getTextContent(graphic){ var names = graphic.attributes.x_coord; var y_coord = graphic.attributes.y_coord var commName = names; var btn = document.createElement("BUTTON"); btn.innerHTML = 'click me'; if(commName === ""){ commName = names[0]; } return "<b>" + commName + "</b><br /><p >" + y_coord +"</p><br /><button>" + btn +"</button>";
... View more
09-29-2015
02:09 PM
|
0
|
2
|
686
|
POST
|
Hi Richard, I have tried this approach as the call to the infoTemplate is already nested within a <script> tag which is in the <head> tag. I realized that I should have included the whole code so I attached the entire code to the original message for reference. Thanks!
... View more
09-24-2015
03:47 PM
|
0
|
0
|
686
|
POST
|
Hola everybody, I've successfully added an html button within an InfoWindow. However, I am having trouble calling functionality when the button is clicked. I've tried onClick within the html tag, using the 'on' event listener, and querying for the button class and listening for the 'click' event. If someone could point me in the right direction that would be great. Thanks for your time. Cz var sources = search.sources; sources.push({ featureLayer: layer, placeholder: "L0400409", enableLabel: false, searchFields: ["NUMBER_KEY"], displayField: "NUMBER_KEY", exactMatch: false, outFields: ["*"], //Create an InfoTemplate infoTemplate: new InfoTemplate("Casefile Info", "<a href= ${CASE_NUM} target=_blank ;'>Additional Info</a></br></br>NumberKey: ${NUMBER_KEY}</br>TLNO: ${TLNO}</br><button type='button' id='infoBtn' class='infoBtn';'>Click Me</button>") }); //Add functionality to the infoBtn here
... View more
09-24-2015
02:50 PM
|
0
|
7
|
3243
|
POST
|
Hi Matthias, Thanks for the quick response. My next questions becomes, how does one toggle between the cga text editor and the cga gui interface? Thanks! Jon Cz
... View more
08-10-2015
09:39 AM
|
0
|
1
|
356
|
POST
|
Hello, I'm currently running through the online tutorials for CE. At a certain point the moderator opens the cga editor which has a toolbar that allows him to toggle between a text editor and a GUI. When I open up the cga editor I have no such toolbar and have no idea where the toggle to add toolbars is located. Thanks! Jon Cz
... View more
08-10-2015
09:01 AM
|
0
|
3
|
2827
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|