Problems with Parse Path

659
2
Jump to solution
09-02-2013 08:02 AM
StefanPetersen
New Contributor
Hello Everyone,

I'm having trouble with Parse Path. I have created a model, that iterates over multivalues. I need to to drag - drop a lot of different layers, that are stored at a lot of different locations from arcmap into the parameter dialogue of the model. I need the model to parse the name of each shapefile, which works fine, and I need the model to parse the path of each shapefile. I use the Parse Path tool, set the parameters to Path, but I only get empty outputs.
When I open the ArcToolbox from ArcCatalogue and run the model from there, it works, but I can not browse to hundred of different shapes at lots of different locations and add them step for step to the dialogue box. That will take hours.
So I need the convienience to run the model from arcmap, I need to open the layerfile in arcmap and drag drop all contents to the dialogoue box and run the model.

I would really appreciate some help on that issue, as it's driving me crazy.

Thanks a lot!!
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor

So I need the convienience to run the model from arcmap, I need to open the layerfile in arcmap and drag drop all contents to the dialogoue box and run the model.


I don't believe this is true -- you should be able to drag a shapefile from ArcMap's Catalog Window - or ArcCatalog, if you have it open - directly on to the ArcMap model tool dialog if the model element type is Feature Layer.

If you want to provide a layer and get the path, you can use the Calculate Value tool to get it. It requires a small Python script:

Expression:
getpath(r"%input layer%")


Code block:
def getpath(lyr):   import arcpy   return arcpy.Describe(lyr).catalogPath


Speaking of convenience: have you considered using the Model Builder iterator tool Iterate Feature Classes? If all your shape files are within a folder tree, you can let an iterator tool go find them instead of you. The iterator can use a wild card to filter your shapefiles by name, for example "box*.shp". (ModelBuilder iterator tools were introduced at 10.0.)

Hope this helps you out.

View solution in original post

0 Kudos
2 Replies
curtvprice
MVP Esteemed Contributor

So I need the convienience to run the model from arcmap, I need to open the layerfile in arcmap and drag drop all contents to the dialogoue box and run the model.


I don't believe this is true -- you should be able to drag a shapefile from ArcMap's Catalog Window - or ArcCatalog, if you have it open - directly on to the ArcMap model tool dialog if the model element type is Feature Layer.

If you want to provide a layer and get the path, you can use the Calculate Value tool to get it. It requires a small Python script:

Expression:
getpath(r"%input layer%")


Code block:
def getpath(lyr):   import arcpy   return arcpy.Describe(lyr).catalogPath


Speaking of convenience: have you considered using the Model Builder iterator tool Iterate Feature Classes? If all your shape files are within a folder tree, you can let an iterator tool go find them instead of you. The iterator can use a wild card to filter your shapefiles by name, for example "box*.shp". (ModelBuilder iterator tools were introduced at 10.0.)

Hope this helps you out.
0 Kudos
StefanPetersen
New Contributor
Hello curtvprice,

thanks a lot for your reply. I could find a workaround using the pythonscript you've sent. Thanks a lot!!!

I wish you a great day!

Stefan
0 Kudos