POST
|
Hi, I'm trying to debug a stand alone python script as written in http://webhelp.esri.com/arcgiSDEsktop/9.3/index.cfm?TopicName=Debugging_a_ToolValidator_class "Debugging in a Python editor" (page bottom) I thought I did things as described but what I don't understand is that if I call the script from the toolbox in ArcMap, it runs well, but if I launch the script from pythonwin, I get the following error : gp.savetolayerfile("arc", bdd + "arc.lyr") ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Layer: Dataset arc does not exist or is not supported Failed to execute (SaveToLayerFile). So it appears that I'm not in the ArcMap environment as I expected. What I would like to do is exactly what is described in the help "In some cases, you need to debug your code using a Python editor ..." Thanks for any help. Olivier
import arcgisscripting
import pyodbc
gp = arcgisscripting.create(9.3)
# ------------------------- TEMP Debug Tool Validator
gp.addtoolbox(r"D:... my toolbox.tbx")
params = gp.GetParameterInfo("script name") #
params[0].value = "value"
# Classe Tool validator
class ToolValidator:
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog."""
def __init__(self):
"""Setup the Geoprocessor and the list of tool parameters."""
import arcgisscripting as ARC
import pyodbc
bdd = "my folder"
mdb = bdd + "mybase.mdb"
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+mdb)
cursor = conn.cursor()
self.GP = ARC.create(9.3)
self.params = self.GP.getparameterinfo()
cursor.execute("SELECT .... my query")
rows = cursor.fetchall()
list = []
for row in rows:
list.append(row.name)
self.params[0].Filter.List=list
conn.close()
del rows,row,cursor,conn
def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
return
def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parmater
has been changed."""
return
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return
#--------------------------End tool validator
bdd = "my folder"
mdb = bdd + "mybase.mdb"
gp.workspace = mdb
gp.overwriteoutput = True
gp.savetolayerfile("arc", bdd + "arc.lyr") <---- ERROR
validator = ToolValidator()
validator.updateParameters()
validator.updateMessages()
... View more
02-20-2012
06:59 AM
|
0
|
0
|
1780
|
POST
|
I downloaded "FileGDB_API_VS2010_1_1.zip" and went thru but didn't find a sample about Vb .net. Of course I'll try by myself but if I can save time in order to find the very few first references/declarations, I would appreciate.
... View more
01-30-2012
07:02 AM
|
0
|
0
|
578
|
POST
|
Hi Vince, Thanks for your answer. I'm interested in using the FGDB API as I have an existing software that applies SQL Queries. My problem is that it's written in VB .net, I read that there was a wrapper to use API with VB.net but I don't find any example in the downloaded 1.1 API or elsewhere. If possible, I would appreciate any tiny example to get in. Olivieir.
... View more
01-29-2012
08:56 PM
|
0
|
0
|
578
|
POST
|
Hi, I would like to query a file geodatabase, mainly with SQL Queries applied to tables (I could use Python to query features if I need). 1) I first tried to use VB.NET Oldebdconnection but get the message "The Product License has not been initialized." How can I initialize it ? Is it really free ? I saw other threads in this forum and it doesn't appear very clear. 2) As I want to apply only SQL Queries, should I use API ? I saw that there is a wrapper for VB.net but I don't understand how to makes it works, could someone be so kind to add a short VB .net example ? Thanks very much, Olivier
... View more
01-29-2012
01:35 AM
|
0
|
8
|
1860
|
POST
|
Thanks Mathew ! I searched and didn't find this thread. So, instead of updating, I created a new shapefile. That does not work for everyone but is ok for what I wanted to do.
... View more
01-25-2012
07:33 AM
|
0
|
0
|
218
|
POST
|
Hi, I need to build a function that remove first and last point of lines. Soft works with SearchCursor but get 99999 error as soon as I try to use UpdateCursor. I think it could have a link with the Join but don't understand Error occurs on UpdateCursor call when placed after join and when getvalue when UpdateCursor placer before Join. Thanks for any help, Olivier ----------------------------- # Process: Make Feature Layer... gp.MakeFeatureLayer_management(arc_shp, arc_layer, "", "", "ID_ARC ID_ARC VISIBLE NONE") gp.MakeFeatureLayer_management(pnt_shp, pnt_layer, "", "", "ID_POINT ID_POINT VISIBLE NONE") #rows_arc = gp.UpdateCursor(arc_layer) #option 2 # Process: Add Join... gp.QualifiedFieldNames = "UNQUALIFIED" gp.AddJoin_management(arc_layer, "ID_ARC", tab_line, "ID_ARC", "KEEP_ALL") gp.AddJoin_management(pnt_layer, "ID_POINT", tab_point, "ID_POINT", "KEEP_ALL") rows_arc = gp.UpdateCursor(arc_layer) #option 1 desc_arc = gp.describe(arc_layer) row_arc = rows_arc.Next() while row_arc: feat_arc=row_arc.getvalue(desc_arc.ShapeFieldName) # Get feature geometry ---------------------- So When I set option 1, UpdateCursor after join I get the error on the update call rows_arc = gp.UpdateCursor(arc_layer) RuntimeError: ERROR 999999: Error executing function. When I set option 1, Option 2 : UpdateCursor before join, I get the error at this line feat_arc=row_arc.getvalue(desc_arc.ShapeFieldName) RuntimeError: ERROR 999999: Error executing function. (I listed field names after join, they are all there and I tried directly to set "arc.Shape" but it did'nt work.
... View more
01-20-2012
12:42 AM
|
0
|
2
|
437
|
POST
|
Hi Frederic, Thanks for this kind answer, it will improve my basic python knowledge. I hoped that vertices would be an attribute of each line feature but it amazingly seems that it's not the case. Happy New Year, Olivier
... View more
01-02-2012
01:09 AM
|
0
|
0
|
210
|
POST
|
Hi, I'm searching a way to get the number of vertices composing a line, without counting them. I have not many experiences in Python, but unless I missed something searching forums and documentation, it seems that it's not a feature property as I expected. Am I right ? Thanks to all answers Olivier
... View more
01-01-2012
09:38 AM
|
0
|
2
|
807
|
POST
|
I didn't get my coffee too, I thought previous answer was Chris's, sorry Logan. Thanks to both of you, you helped much ! Olivier
... View more
10-25-2011
09:49 AM
|
0
|
0
|
381
|
POST
|
I have a script that works using row.SetValue("y",pnt.y) rows.UpdateRow(row) y field must exists before like Hornbydd said Olivier
... View more
10-25-2011
09:13 AM
|
0
|
0
|
213
|
POST
|
That's ok. Sorry for being stupid, OidFieldName sounded strange to me but I didn't thank further. Thanks very much for your help Chris ! Olivier
... View more
10-25-2011
09:00 AM
|
0
|
0
|
381
|
POST
|
Hi Chris, Thanks for your answer. It seems to work but the problem is that after I used partcount =feat.PartCount # Count the number of points in the current multipart feature and I get this message : AttributeError: 'int' object has no attribute 'PartCount' That means that the feat objet I get is not the same 'shape' ?
... View more
10-25-2011
08:34 AM
|
0
|
0
|
381
|
POST
|
Hi Can someone be so kind to explain why when I use those lines rows = gp.SearchCursor(infc) row = rows.Next() feat=row.shape it works when infc is a shapefile but not when it's a layer ? In this case, I get "Field shape does not exist" even if it exists when I open attributes in ArcView. Thanks very much, sorry for a such basic question, Olivier
... View more
10-25-2011
04:06 AM
|
0
|
6
|
529
|
POST
|
Hi, I have an existing SDE 9.2 database and I know that ArcSde 9.2 stores coordinates as a positive integer. I can't find how could I know the resolution and the extent used to create original layer. Can someone help me ? Thanks very much, Olivier
... View more
09-07-2011
02:14 AM
|
0
|
6
|
904
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|