<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: inconsistent Arcpy.Mapping behaviour in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463092#M36298</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;my time is pretty limited so I'm trying to avoid having to rewrite the entire thing. That may take me as much time as manually doing this one at a time. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Aug 2014 17:07:13 GMT</pubDate>
    <dc:creator>JoshuaChan</dc:creator>
    <dc:date>2014-08-08T17:07:13Z</dc:date>
    <item>
      <title>inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463071#M36277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've written a script using Arcpy.mapping module to automate map making. It works as a one-off for use in ArcMap if I use the ArcToolbox to call the script. But if I call it from python (eclipse) I get weird error messages ("ExecuteError: ERROR 000358: Invalid expression") pointing towards the "Select by Layer" tool. But it executes fine if run from ArcToolbox, no errors... same script. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Part 2: I gave up running it from Eclipse and ran it from ArcToolbox within ArcMap. Now I'm trying to run a batch - multiple maps. It used to work until this morning. this morning I made the most minor of changes... to check to see if a variable.upper() == 'YES'&lt;/P&gt;&lt;P&gt;again, this works in the "one-off" scenario within ArcMap called from ArcToolbox. But I'm trying to run my batch script (also called by ArcToolbox) and I get that same query error as above. Why is that? it's the exact same script. I don't want to interactively run this script in ArcMap for all 350+ maps. Why is arcpy.mapping so flaky? Is there a way to fix this???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 17:55:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463071#M36277</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-07-31T17:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463072#M36278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ps for the one-off my mxd is set to "CURRENT" but for the batch I did link it to the actual mxd file location "C:\blah\blah\awesome.mxd"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The batch worked this morning until I added the "upper()" part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if you want to see the scripts you can get them at: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="ftp://ftp.geobc.gov.bc.ca/pub/outgoing/GeoBC_Regional/Coast/tmp_mapRobot/" rel="nofollow" target="_blank"&gt;ftp://ftp.geobc.gov.bc.ca/pub/outgoing/GeoBC_Regional/Coast/tmp_mapRobot/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 20:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463072#M36278</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-07-31T20:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463073#M36279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post a full traceback? There's &lt;EM&gt;a lot&lt;/EM&gt; that could be going wrong here. &lt;SPAN style="font-family: 'courier new', courier;"&gt;arcpy.mapping&lt;/SPAN&gt; should work the same in all environments, I suspect something else is at play here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 20:25:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463073#M36279</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2014-07-31T20:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463074#M36280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what is a traceback? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not a real programmer - just a GIS guy thrown into the possibilities of python. A lot of my script had to be fixed by a real python guy but he stopped when he said that the errors that are ESRI based are out of his "scope". &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you mean the error messages it looks like this now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;Executing: batchMap4PMV&lt;/P&gt;&lt;P&gt;Start Time: Thu Jul 31 13:38:22 2014&lt;/P&gt;&lt;P&gt;Running script batchMap4PMV...&lt;/P&gt;&lt;P&gt;checking out inset map placement: None&lt;/P&gt;&lt;P&gt;no inset map&lt;/P&gt;&lt;P&gt;beginning layer filter of data frameLayers&lt;/P&gt;&lt;P&gt;CROWN_LANDS_FILE = '2411100'&lt;/P&gt;&lt;P&gt;Tantalis Files&lt;/P&gt;&lt;P&gt;defined the lyr for Tantalis Files?&lt;/P&gt;&lt;P&gt;ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\batchMapRobot.py", line 80, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; runMapRobotScript(filenum, outfile)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\batchMapRobot.py", line 42, in runMapRobotScript&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.dataFrameFilter(obj.mainDF, obj.mainDefQry, inset_map)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\map_robot_2014_PMV_v2_4batch.py", line 161, in dataFrameFilter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION", defQry)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "e:\sw_nt\arcgis\desktop10.1\arcpy\arcpy\management.py", line 6498, in SelectLayerByAttribute&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to execute (batchMap4PMV).&lt;/P&gt;&lt;P&gt;Failed at Thu Jul 31 13:38:29 2014 (Elapsed Time: 7.00 seconds)&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh and I've tried the quotes around the field names. It works OK without the quotes in the ArcMap interactive world.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 20:39:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463074#M36280</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-07-31T20:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463075#M36281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no answers? no similar experiences? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll try rebuilding my mxd from scratch... maybe it's another corrupted MXD????&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 17:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463075#M36281</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-06T17:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463076#M36282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;P.S. with the new forum format, where is this post supposed to go? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is this the wrong forum? where do the arcpy.mapping experts hang out?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 16:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463076#M36282</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-07T16:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463077#M36283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Probably this should go in the python space. &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/2034"&gt;Timothy Hales&lt;/A&gt;‌, can you get this moved?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌, you mind taking a look at this code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 16:31:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463077#M36283</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-08-07T16:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463078#M36284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've moved it to &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;‌. Thanks for the heads up!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 16:36:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463078#M36284</guid>
      <dc:creator>TimothyHales</dc:creator>
      <dc:date>2014-08-07T16:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463079#M36285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;so I haven't touched this for a week. I copied my old mxd and re-ran the program with no changes to the script. Now the error message is different: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\batchMapRobot.py", line 80, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; runMapRobotScript(filenum, outfile)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\batchMapRobot.py", line 46, in runMapRobotScript&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.doDimensions(obj.mainDF, tantlyr)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\map_robot_2014_PMV_v2_4batch.py", line 230, in doDimensions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(dFrame, upLyr, srcLyr, False)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "e:\sw_nt\arcgis\desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fn(*args, **kw)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "e:\sw_nt\arcgis\desktop10.1\arcpy\arcpy\mapping.py", line 1869, in UpdateLayer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert isinstance(update_layer, Layer)&lt;/P&gt;&lt;P&gt;AssertionError&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to execute (batchMap4PMV).&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I placed a whole bunch of add message statements to see where exactly it was bombing and it's on the UpdateLayer line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, this script runs without error when I'm doing it one at a time in ArcMap via ArcToolbox. But when trying to run as a batch - namely have a script call the original script with a bunch of arguments - it bombs. The error message doesn't make much sense to me and so far every online answer to similar queries point to people sending a text string to the UpdateLayer function instead of a map document object or a layer object.&amp;nbsp; If you check my script (it's still on the FTP site listed above) I'm fairly certain I have sent it map document object and layer object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 18:12:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463079#M36285</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-07T18:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463080#M36286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;p.s. I've uploaded the most recent version of the batch script and the other one. &lt;/P&gt;&lt;P&gt;minor changes included checking for upper case value for a text variable, changing a UNC path to a drive letter mapping, and adding a bunch of Add Message to see where it's bombing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;search for "check 1" "check 2" etc and you'll see... it doesn't get to check 6.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 18:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463080#M36286</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-07T18:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463081#M36287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How come your using this OO formatted python script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems like a few added steps, for what may seem to cut time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 18:42:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463081#M36287</guid>
      <dc:creator>ToddUlery</dc:creator>
      <dc:date>2014-08-07T18:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463082#M36288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think "ListLayers" returns a list.&amp;nbsp; I'm assuming that you are only expecting one layer called "Dimensions" to be returned.&amp;nbsp; Try changing this:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;arcpy.mapping.UpdateLayer(dFrame, upLyr, srcLyr, False)&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to this:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;arcpy.mapping.UpdateLayer(dFrame, upLyr[0], srcLyr, False)&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 19:01:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463082#M36288</guid>
      <dc:creator>ThomasStanley-Jones</dc:creator>
      <dc:date>2014-08-07T19:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463083#M36289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yea, you are missing an 0 index on a listlayers by check 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.AddMessage("check 3")&lt;/P&gt;&lt;P&gt;#upLyr = arcpy.mapping.ListLayers(self.mxd, "Dimensions", dFrame)[0]&lt;/P&gt;&lt;P&gt;upLyr = arcpy.mapping.ListLayers(self.mxd, "Dimensions", dFrame)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 19:11:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463083#M36289</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-08-07T19:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463084#M36290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i've tried both 0 and not 0 (i've taken turns commenting out one or the other one) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;same result... bombs before check 6&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 21:57:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463084#M36290</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-07T21:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463085#M36291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if I leave the [0] in there I just got an error saying "list index out of range".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I do have a layer called "Dimensions" in my mxd... I just double checked&lt;/P&gt;&lt;P&gt;&lt;IMG alt="TOC_Dimensions.JPG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/3218_TOC_Dimensions.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I decided to close out ArcMap - re open ArcMap and now the error message has reverted back to the &lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;very weird because other than re-activating the line upLyr = arcpy.mapping.ListLayers(self.mxd, "Dimensions", dFrame)[0] &lt;/P&gt;&lt;P&gt;I didn't do anything different.&amp;nbsp;&amp;nbsp; Seems so random.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 22:05:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463085#M36291</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-07T22:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463086#M36292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ToddUlery &lt;/P&gt;&lt;P&gt;the idea was to utilize python to be able to send a batch of maps - 350+&lt;/P&gt;&lt;P&gt;it included lots of customization like truncating text fields, creating text files where it was truncated, adding text if it meets certain conditions, filtering out a layer, zooming to it, etc. Not all of those functions are readily available in Data Driven Pages yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as for OO formatting I'm still learning this stuff. I was told that programming best practices in python (or anything else) was to use modules, classes, etc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 22:10:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463086#M36292</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-07T22:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463087#M36293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I closed ArcMap again, re opened and now I'm back at the List Index out of range error for the updateLayer &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 22:57:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463087#M36293</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-07T22:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463088#M36294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just had a "short" look at the code, and from the error message I see you're using version 10.1 of ArcGIS. Any service packs installed? At 10.1 you can use lot's of the goodies provided like the data access module, but you're using the old and slow cursors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code normally does the same thing each time over and over. If it doesn't then normally something of the environment it runs in (ArcGIS, underlying data, state of elements in your MXD, etc) changed. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to respond to the discussion on whether to use quotes around the field name or field values not. Don't think about this to much, since arcpy can do the work for you. As you know the way you have to specify the field with single quotes, square brackets or just without, depends on the data source. Arcpy comes with a tool ("AddFieldDelimiters") that will do the work for you. Have a look at the snippet below: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14074647122524025" jivemacro_uid="_14074647122524025"&gt;
&lt;P&gt;fc = r"C:\some\path\to\a\folder\or\fgdb.gdb\myFeatureClass"&lt;/P&gt;
&lt;P&gt;fld_name = "myField"&lt;/P&gt;
&lt;P&gt;a_value = 123456&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;qdef = "{0} = {1}".format(arcpy.AddFieldDelimiters(fc, fld_name), a_value)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you want to append text into one string try to avoid this:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14074652511171125" jivemacro_uid="_14074652511171125" modifiedtitle="true"&gt;
&lt;P&gt;"CROWN_LANDS_FILE = '" + str(fileNum) + "'"&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... rather use the string format syntax like:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14074652625089393" jivemacro_uid="_14074652625089393"&gt;
&lt;P&gt;"CROWN_LANDS_FILE = '{0}'".format(fileNum)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This makes it easier to construct complex strings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to zoom to a feature, you can also use the extent of the feature geometry, as I have explained in this thread:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/message/393455#393455" title="https://community.esri.com/message/393455#393455"&gt;https://community.esri.com/message/393455#393455&lt;/A&gt;‌ &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then there's this thing about classes; the fact that you want to run a piece of code 350 times, for me isn't a reason to create a class for it. Sure you can, but the idea of classes (IMHO) is that they should contain reusable generic code and not all kinds of specifics as is the case in your code. It makes it very hard to read your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Aug 2014 02:45:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463088#M36294</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-08-08T02:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463089#M36295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I asked our server administrator and here's what patches we have:&lt;/P&gt;&lt;P&gt;&lt;SPAN dir="ltr" style="font-family: 'Segoe UI'; color: #000000; font-size: 10pt;"&gt;ArcGIS 10.1 for Desktop&lt;BR /&gt;&amp;nbsp; ArcGIS 10.1 SP1 for Desktop&lt;BR /&gt;&amp;nbsp; ArcGIS 10.1 SP1 for Desktop Set Bing Key Patch&lt;BR /&gt;&amp;nbsp; ArcGIS 10.1 SP1 for Desktop Quality Improvement Patch&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure how this affects this strange bug where my program works one at a time but not in a batch. I've changed the query format as you suggested.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So after using the string format syntax example, instead of the update layer error (as per yesterday) it is giving me the older query format error again:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Executing: batchMap4PMV&lt;/P&gt;&lt;P&gt;Start Time: Fri Aug 08 08:04:35 2014&lt;/P&gt;&lt;P&gt;Running script batchMap4PMV...&lt;/P&gt;&lt;P&gt;checking out inset map placement: None&lt;/P&gt;&lt;P&gt;no inset map&lt;/P&gt;&lt;P&gt;beginning layer filter of data frameLayers&lt;/P&gt;&lt;P&gt;CROWN_LANDS_FILE = '2411100'&lt;/P&gt;&lt;P&gt;Tantalis Files&lt;/P&gt;&lt;P&gt;defined the lyr for Tantalis Files?&lt;/P&gt;&lt;P&gt;ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\batchMapRobot.py", line 80, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; runMapRobotScript(filenum, outfile)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\batchMapRobot.py", line 42, in runMapRobotScript&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.dataFrameFilter(obj.mainDF, obj.mainDefQry, inset_map)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\data\scripts\map_robot_2014_PMV_v2_4batch.py", line 163, in dataFrameFilter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION", defQry)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "e:\sw_nt\arcgis\desktop10.1\arcpy\arcpy\management.py", line 6498, in SelectLayerByAttribute&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to execute (batchMap4PMV).&lt;/P&gt;&lt;P&gt;Failed at Fri Aug 08 08:04:43 2014 (Elapsed Time: 8.00 seconds)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Aug 2014 15:21:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463089#M36295</guid>
      <dc:creator>JoshuaChan</dc:creator>
      <dc:date>2014-08-08T15:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: inconsistent Arcpy.Mapping behaviour</title>
      <link>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463090#M36296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suppose that if you manually apply the definition query &lt;SPAN style="font-family: 'courier new', courier;"&gt;CROWN_LANDS_FILE = '2411100'&lt;/SPAN&gt; to the layer, it works without any problems, right? If so, then the definition query is not the problem. It might be the layer itself or other aspects of the environment you're working in. Those are hard to solve without access to the data and mxd you're using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would probably step away from using of classes and rewrite the code using the da cursors and set the extent using the geometry rather than selecting and zooming to the extent of the selection.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Aug 2014 16:15:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/inconsistent-arcpy-mapping-behaviour/m-p/463090#M36296</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-08-08T16:15:56Z</dc:date>
    </item>
  </channel>
</rss>

