POST
|
My script works as intended when the workspace and variables are set to a File Geodatabase, but not when connecting to SDE. The commented out lines show how the script runs when connecting to a File Geodatabase vs. my SDE setup. The end result is a csv file. Using the SDE setup calls the sub layer and outputs the correct results, but does not write out par layer results.
import arcpy
import getpass
#Workspace
#arcpy.env.workspace = "H:\\Python\\Python.gdb" #File Geodatabase
arcpy.env.workspace = "Database Connections\\Connection_to_sde2.sde" #SDE
#Variables
mxd = arcpy.mapping.MapDocument ("CURRENT")
df = arcpy.mapping.ListDataFrames (mxd)[0]
#sub = arcpy.mapping.ListLayers(mxd, "Subdivisions", df)[0] #File Geodatabase
#par = arcpy.mapping.ListLayers(mxd, "Parcels", df)[0] #File Geodatabase
sub = arcpy.mapping.ListLayers(mxd, "LIBRARIAN.Subdivisions", df)[0] #SDE
par = arcpy.mapping.ListLayers(mxd, "LIBRARIAN.Parcels", df)[0] #SDE
... View more
04-18-2014
06:02 AM
|
0
|
0
|
767
|
POST
|
I do not have permission to upgrade or access the server to rename the gx file. I am able to view the raster contents in ArcCatalog to see they exist in SDE. But, I am not able to preview or add the rasters in ArcMap. I believe this maybe some sort of license issue causing the mxds to crash.
... View more
11-05-2013
06:53 AM
|
0
|
0
|
1022
|
POST
|
I have MXDs that open in 9.3, but not in 10.2. The rasters were initially stored in SDE, but have been moved to another location. The MXDs should still open with broken data links for the rasters. What is causing the MXDs to open in 9.3, but not in 10.2? When attempting to use 10.2, the MXD either crashes or attempts to open the MXD until Task Manager forces ArcMap to close. Even more perplexing is the rasters within the 9.3 MXDs point to the initial SDE connection and the rasters display. How can the 9.3 rasters display after the have been moved from the SDE connection?
... View more
10-31-2013
06:34 AM
|
0
|
17
|
3586
|
POST
|
All, I have a script that works when the desired Feature Class is listed above Feature-Linked Annotations within ArcMap TOC. But, the script does not work when the Feature Class is displayed below Feature-Linked Annotations. What is the logic behind why this occurs? [ATTACH=CONFIG]27752[/ATTACH] [ATTACH=CONFIG]27753[/ATTACH]
... View more
09-25-2013
09:26 AM
|
0
|
5
|
3056
|
POST
|
jdrvar;330609 wrote: Well this is nothing like a Field Calculation, so of course the !TextString! won't work. I did not know you were going to this kind of script. Just use the updatecursor itself to do this. FieldName = arcpy.GetParameterAsText(0)
cursor = arcpy.da.UpdateCursor(History, [FieldName])
for row in cursor:
row[0] = "(" + row[0] + ")"
cursor.updateRow(row)
del row
del cursor The input parameter would be any text field name. So choose "TextString" in that parameter. Or forget the parameter and hard code the field name. cursor = arcpy.da.UpdateCursor(History, ["TextString"])
for row in cursor:
row[0] = "(" + row[0] + ")"
cursor.updateRow(row)
del row
del cursor I suppose I should have been more specific. Using your suggestion works! I just need to refresh to display the (). arcpy.RefreshActiveView()
... View more
09-20-2013
11:04 AM
|
0
|
0
|
471
|
POST
|
jdrvar;329266 wrote: I changed the text to match my field name. My field name is TextString. So, my line of script reads: "(" + !TextString! + ")"QUOTE] addParentheses = "(" + !TextString! + ")" returns a Syntax Error. I know the field name and type are correct, therefore, believed the expression to be correct. That left the concatenation of parentheses. But, the concatenation worked within Field Calculator. Then, I went back reread the posts and tried adding a second variable; expression = (!TextString!). Which also created a Syntax Error. So, I removed the exclamation points from the addParentheses variable. Removing the exclamation points, the script runs, and replaces existing text with parentheses. But, I want to concatenate the existing text with parentheses. Any suggestions?
TextString = arcpy.GetParameterAsText(0)
addParentheses = "(" + TextString + ")"
cursor = arcpy.da.UpdateCursor(History, ["TextString"])
for row in cursor:
row[0] = addParentheses
cursor.updateRow(row)
del row
del cursor
... View more
09-20-2013
06:45 AM
|
0
|
0
|
471
|
POST
|
I plan to use a selection within the MXD. So, I would only need to create the statement to add parentheses to the output. Thanks for all of your assistance.
... View more
09-16-2013
09:58 AM
|
0
|
0
|
471
|
POST
|
I have no idea what you think you were doing in the second calculation, but that version definitely should not work. Aren't you just using a single feature class for the anno? If two feature classes are involved you never mentioned that. Screen shot the table and the field calculator dialog set up you used with my original expression. I want to see exactly what you have and what you did. Use the Field Calculator field list to build the expression and to insert the field name in the calculation. Quotes should be fine, but so should single quotes (only for Python, not for VB Script). I am running a similiar script to copy & paste annotations, which is why I posted in this thread. The copy & paste part of my script works fine. I have two annotation Feature Classes, but only want the parentheses added to one Annotation Feature Class. Which, is why I attempted to specify the Feature Class to add the parentheses. I probably should have set up a conditional statement. Your suggestion of "(" + !TextString! + ")" works using Field Calculator. Parentheses are added to selected values within the TextString field.
... View more
09-16-2013
07:09 AM
|
0
|
0
|
471
|
POST
|
Than the text should be calculated to a simple Python calculation of: "(" + !AnnoText! + ")" where you are calculating the annotation text field and that text field name is AnnoText. Change AnnoText to match your actual annotation text field name. The same simple calculation in VB Script is: "(" & [AnnoText] & ")" I changed the text to match my field name. My field name is TextString. So, my line of script reads: "(" + !TextString! + ")" But, a Syntax Error is returned. Changing the outer double quotes to single quotes eliminates the syntax error, yet does not add the parentheses. I have a couple of Annotation Feature Classes with the field TextString. Then, I attempted to specify which Feature Class to apply the parentheses. '(" + (History)!TextString! + ")' The script does not have any errors. Yet, does not add the parentheses.
... View more
09-16-2013
05:39 AM
|
0
|
0
|
471
|
POST
|
In python to make an integer variable into a string with parentheses added around it you would do something like: parenInt = "(" + str(myInt) + ")" where myInt is an integer value variable and parenInt is a string of the interger surrounded by parantheses. The string is not working. I suspect that is because I asked the wrong question. I have an Annotation Feature Class that is displaying the information as integers within ArcMap, but the field type is a string.
... View more
09-13-2013
04:47 AM
|
0
|
0
|
469
|
POST
|
All, I am writing a similiar script. I need the output to have parentheses added around an integer. For example, instead of 31, I need the output to be (31). Where can I locate information on how to add parentheses?
... View more
09-12-2013
11:37 AM
|
0
|
0
|
469
|
POST
|
James: Can you create a feature class with a small subset of features (say 10) and then print out the fidset? It appears from Richard's last post that the semi-colon delimited string will need to be converted to a comma separated list. You shouldbe able to find python methods to easily perform that process. print "Data type: " +dsc.dataType Data type: FeatureLayer print "File path: " + dsc.path File path: C:\User\County\Personalworkspace.gdb print "Catalog path: " + dsc.catalogpath Catalog path: C:\User\County\Personalworkspace.gdb\Lot_Lines print "File name: " +dsc.file File name: Lot_Lines print "Base name: " + dsc.baseName Base name: Lot_Lines print "Name: " + dsc.name Name: Lot_Lines print dsc.shapeType Polyline Those all work, but when trying to run: print dsc.FidSet, no results are returned. Is that what you were meaning, Michael? I am now going to work on creating the comma separated list.
... View more
08-28-2013
10:03 AM
|
0
|
0
|
402
|
POST
|
I was thinking of using a zoom to centroid approach, since my field has multiple attributes with the same name. Also, if I am in zoomed in working on a feature class, I would use the zoom to centroid of my Subd field, and see the feature class at another scale.
... View more
08-09-2013
12:01 PM
|
0
|
0
|
628
|
POST
|
I have a Toolbar with five buttons created and loaded through Python Addin (ArcMap 10.1). The last tool has the image, shows the caption, but an error pops up when the tool is clicked. The Error reads, "Failed to open tool TRSearch.py(BCPAO.tbx). The name of the tool is TRSearch.py and is located within the BCPAO toolbox. The python script is saved within the same folder as the other scripts and the name is correct. All of the other buttons work. Any ideas why the TRSearch.py button does not work? I have included my Addin script. import arcpy
import pythonaddins
class ButtonClass(object):
"""Implementation for BCPAO_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pythonaddins.GPToolDialog(r'E:\User\Python\ArcGIS10.1_Scripts\BCPAO.tbx', 'ParcelSearch.py')
class ButtonClass1(object):
"""Implementation for BCPAO_addin.button_1 (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pythonaddins.GPToolDialog(r'E:\User\Python\ArcGIS10.1_Scripts\BCPAO.tbx', 'SectionSearch.py')
class ButtonClass2(object):
"""Implementation for BCPAO_addin.button_2 (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pythonaddins.GPToolDialog(r'E:\User\Python\ArcGIS10.1_Scripts\BCPAO.tbx', 'CalculateArea.py')
class ButtonClass3(object):
"""Implementation for BCPAO_addin.button_3 (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pythonaddins.GPToolDialog(r'E:\User\Python\ArcGIS10.1_Scripts\BCPAO.tbx', 'NameDate.py')
class ButtonClass4(object):
"""Implementation for BCPAO_addin.button_4 (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pythonaddins.GPToolDialog(r'E:\User\Python\ArcGIS10.1_Scripts\BCPAO.tbx', 'TRSearch.py')
... View more
08-01-2013
10:40 AM
|
0
|
1
|
4324
|
Online Status |
Offline
|
Date Last Visited |
03-21-2024
07:14 AM
|