POST
|
Thanks Dan. Although this didn't work for me in this instance, I need to learn where I require brackets and where I don't. Rookie error. Thanks. As it turns out, and for whatever reason, I needed to be using CURRENT and not a reference to the mxd. The brackets were similarly important. So, the working code is: mxd = arcpy.mapping.MapDocument("CURRENT") #current mxd scaleBar = arcpy.mapping.ListLayoutElements(mxd,"MAPSURROUND_ELEMENT","ScaleBar1") #enforce working on "ScaleBar1". Can use wildcards when we have more. for item in scaleBar: print item.name #confirm that we are working on the only scalebar that's currently in the document if item.name == "ScaleBar1": item.elementPositionY = 1 arcpy.RefreshActiveView() print item.name #reconfirm we have entered the if statement with the name
... View more
09-18-2017
01:26 AM
|
0
|
1
|
389
|
POST
|
Thanks Dan Neither saving nor using arcpy.RefreshActiveView after the posted code seems to make a difference. That said, there's no errors either. RefreshActiveView returns <function RefreshActiveView at 0x255B32B0> which seems ok.
... View more
09-17-2017
01:14 PM
|
0
|
3
|
389
|
POST
|
I'm looking to shift a scale bar with Python, and as such have a small proof of concept script happening in a python console window. Using the below code, no matter the location given with elementPositionY, the scale bar does not seem to change location at all. My current mxd has a single scale bar named "ScaleBar1" My data frame has a geographic coordinate system set (not sure if this matters). I'm attempting to access the scale bar this way because ultimately I'll extend the for and if statements to work with multiple bars and some logic. I'm not a python coder, so please be gentle. My code: mxd = arcpy.mapping.MapDocument(r"C:\users\I5-Desktop\Documents\untitled.mxd") #current mxd scaleBar = arcpy.mapping.ListLayoutElements(mxd,"MAPSURROUND_ELEMENT","ScaleBar1") #enforce working on "ScaleBar1". Can use wildcards when we have more. for item in scaleBar: print item.name #confirm that we are working on the only scalebar that's currently in the document if item.name == "ScaleBar1": item.elementPositionY = 1 print item.name #reconfirm we have entered the if statement with the name What reason might there be for the scalebar not changing location? I can resolve its name, and enter a loop based on its name, etc.
... View more
09-17-2017
04:08 AM
|
0
|
5
|
710
|
POST
|
I'm hoping someone might be able to help me here: I am looking to calculate the difference between the timestamps in the current row of a table, and the preceding row. Then, if the difference exceeds a set amount, increment the number in the Journey_Number column by 1. At the moment I am dumping all my data to excel to do this, but it's very inefficient. Example data is below. At the moment I've worked out a model that can draw in related files, spit each out as a shapefile, then merge the shapefiles, reduce identical values, and sort by the timestamp field using regular toolbox items. In theory the data should be sorted at this point so that it's all sequential. This function, however, requires something more specific such as a python script - and I'm in over my head. Any help is appreciated (Given information) (Calculated Information) (Calculated Information) Timestamp Seconds_from_prior_line_to_this_line Journey_Number 2015-07-13T23:49:09Z 1 2015-07-13T23:49:17Z 8 1 2015-07-13T23:49:23Z 6 1 2015-07-13T23:49:24Z 1 1 2015-07-13T23:49:32Z 8 1 2015-07-13T23:49:44Z 12 1 2015-07-13T23:49:51Z 7 1 2015-07-13T23:49:59Z 8 1 2015-07-17T06:04:27Z 868 2 2015-07-17T06:05:02Z 35 2 2015-07-17T06:05:05Z 3 2
... View more
07-31-2017
03:13 PM
|
0
|
1
|
543
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|