sgear

VB.NET Add layer IESRIScriptEngine turn Layer on or off

Discussion created by sgear on May 11, 2017

Hi Anyone who can help me with this Please

 

I am try to turn Layer on or off but I get error on this line 

.AddCode("lyr7.visible = False")

 

System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

 

Dim engine As IESRIScriptEngine = New ESRIScriptEngine
With engine
.Language = "python"

.AddCode("import arcpy")
.AddCode("mxd = arcpy.mapping.MapDocument(""CURRENT"")")
.AddCode("df = arcpy.mapping.ListDataFrames(mxd)[0]")
.AddCode("addLayer = arcpy.mapping.Layer(r" & "'" & LYR_file & "'" & ")")
.AddCode("arcpy.mapping.AddLayer(df, addLayer, ""BOTTOM"")")

.AddCode("lyr7 = arcpy.mapping.ListLayers(mxd, "", df)[0]"")")
.AddCode("lyr7.visible = False")

Outcomes