Hi,
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?
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.
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
http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/How_to_make_a_line_fill_symbol/0001000000s4000000/
Working with layers and renderers
http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Working_with_layers_and_renderers/000100000468000000/
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">
<OBJECT units="database">
<SIMPLELINESYMBOL transparency="1.0" type="$markType" overlap="false" color="255,0,0" antialiasing="true" width="4" />
<POLYLINE>
<PATH>
<POINT x="$xPoint1" y="$yPoint1" />
<POINT x="$xPoint2" y="$yPoint2" />
</PATH>
</POLYLINE>
</OBJECT>
</LAYER>
You can use a lyr file to set the symbology in your script.
Setting output symbology in scripts—Help | ArcGIS for Desktop
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.