-
Notifications
You must be signed in to change notification settings - Fork 37
Advanced Usage
There are a few advanced features of this module that provide more control over how things work.
Settings.py has been placed in the root of the module's directory. Modifications can be made to this file to change some aspects of the module's operation. A restart of FreeCAD, or leaving the module and then coming back is required after making changes to Settings.py.
-
execute_on_save - Automatically execute a script every time you save. The default is
False
. -
use_external_editor - Automatically reloads and executes the open script when an external change is made. This allows users to use their preferred code editor instead of the one included with this module. The default is
False
. -
max_line_length - The number of characters per line that is allowed before a line length warning is given. The default is
79
to help make scripts PEP8 compliant. - font_size - Sets the font size of the embedded Python editor (PyQode). Default is 10.
- execute_keybinding - Allows a user to set the key (or key combo) that will execute the currently active script. Defaults to 'F2' and follows the Qt shortcut key conventions.
-
report_execute_time - Controls whether or not to display the time it took to execute a script. The script being executed must be CQGI (CadQuery Gateway Interface) compliant, meaning that it uses the
show_object
function. Default is False.
Environment variables are set when a script executes to give you access to the path your script is running from. This is needed because of the way the module executes scripts from a temporary file, which may render things like settings files in the script's home directory unavailable. To access these environment variables, import os
and then use os.environ.get("VARIABLE_NAME")
.
- MYSCRIPT_FULL_PATH - Includes the full path and filename of the script being executed.
- MYSCRIPT_DIR - Full path excluding the filename, giving the directory the script resides in.
Here is an example of retrieving the value and using these environment variables:
import os
config = '{path:s}/config.yaml'.format(path=os.environ.get("MYSCRIPT_DIR"))
file = open(config, 'r')
print(file.read())