Hello,
I'm trying to create a model builder to save the layer file (.lyrx) in the same path of the data source.
Using the parse path the output path is the project folder and not the data source folder path.
here below an image of the model builder.
Someone can help please.
Solved! Go to Solution.
I would start here, there's a useful walk through and some code snippets which should familiarise you with what you want to do
Five python code snippets for arcgis pro
Also, the help page for every geoprocessing tool that you might ever have wanted to drag into model builder incldues a python snippet and example to show how to use it.
In broad terms then your python process will effectively be a case of listing the layers in your map, creating a for loop and saving to a layer file for each.
The iterate layers tool will return that path as that;s where the layer lives.
If you want the actual data source then look at making a workspace (the folder containing your data) your input variable (rather than a map) and iterating datasets then parsing that path.
Alternatively have a look at python and listLayers, which will give you much more flexibility and the ability to interrogate all the layer properties, including data source.
Thanks, but using the iterate workspace I can't use the tool save to layer file.
Ah yeah, that;s fair. I would definitely look into python then. I realise it can be daunting at first, but honestly once you get going and you see the possibilities, you'll never look back at model builder.
Ok. i'll try in python. I never used before, any suggestion that can guide me to solve my problem?
I would start here, there's a useful walk through and some code snippets which should familiarise you with what you want to do
Five python code snippets for arcgis pro
Also, the help page for every geoprocessing tool that you might ever have wanted to drag into model builder incldues a python snippet and example to show how to use it.
In broad terms then your python process will effectively be a case of listing the layers in your map, creating a for loop and saving to a layer file for each.
More resources for learning Python in ArcGIS Pro can be found here:
https://learn.arcgis.com/en/paths/learn-python-in-arcgis-pro/