
Search is based on keyword.
Ex: "Procedures"
Do not search with natural language
Ex: "How do I write a new procedure?"
Automating Procedures
Once you know how to use the Python tab to type in a sequence of Python statements, you probably want to learn how to automate the procedure. All you need to do is save your statements, and when you want to use them again later, import them into the Python tab.
Importing and Executing a Python Script
To import and execute a Python script in the Python tab:
1. | On the top of the Python tab, click the Script > Source File menu option. |
The Run a Script dialog opens.
2. | Navigate to the Python module that contains the script you want to open, or type in the file path to the module, and click Open. |
OR
In the input pane, enter:
import module
Where module represents the name of your Python module without the file extension, for example:
import firstmodule
Katana imports the Python module and performs the procedure defined in the module.
Note: The statement does not appear in the input pane either before or after it's executed.
Note: Importing the module is done according to Python’s default rules. During the import, the module is searched in the following locations and order:
1. In the current directory.
2. In the directories contained in the PYTHONPATH environment variable, if this has been defined. To view these directories, enter echo $PYTHONPATH in a command shell.
3. In an installation-dependent default directory.
During the search, the variable sys.path is initialized from these directories. Modules are then searched in the directories listed by the sys.path variable. To see these directories, execute the statement print sys.path in the Python tab.
Sorry you didn't find this helpful
Why wasn't this helpful? (check all that apply)
Thanks for your feedback.
If you can't find what you're looking for or you have a workflow question, please try Foundry Support.
If you have any thoughts on how we can improve our learning content, please email the Documentation team using the button below.
Thanks for taking time to give us feedback.