embedding the ???code??? (*.py) with the ???script tool??? (*.tbx),

891
8
05-18-2013 12:26 PM
JamalNUMAN
Legendary Contributor
embedding the ???code??? (*.py) with the ???script tool??? (*.tbx),

I???m wondering if there is a way to keep the ???code??? (*.py) with the ???script tool??? ??? (*.tbx).

It happens very often that the script tool is copied without its code.

[ATTACH=CONFIG]24460[/ATTACH]


Then how this code can be permanently embedded in the script tool?


Thank you

Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
Tags (2)
0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus
check out Python toolboxes ( *.pyt )
http://resources.arcgis.com/en/help/main/10.1/index.html#//001500000022000000
read carefully
0 Kudos
Luke_Pinner
MVP Regular Contributor
See embedding scripts in the help.
0 Kudos
ChrisSnyder
Regular Contributor III
Note that you can only do this in v10.1. The embedding of the .py code into a .tbx is pretty nice as it obfuscates the code as well, rendering it unreadable to general end users.
0 Kudos
JamalNUMAN
Legendary Contributor
See embedding scripts in the help.


Many thanks Dan, Luke and Chris for help,

Then all what I need is just to import the code. in this case, do we still need to go for the *.pyt option?

[ATTACH=CONFIG]24641[/ATTACH], [ATTACH=CONFIG]24643[/ATTACH]


Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
T__WayneWhitley
Frequent Contributor
No, I think you're confusing Python toolboxes and 'regular' system toolboxes... looks like you're going for the 'embed' option, if you right-click the script tool (not the py source file), then you can 'import script', the option only available beginning at 10.1 (as I learned from Caleb today, so thanks to him).

I don't have 10.1, but you say you do....and according to the documentation it's a 2 step process!  (the 2nd step is clicking 'OK' from the dialog box that opens ??)  Afterwards, it's another 2 step process to set a password, so I understand.  I think the checkmark goes to Luke on this one.

Enjoy,
Wayne

EDIT:  ...so it looks to me from your attached pics that you've already done the import?
0 Kudos
JamalNUMAN
Legendary Contributor
No, I think you're confusing Python toolboxes and 'regular' system toolboxes... looks like you're going for the 'embed' option, if you right-click the script tool (not the py source file), then you can 'import script', the option only available beginning at 10.1 (as I learned from Caleb today, so thanks to him).

I don't have 10.1, but you say you do....and according to the documentation it's a 2 step process!  (the 2nd step is clicking 'OK' from the dialog box that opens ??)  Afterwards, it's another 2 step process to set a password, so I understand.  I think the checkmark goes to Luke on this one.

Enjoy,
Wayne

EDIT:  ...so it looks to me from your attached pics that you've already done the import?


Many thanks Wayne,

This is why I wanted to know about these two options that allow keeping the script with the tool

*.pyt option

Import option

Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
T__WayneWhitley
Frequent Contributor
To be clear:
The Python toolbox (pyt) is a whole 'new animal', the entire toolbox is written in Python, even has a different icon in ArcToolbox.

I haven't tried it out yet, I admit, but the webhelp link below is very interesting - a comparison between the 2.  The way I think of it is it depends on where the customizations you made are 'hitched' to the core system software ESRI made -- so apparently the arcpy development framework has been extended to 'take over' where the system was previously hitched....and apparently with new capabilities as well (see the link).  More compelling reasons for me to get on with my next upgrade, in my production mode I'll probably skip to 10.2 -- ah, but that's another story.

Comparing custom and Python toolboxes
Desktop » Geoprocessing » Creating tools
http://resources.arcgis.com/en/help/main/10.1/index.html#//00150000002r000000


Enjoy,
Wayne
0 Kudos
JamalNUMAN
Legendary Contributor
To be clear:
The Python toolbox (pyt) is a whole 'new animal', the entire toolbox is written in Python, even has a different icon in ArcToolbox.

I haven't tried it out yet, I admit, but the webhelp link below is very interesting - a comparison between the 2.  The way I think of it is it depends on where the customizations you made are 'hitched' to the core system software ESRI made -- so apparently the arcpy development framework has been extended to 'take over' where the system was previously hitched....and apparently with new capabilities as well (see the link).  More compelling reasons for me to get on with my next upgrade, in my production mode I'll probably skip to 10.2 -- ah, but that's another story.

Comparing custom and Python toolboxes
Desktop » Geoprocessing » Creating tools
http://resources.arcgis.com/en/help/main/10.1/index.html#//00150000002r000000


Enjoy,
Wayne


Thank you very much Whitley for the elaboration.

I think we will be all switching to *.pyt due to the new capabilities included.

Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos