AnsweredAssumed Answered

ApplySymbologyFromLayer  does not work in my python code

Question asked by monir_mostafizur1 on Dec 27, 2015
Latest reply on Dec 27, 2015 by monir_mostafizur1

Hi,

I have  a layer file. I make a button in ArcGIS 10 with .NET. I want to change layer symbology with the layer file. For this purpose I Write python code and execute it from C#. If the following code is written in python window of ArcGIS, then works fantastic. But from my code, it does not work. Can anyone help me ??

 

try

           {

               const string prg = @"import sys

import arcpy

from arcpy import env

mxd = arcpy.mapping.MapDocument('CURRENT')

layer = arcpy.mapping.ListLayers(mxd)[0]

    arcpy.ApplySymbologyFromLayer_management(layer,'C:\Users\DELL\AppData\Local\Temp\Junctions_Temp.lyr')

"

                   ;

               var sw = new StreamWriter("D:\\test2.py");

               sw.Write(prg); // write this program to a file

               sw.Close();

               var p = new Process

                           {

                               StartInfo =

                                   {

                                       FileName = @"C:\Python26\ArcGIS10.0\python.exe",

                                       RedirectStandardOutput = true,

                                       UseShellExecute = false,

                                       Arguments = "D:\\test2.py "

                                   }

                           }; // create process (i.e., the python program

               p.Start();

 

Thanks ...

Outcomes