POST
|
Hi everyone I've just started to use ArcMap 10 (worked so far on 9.3.1) and I'm having basic problem with editing. I didn't find where to choose the layer to edit. In the previous version it was on the editor toolbar, but here I can't find it anywhere... Thanx a lot, Yair when you start an editing session the create features window should appear with templates of all editable layers that are visible, a draw back to teen is a layer must be visible to edit it read the help on templates, it is the way 10 handles layers and you can add the target tool back to your editor tool bat in ten by customizing the toolbar, butit can cause problems with the templates as we have found
... View more
04-28-2011
04:10 AM
|
0
|
0
|
237
|
POST
|
How do I get a count of the selected features in a Layer using python? use the getcount you have to change the getcount result to an integer: ALyr = arcpy.mapping.ListLayers(IMXD,"address_point")[0]
arcpy.SelectLayerByAttribute_management(ILyr, "NEW_SELECTION", SheetQry)
## Test for slected address points
NumS = str(arcpy.GetCount_management(ALyr))
Num = int(NumS)
print Num or a string: arcpy.SelectLayerByAttribute_management(ILyr, "NEW_SELECTION", SheetQry)
Num = str(arcpy.GetCount_management(ILyr))
if Num == "0":
arcpy.AddMessage("!! NO CORRESPONDING PLSS AREA EXISTS FOR THIS REQUEST !!")
... View more
04-26-2011
11:22 AM
|
0
|
0
|
2855
|
POST
|
well, it seems the workspace had to be set with the sde connection in order for it to write to the layer this is how the workspace is set, does anyone know a less ugly way? SDEInfo = BLLyr.serviceProperties
UserInfo = str(SDEInfo.get('UserName'))
UserInfoSplt = UserInfo.split("\\")
User = UserQ.rstrip('"')
User = User.lower()
IWork = r"C:\\Documents and Settings\\%s\\Application Data\\ESRI\\Desktop10.0\\ArcCatalog\\%s@propertyappraisal.vgisdb1.sde"%(User, User)
arcpy.env.workspace = IWork
... View more
04-21-2011
01:04 PM
|
0
|
0
|
379
|
POST
|
our sde database is versioned, the layer i am trying to write to is from a database connection with rights to edit the data can python write to sde versioned data if done within an editing session?
... View more
04-21-2011
06:51 AM
|
0
|
0
|
379
|
POST
|
maybe there is another way to do what i want, copy lines from a geoprocessing output into a sde feature class in arcmap currently the output is being written to a file geodatabase
## Import standard modules
import sys, os
## Set the necessary product code
import arcinfo
## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env
## Overwrite pre-existing files
arcpy.env.overwriteOutput = True
## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]
try:
for ILayer in arcpy.mapping.ListLayers(IMXD):
if ILayer.name == "AGHXL":
arcpy.mapping.RemoveLayer(DF, ILayer)
except:
arcpy.GetMessages()
## Refresh map
arcpy.RefreshTOC()
arcpy.RefreshActiveView
## Set Relevant Layers
ALyr = arcpy.mapping.ListLayers(IMXD,"address_point")[0]
BLLyr = arcpy.mapping.ListLayers(IMXD,"Basemap_Line")[0]
try:
## Test for slected address points
NumS = str(arcpy.GetCount_management(ALyr))
Num = int(NumS)
if Num > 1000:
# print "Please select an address point"
arcpy.AddMessage("PLEASE SELECT AN ADDRESS POINT")
elif Num > 1 and Num < 1000:
# print "Please select only one address point"
arcpy.AddMessage("PLEASE SELECT ONLY ONE ADDRESS POINT")
else:
## Get the XY of the selected address point
ACur = arcpy.SearchCursor(ALyr)
for ARow in ACur:
ACenter = ARow.shape.centroid
AX = ACenter.X
AY = ACenter.Y
## Set the corners for the AGHX polygon
PNT1X = AX - 12.5
PNT1Y = AY + 12.5
PNT2X = AX + 12.5
PNT2Y = AY + 12.5
PNT3X = AX + 12.5
PNT3Y = AY - 12.5
PNT4X = AX - 12.5
PNT4Y = AY - 12.5
PNT1 = r"%s,%s"%(PNT1X, PNT1Y)
PNT2 = r"%s,%s"%(PNT2X, PNT2Y)
PNT3 = r"%s,%s"%(PNT3X, PNT3Y)
PNT4 = r"%s,%s"%(PNT4X, PNT4Y)
BArray = arcpy.Array()
COORDS = [PNT1, PNT2, PNT3, PNT4]
for COORDPAIR in COORDS:
X, Y = COORDPAIR.split(",")
X = float(X)
Y = float(Y)
PNT = arcpy.Point(X,Y)
BArray.add(PNT)
BArray.add(BArray.getObject(0))
NPolygon = arcpy.Polygon(BArray)
arcpy.FeatureToLine_management(NPolygon, "C:\\WorkSpace\\GeoProcessingTemp.gdb\\ScratchData\\AGHXL","","NO_ATTRIBUTES")
del ACur, ARow
SourceData = "C:\\WorkSpace\\GeoProcessingTemp.gdb\\ScratchData\\AGHXL"
AGHXLayer = arcpy.MakeFeatureLayer_management(SourceData,"AGHXL")
arcpy.SetParameterAsText(0,NPolygon)
arcpy.SetParameterAsText(1, AGHXLayer)
## Refresh map
arcpy.RefreshTOC()
arcpy.RefreshActiveView
except:
arcpy.GetMessages()
... View more
04-20-2011
12:38 PM
|
0
|
0
|
379
|
POST
|
in a python script ## THIS WORKS IN AN EDITING SESSION ON A FILE GEODATABASE FEATURE CLASS
arcpy.Append_management(SourceData,TLyr,"NO_TEST")
## THIS DOES NOT WORK FOR AN SDE DATABASE FEATURECLASS
arcpy.Append_management(SourceData,BLLyr,"NO_TEST") the error returned is: Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000210: Cannot create output \propertyappraisal.DBO.PA_Basemap\propertyappraisal.DBO.basemap_arc Failed to execute (Append). is there a way around this?
... View more
04-20-2011
09:45 AM
|
0
|
4
|
812
|
POST
|
fixed, had to add the parameters to the script: ## Capture the Section, Township, and Range
SLyr = arcpy.mapping.ListLayers(IMXD,"PLSS",LDF)[0]
arcpy.MakeFeatureLayer_management("PA_Index","SIndex")
arcpy.SelectLayerByLocation_management (SLyr,"INTERSECT", "SIndex", -100)
arcpy.MakeFeatureLayer_management("PLSS","STR")
arcpy.RefreshTOC()
## FIXED IT HERE
SIndex = arcpy.GetParameterAsText(2)
STR = arcpy.GetParameterAsText(3)
arcpy.SelectLayerByLocation_management(SLyr,"INTERSECT", "SIndex", -100,"REMOVE_FROM_SELECTION")
SSTR = arcpy.SearchCursor("STR")
for str in SSTR:
TWN = str.twn
RNG = str.rng
del SSTR, str
SSTR = arcpy.SearchCursor("STR")
SEC1 = SSTR.next()
SECLIST = []
while SEC1:
SECVAL =SEC1.getValue("sec")
if SECVAL not in SECLIST:
SECLIST.append(SECVAL)
SEC1 = SSTR.next()
del SSTR, SEC1
SECLIST.sort()
SEC = r"%s"%(SECLIST)
SEC = SEC.lstrip('[')
SEC = SEC.rstrip(']')
... View more
04-08-2011
01:05 PM
|
0
|
0
|
405
|
POST
|
you may be going about this a more difficult way than necessary in arccatalog go to the database connection, go to the table, preview it than select the export table from the options and direct it to a personal geodatabase
... View more
04-08-2011
10:34 AM
|
0
|
0
|
257
|
POST
|
still not working i added arcpy.RefreshTOC() hoping that would help and put the new layers into the script properties as derived output layers parameters and the new layers still do not get added to the mxd when run from model builder but will in the python window?? i'm trying to get a new layer of selected polygons to run a search cursor on, is there another way to doe this? where the model bails i get <type 'exceptions.IndexError'>: list index out of range Failed to execute ## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env
## Overwrite pre-existing files
arcpy.env.overwriteOutput = True
## Set the workspace
# IWork = r"G:\AGIS\PDFs\TestParcelMap"
IWork = arcpy.GetParameterAsText(1)
arcpy.env.workspace = IWork
## Sets the MXD file to the current ArcMap MXD, if run out of ArcMap use the full path to the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
# IMXD = arcpy.mapping.MapDocument("G:\\AGIS\\PDFs\\TestParcelMap\\Parcel_Map_Test.mxd")
## Set Data Frames for the layer to select from
MDF = arcpy.mapping.ListDataFrames(IMXD, "Main Map")[0]
SDF = arcpy.mapping.ListDataFrames(IMXD, "Subinset")[0]
LDF = arcpy.mapping.ListDataFrames(IMXD, "Local Indicator")[0]
## Set the Index layers
ILyr = arcpy.mapping.ListLayers(IMXD,"PA_Index",MDF)[0]
ILyrL = arcpy.mapping.ListLayers(IMXD,"PA_Index",LDF)[0]
## Set the Sheet Number
Sheet = arcpy.GetParameterAsText(0)
# Sheet = 7429
## Create the SQL Query for the sheet number
SheetQry = r"SHEETNUM2 = '%s'"%(Sheet)
## Select the Index Sheet
arcpy.SelectLayerByAttribute_management(ILyr, "NEW_SELECTION", SheetQry)
arcpy.SelectLayerByAttribute_management(ILyrL, "NEW_SELECTION", SheetQry)
## Get and set the Scale
try:
ICur = arcpy.SearchCursor(ILyrL,SheetQry)
for IRow in ICur:
MScale = IRow.PARCELMAP
except:
arcpy.GetMessages()
del ICur
del IRow
MScale = int(MScale)
## Set the Data Frame scales
MDF.scale = MScale * 12
SDF.scale = MScale * 38
LDF.scale = MScale * 300
## Get Extent of Selected Sheet
IExt = ILyr.getSelectedExtent()
## Pan to selected extent
MDF.panToExtent(IExt)
SDF.panToExtent(IExt)
LDF.panToExtent(IExt)
## THIS IS THE BLOCK THAT FAILS IN MODEL BUILDER
## Capture the Section, Township, and Range
SLyr = arcpy.mapping.ListLayers(IMXD,"PLSS",LDF)[0]
arcpy.MakeFeatureLayer_management("PA_Index","SIndex")
arcpy.SelectLayerByLocation_management (SLyr,"INTERSECT", "SIndex", -100)
arcpy.MakeFeatureLayer_management("PLSS","STR")
arcpy.RefreshTOC()
arcpy.SelectLayerByLocation_management(SLyr,"INTERSECT", "SIndex", -100,"REMOVE_FROM_SELECTION")
## THIS IS THE LINE WHERE IT FAILS
SIndex = arcpy.mapping.ListLayers(IMXD, "SIndex", LDF)[0]
# arcpy.mapping.RemoveLayer(LDF,SSheet)
# SSTR = arcpy.SearchCursor("STR")
# for str in SSTR:
# TWN = str.twn
# RNG = str.rng
# del SSTR
# SSTR = arcpy.SearchCursor("STR")
# SEC1 = SSTR.next()
# SECLIST = []
# while SEC1:
# SECVAL =SEC1.getValue("sec")
# if SECVAL not in SECLIST:
# SECLIST.append(SECVAL)
# SEC1 = SSTR.next()
# del SSTR, SEC1
# SECLIST.sort()
# SEC = r"%s"%(SECLIST)
# SEC = SEC.lstrip('[')
# SEC = SEC.rstrip(']')
# SSLyr = arcpy.mapping.ListLayers(IMXD, "STR", LDF)[0]
# arcpy.mapping.RemoveLayer(LDF,SSLyr)
## THIS IS WHERE IT PICKS UP
... View more
04-08-2011
09:40 AM
|
0
|
0
|
405
|
POST
|
change this: mxd.findAndReplaceWorkspacePaths(r"X:\ArcGIS\OLD.gdb\Old_Units", r"Database Connections\server.sde\SDE.DBO.New_Units") to this: mxd.findAndReplaceWorkspacePaths(r"X:\ArcGIS\OLD.gdb\Old_Units", r"Database Connections\server.sde", False)
... View more
04-08-2011
09:19 AM
|
0
|
0
|
736
|
POST
|
is your sde database sql server? you should be able to just export it to an access database directly from arccatalog and/or arcmap
... View more
04-06-2011
09:52 AM
|
0
|
0
|
257
|
POST
|
i wrote a script that exports a pdf of an mxd based on a value in a polygon dataset, the script runs fine if run from python window in arcmap with all the values for GetParameterAsText hardcoded, AND it runs fine in model builder with an iterataion on a dbf file EXCEPT for one block of code in the attached code the section that does not run is commented out starting with ## THIS IS WHERE IT FAILS IN MODEL BUILDER and ending with ## THIS IS WHERE IT PICKS UP, by running chunks of the script in the model the failure is the arcpy.MakeFeatureLayer_management command, if run alone from the python window the command works and two new layers are added to the active data frame, but when run in the model no new layers are added ## THIS COMMAND IS IGNORED?? , does anyone no why? the error i get is <type 'exceptions.IndexError'>: list index out of range Failed to execute (Export Parcel Maps). ## Import standard modules
import sys, os
## Set the product code
import arcinfo
## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env
## Overwrite pre-existing files
arcpy.env.overwriteOutput = True
## Set the workspace
IWork = arcpy.GetParameterAsText(1)
arcpy.env.workspace = IWork
# IWork = r"G:\AGIS\PDFs\TestParcelMap"
## Sets the MXD file to the current ArcMap MXD, if run out of ArcMap use the full path to the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
# IMXD = arcpy.mapping.MapDocument("G:\\AGIS\\PDFs\\TestParcelMap\\Parcel_Map_Test.mxd")
## Set Data Frames for the layer to select from
MDF = arcpy.mapping.ListDataFrames(IMXD, "Main Map")[0]
SDF = arcpy.mapping.ListDataFrames(IMXD, "Subinset")[0]
LDF = arcpy.mapping.ListDataFrames(IMXD, "Local Indicator")[0]
## Set the Index layers
ILyr = arcpy.mapping.ListLayers(IMXD,"PA_Index",MDF)[0]
ILyrL = arcpy.mapping.ListLayers(IMXD,"PA_Index",LDF)[0]
## Set the Sheet Number
Sheet = arcpy.GetParameterAsText(0)
# Sheet = 7429
## Create the SQL Query for the sheet number
SheetQry = r"SHEETNUM2 = '%s'"%(Sheet)
## Select the Index Sheet
arcpy.SelectLayerByAttribute_management(ILyr, "NEW_SELECTION", SheetQry)
arcpy.SelectLayerByAttribute_management(ILyrL, "NEW_SELECTION", SheetQry)
## Set the Scale
# MScale = arcpy.GetParameterAsText(2)
# MScale = int(MScale)
MScale = 200
## Set the Data Frame scales
MDF.scale = MScale * 12
SDF.scale = MScale * 38
LDF.scale = MScale * 400
## Get Extent of Selected Sheet
IExt = ILyr.getSelectedExtent()
## Pan to selected extent
MDF.panToExtent(IExt)
SDF.panToExtent(IExt)
LDF.panToExtent(IExt)
## THIS IS WHERE IT FAILS IN MODEL BUILDER
## Capture the Section, Township, and Range
SLyr = arcpy.mapping.ListLayers(IMXD,"PLSS",LDF)[0]
## THIS COMMAND IS IGNORED??
arcpy.MakeFeatureLayer_management("PA_Index","SELSHEET")
arcpy.SelectLayerByLocation_management (SLyr,"INTERSECT", "SELSHEET", -10)
## THIS COMMAND IS IGNORED??
arcpy.MakeFeatureLayer_management("PLSS","STR")
arcpy.SelectLayerByLocation_management(SLyr,"INTERSECT", "SELSHEET", -10,"REMOVE_FROM_SELECTION")
## THIS IS WHERE IT WILL ERROR OUT
# SSheet = arcpy.mapping.ListLayers(IMXD, "SELSHEET", LDF)[0]
# arcpy.mapping.RemoveLayer(LDF,SSheet)
# SSTR = arcpy.SearchCursor("STR")
# for str in SSTR:
# TWN = str.twn
# RNG = str.rng
# del SSTR
# SSTR = arcpy.SearchCursor("STR")
# SEC1 = SSTR.next()
# SECLIST = []
# while SEC1:
# SECVAL =SEC1.getValue("sec")
# if SECVAL not in SECLIST:
# SECLIST.append(SECVAL)
# SEC1 = SSTR.next()
# del SSTR, SEC1
# SECLIST.sort()
# SEC = r"%s"%(SECLIST)
# SEC = SEC.lstrip('[')
# SEC = SEC.rstrip(']')
## THIS IS WHERE IT PICKS UP
# SSLyr = arcpy.mapping.ListLayers(IMXD, "STR", LDF)[0]
# arcpy.mapping.RemoveLayer(LDF,SSLyr)
## Set the Sheet Number
for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
if SheetNum.text == "SHEET 0000":
SheetNum.text = r"SHEET %s"%(Sheet)
## COMMENTED OUT DUE TO FAIL
## Set the Sheet Number and SEC, TWN, RNG
# for SecNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
# if SecNum.text == "SECTION: 00":
# SecNum.text = r"SECTION: %s"%(SEC)
# for TRNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
# if TRNum.text == "TWP 00 S RNG 00 E":
# TRNum.text = r"TWP %s S RNG %s E"%(TWN, RNG)
## Refresh data farame
arcpy.RefreshActiveView
## Set the name for the PDF
Output = r"%s\P%s.pdf"%(IWork, Sheet)
## Export the map to PDF
arcpy.mapping.ExportToPDF(IMXD, Output)
## Set the Text Elements back
for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
if SheetNum.text == r"SHEET %s"%(Sheet):
SheetNum.text = "SHEET 0000"
## COMMENTED OUT DUE TO FAIL
# for SecNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
# if SecNum.text == r"SECTION: %s"%(SEC):
# SecNum.text = r"SECTION: 00"
# for TRNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
# if TRNum.text == r"TWP %s S RNG %s E"%(TWN, RNG):
# TRNum.text = r"TWP 00 S RNG 00 E"
... View more
04-06-2011
07:48 AM
|
0
|
3
|
509
|
POST
|
this is clunky but it works, the text element was set to SHEET 0000 on the mxd then ran this code: ## Set the Sheet Number
Sheet = arcpy.GetParameterAsText(0) # 7001 for example
## Set the Sheet Number
for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
if SheetNum.text == "SHEET 0000":
SheetNum.text = r"SHEET %s"%(Sheet)
## Export the map to PDF
arcpy.mapping.ExportToPDF(IMXD, Output)
## Set the Sheet Number back
for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
if SheetNum.text == r"SHEET %s"%(Sheet):
SheetNum.text = "SHEET 0000"
... View more
03-31-2011
01:06 PM
|
0
|
0
|
436
|
POST
|
This looks to be a bug with the ListLayoutElements function. The "SHEET*" wildcard should be returning the text elements that begin with "SHEET". I would recommend reporting this to tech support so they can document this bug. I haven't been able to find a workaround yet, but I'll keep looking a little bit longer. thank you for your time, any help would be greatly appreciated i tried adding it as a title intstead, is there a way to change a title in arcpy?
... View more
03-31-2011
09:50 AM
|
0
|
0
|
436
|
POST
|
You will need to add 'arcpy.RefreshActiveView()' at the end of your code. Try the following: import arcpy mxd = arcpy.mapping.MapDocument(r"CURRENT") for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "*SHEET*"): if elm.type == "TEXT_ELEMENT": elm.text = "SHEET 7001" arcpy.RefreshActiveView() Note: I also had to add an '*' in front of SHEET for the wildcard to work correctly. if i add an asterisk before SHEET than every text element gets selected, please see picture is there a way to put a Like operator for python? for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT", "*SHEET*"):
if SheetNum.text LIKE "SHEET*"
SheetNum.text = "SHEET <Some Number>" edit: i thought maybe the element could be captured by it's location, but this also returns nothing >>> for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT", "*SHEET*"): ... if SheetNum.text == "SHEET 2156": ... print SheetNum.elementPositionX ... 38.926 >>> for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT", "*SHEET*"): ... if SheetNum.elementPositionX == 38.926: ... print SheetNum.text ... >>> for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT", "*SHEET*"): ... if SheetNum.elementPositionX == "38.926": ... print SheetNum.text
... View more
03-31-2011
07:41 AM
|
0
|
0
|
436
|
Title | Kudos | Posted |
---|---|---|
1 | 01-22-2016 10:12 AM | |
1 | 01-14-2016 11:31 AM | |
1 | 08-17-2011 12:28 PM | |
16 | 09-04-2015 08:57 AM | |
1 | 01-18-2011 09:42 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|