Editing a layer in modelbuilder

1423
11
10-11-2019 07:08 AM
SLouq
by MVP Regular Contributor
MVP Regular Contributor

I have created 3 models in mobelbuilder to accomplish one task. However I would like to do away with the 3 separate models and just combine all into one model. The problem I am having is I can't get the second part of the model to work unless I add the shapefile I edited in the first part of the model back into the map. The message it is giving me is 'All inputs are not current'. I am trying to use the Select Layer by Attribute tool.

How can I keep all inputs current so the model doesn't quit after the first step?

Thanks,

Scott

0 Kudos
11 Replies
RobertBorchert
Frequent Contributor III

have you tried putting all the steps in one model and using pre-conditions before the next step starts.


You should also then be able to direct link to the shapefile

0 Kudos
SLouq
by MVP Regular Contributor
MVP Regular Contributor

Yes I have preconditions set to the last variable in the first step.

I think the reason the model stops is because the first step takes the shapefile out the map while it is running and the second step won't start unless the shapefile is in the map.

I am trying to get the model to run through each step on its own without me having to babysit it and put the layer back in the map after each step 

0 Kudos
RobertBorchert
Frequent Contributor III

What I have done when models get complicated is to export them as Python scripts. you may be able to export all three of yours to python.  You should be able to go to the script for the third tool and specify in the variables the exact location of the shape file.

0 Kudos
RobertBorchert
Frequent Contributor III

Have you tried working it as a feature class in a database instead?

Out of curiosity what is the task?

0 Kudos
SLouq
by MVP Regular Contributor
MVP Regular Contributor

That's what I am coming try right now

Thanks,

Scott

0 Kudos
RobertBorchert
Frequent Contributor III

I just tried a variation. I added calculate field to the model.  double clicked the calculate field and made what I wanted. I closed it and it added the Feature Class to the model.

then I used the ADD DATA button to manually add the feature class back into the model.  Did a second function and used the inner model link to the recalled feature class.

This seems to work.  but my model was exceptionally basic

0 Kudos
SLouq
by MVP Regular Contributor
MVP Regular Contributor

Thanks Robert!

That's what I'm trying to be. 'Exceptionally basic' 

0 Kudos
RobertBorchert
Frequent Contributor III

I renamed the second instance of the feature as AddressPointsAgain

This is what it did in python.  It calls the same feature twice but calls them different things in the script. It then performs the Process's in the order they are in Python.  I am far from an expert in Python this is just an export from Model Builder

# Import arcpy module

import arcpy

 # Local variables:

AddressPointsAgain = "Database Connections\\PROD_GIS.sde\\GIS.AddressPoints\\GIS.AddressPoints"

GIS_AddressPoints__4_ = AddressPointsAgain

GIS_AddressPoints__2_ = "Database Connections\\PROD_GIS.sde\\GIS.AddressPoints\\GIS.AddressPoints"

GIS_AddressPoints__3_ = GIS_AddressPoints__2_

 

# Process: Calculate Field

arcpy.CalculateField_management(GIS_AddressPoints__2_, "LOCATION", "2", "VB", "")

 

# Process: Add Field

arcpy.AddField_management(AddressPointsAgain, "TEStField", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")

 

 

0 Kudos
SLouq
by MVP Regular Contributor
MVP Regular Contributor

if you got that far your better in Python than me.

0 Kudos