Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I use the Model builder to run my model and I have question

Sub M()
' Create the Geoprocessor object
Dim gp As Object
Set gp = CreateObject("esriGeoprocessing.GPDispatch.1")

' Check out any necessary licenses
gp.CheckOutExtension "spatial"

' Load required toolboxes...
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx"
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx"
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx"


' Local variables...
Dim Output_Features As String
Dim Output_point_features As String
Dim Layer_Name_or_Table_View As String
Dim Kriging_poin3 As String
Dim Output_variance_of_prediction_raster As String
Dim dbtexts_mdb As String
Dim ws As String
Dim dbtexts_mdb__2_ As String
Output_Features = "C:\temp2\RasterT_Kriging1.shp"
Output_point_features = "C:\temp2\RasterT_Kriging1.shp"
Layer_Name_or_Table_View = "ws_Layer"
Kriging_poin3 = "C:\temp2\kriging_poin3"
Output_variance_of_prediction_raster = ""
dbtexts_mdb = "C:\dbtexts.mdb"
ws = "C:\dbtexts.mdb\ws"
dbtexts_mdb__2_ = "C:\dbtexts.mdb"

' Process: Make XY Event Layer...
gp.MakeXYEventLayer_management ws, "x", "y", Layer_Name_or_Table_View, ""

' Process: Kriging...
gp.Kriging_sa Layer_Name_or_Table_View, "data", Kriging_poin3, "Spherical 249.101224",     "250", "VARIABLE 12", Output_variance_of_prediction_raster

' Process: Raster to Point...
gp.RasterToPoint_conversion Kriging_poin3, Output_point_features, "Value"

' Process: Add XY Coordinates...
gp.AddXY_management Output_point_features

' Process: Table to Geodatabase (multiple)...
gp.TableToGeodatabase_conversion "C:\temp2\RasterT_Kriging1.shp", dbtexts_mdb__2_

End Sub

in the sub I have parameters but I want it to run with the data I have

can I just like VB give it a do loop and make it run itself?

share|improve this question
    
@artwork21 VBA's button click will be the trigger, I will change the data grab from geodatabase and put it back the same geodatabase –  blueman010112 Jun 24 '11 at 12:34
    
@blueman010112, can you elaborate more on how you want a do loop to run the code and what event will trigger your code/model to run, running the model manually, UI Control click, UI Tool mouse down, form button click, looking for data either present in the ArcMap TOC or data present in a certain folder? –  artwork21 Jun 24 '11 at 12:36
    
@blueman010112, what will you be using the do loop for? –  artwork21 Jun 24 '11 at 12:38
    
@artwork21 change the data grab from geodatabase and put it back the same geodatabase I think,change the field in the kriging,change the output table name in the database –  blueman010112 Jun 24 '11 at 12:49
    
the maximum value of my fields will be 20 and the table name can be change in the same values the table name maybe numbern and the field's name is also be numbern and 'code'do until n =20 n=n+1 'the model run end do'code' –  blueman010112 Jun 24 '11 at 13:10
show 1 more comment

1 Answer

up vote 2 down vote accepted

Based on what I can deduct from your example you are running geoprocessing tools (or models) from inside a VB procedure. (Not using a model builder to run your model)

To answer your question; Yes you can use a "for next" or whatever other loop to iterate however many times you want and change the values of the parameters in either the model or the geoprocessing tools you are calling every time you loop. Works fine for me.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.