In python, I've created a new polyline feature class, turned it into a layer and added it to an existing map. How can I dynamically change the color of that line in python code?
You can use a lyr file to set the symbology in your script.
Setting output symbology in scripts—Help | ArcGIS for Desktop
I was hoping there was a way to do this without first creating a dummy layer file of every possible color I would use. I'm looking for how to change the symbology in code, not just assign it an already existing one. In arcims I could do this simply with arcxml:
<LAYER type="acetate" name="NAME" visible="true" id="$preLineID">
<SIMPLELINESYMBOL transparency="1.0" type="$markType" overlap="false" color="255,0,0" antialiasing="true" width="4" />
<POINT x="$xPoint1" y="$yPoint1" />
<POINT x="$xPoint2" y="$yPoint2" />
Currently this isn't possible within the arcpy site package. Although you can inherit the symbology from an existing layer file or use python to change the renderer for the layer, you cannot create the symbology from scratch and apply it to the layer.
To accomplish this you'd need to utilize ArcObjects. Within ArcObjects you could create the symbol, add it to a renderer and set the renderer for the layer.
How to make a line fill symbol
Working with layers and renderers
While that would work, the way that was project has to be done, I can't use ArcObjects. Its has to be done in an geoprocessing service that I can call within the existing perl code since this is replacing an old way of creating a map. We can't recode the entire website for this one little part. Thank you though.
No problem. Without using ArcObjects directly I don't think you'd be able to accomplish this in a supported manner until these functionalities are added to the arcpy module. Otherwise, the ArcObjects code could easily be wrapped into a custom gp tool, published to the server as a gp service, and called from any client that can communicate with REST.
I'm confused. I can write something using ArcObjects and have it wrapped as a gp tool now or is that something that would need to be changed by Esri before I could do it? Cause I think that would work for me if that is possible presently (and I saw an example of how to do that.)
ArcObjects would allow you to build custom gp tools in the same manner that you build them in python. The python toolbox and python script tool workflows are essentially a watered down version of what you can do in ArcObjects.
Building a custom geoprocessing function tool
Retrieving data ...