Skriptovanie a ochrana¶
The ability to include Python scripts within blend-files is valuable for advanced tasks such as rigging and automation. However, it poses a security risk since Python does not restrict what a script can do. Therefore, you should only run scripts from sources you know and trust. Automatic execution is disabled by default, however, some blend-files need this to function properly.
Keď sa blend súbor pokúsi vykonať skript a nie je povolený, zobrazí sa dialógové okno. V ňom si môžete vybrať povoliť vykonávanie alebo ignorovať skripty.
Upozornenie na automatické spustenie v záhlaví editora informácií.¶
Skripty v blend súboroch¶
Automatické vykonávanie¶
Tu sú uvedené rôzne spôsoby, ako môžu blend súbory spúšťať skripty automaticky.
- Registrované textové bloky
Textový blok údajov môže mať povolenú možnosť Zaregistrovať, čo znamená, že sa načíta pri spustení.
- Ovládače animácie
Výrazy jazyka Python možno použiť na hodnoty ovládača a často sa používajú v pokročilejších platformách a animáciách.
Manuálne vykonávanie¶
Existujú aj iné spôsoby, ako sa môžu skripty v blend súbore spustiť, ktoré vyžadujú interakciu užívateľa (preto sa spustia, aj keď je automatické spúšťanie vypnuté), ale mali by ste si byť vedomí, že je to tak, pretože to nemusí byť zrejmé.
Spustenie skriptu v textovom editore.
Prekresľovanie Voľným štýlom, pretože Voľný štýl používa skripty na ovládanie štýlov čiar.
Kontrola vykonávania skriptov¶
Blender poskytuje niekoľko spôsobov, ako kontrolovať, či sa skripty z blend súboru môžu automaticky spúšťať.
First of all, the File Browser has the option Trusted Source which you can use on a case-by-case basis to control auto execution. However, you may forget to set this, or open a file without going through the File Browser – so you can change the default (described next).
Nastavenie predvolieb¶
In the Preferences, there is the toggle to Auto Run Python Scripts. This means the Trusted Source option in the File Browser will be enabled by default, and scripts can run when blend-files are loaded without using the File Browser. Once enabled you have the option to exclude certain directories, a typical configuration would be to trust all paths except for the download directory.
Zaškrtávacie políčko Automatické spúšťanie Python skriptov.¶
Príkazový riadok¶
You may want to perform batch rendering or some other task from the command line – running Blender without an interface. In this case, the Preferences are still used but you may want to override them:
Povolenie pomocou
-yalebo--enable-autoexecZakázať pomocou
-Yalebo--disable-autoexec
Napríklad¶
Rendering an animation in background mode, allowing drivers and other scripts to run:
blender --background --enable-autoexec my_movie.blend --render-anim
Poznámka
Tieto argumenty príkazového riadka sa môžu použiť na spustenie bežnej inštancie Blenderu a stále budú mať prednosť pred nastaveniami.