Setting Python Tool Properties

3956
10
Jump to solution
10-12-2016 08:24 AM
TimHayes1
Occasional Contributor III

I am new to Python. I created a Python Toolbox - Tool Properties, I cannot change the Name, Label, and the Store Relative Pathnames is grayed out. How do I enable to these features?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
BrittneyWhite1
Esri Contributor

Sorry! I was referring to the How To: Batch export attachments from a feature class you are following. I suggest not creating a Python toolbox and create a Custom one instead. Here are the instructions for that: Creating a toolbox.

View solution in original post

10 Replies
DanPatterson_Retired
MVP Emeritus

Just to be sure... you are following the logic and process described in the help files beginning here...

Creating a new Python toolbox—Help | ArcGIS for Desktop 

0 Kudos
TimHayes1
Occasional Contributor III

I am using ArcGIS 10.2.2, and have never used Python before. I am using NotePad++ as my editor. The script was copied from here: How To: Batch export attachments from a feature class and savedas a .py file using Notepad. 

I followed the instructions for Creating a new Python Toolbox, all I need to do is make sure the box next to "Store Relative Paths" is checked. But, when I right click on Tool under the Toolbox.pyt and go to Properties, the "Store Relative Path Names" is grayed out. How do I get this so it is not grayed out and I can add a check in the box next to it.

I am totally new to Python. 

0 Kudos
BrittneyWhite1
Esri Contributor

I think the directions in the article you link to are for a custom toolbox (right-click New>Toolbox) instead of a Python Toolbox. Try with a custom toolbox and then follow steps 2 -6 in the article.

0 Kudos
TimHayes1
Occasional Contributor III
0 Kudos
BrittneyWhite1
Esri Contributor

Sorry! I was referring to the How To: Batch export attachments from a feature class you are following. I suggest not creating a Python toolbox and create a Custom one instead. Here are the instructions for that: Creating a toolbox.

TimHayes1
Occasional Contributor III

It worked! I was able to extract the attached photos on my local drive. THANKS!

0 Kudos
TimHayes1
Occasional Contributor III

One more thing, the photo attachments download, but their names include the Attachment ID at the front, like this:

ATT3_CIP Photographs_-1_0_ArcGISApp_1475269645362.jpg

Any idea how to auto-remove the "ATT3_" from the photo file name automatically?

I know I could do a Field Calculate on the Photo_ATTACH Table and add the "ATT3_" before each Photo. But is there a better way?

0 Kudos
curtvprice
MVP Esteemed Contributor

The script generates this filename here.

filenum = "ATT" + str(item[2]) + "_"
filename = filenum + str(item[1])‍‍‍‍

This is how I'd do it (equivalent to the above). 0 and 1 format indexes are used to flip the order (put the first argument second).

filename = "ATT{1}_{0}".format(item[1], item[2])‍‍‍

You could modify your script tool to set up a filename just how you want it.

Hope this helps!

TimHayes1
Occasional Contributor III

I want to remove the "ATT_1" etc... all together. Do not want to have any filename added, just want to use the original file names with nothing added a prefix or suffix via the script tool. How can this be done?

0 Kudos