Skip to content

Latest commit

 

History

History
115 lines (77 loc) · 6.87 KB

README.md

File metadata and controls

115 lines (77 loc) · 6.87 KB

snippetsLibrary

Blender addon - personnal snippets library in text editor

Download latest

Looking for the blender 2.7 version ? go to this repo

Want to support me? Get something from my gumroad, blender market, or see other means


Description

Allow you use and manage a library of your own code snippets.
Works well in combination with devTools to make your scripting life easier.

A new Snippets tab will be in the text editor's toolbar (accessible with ctrl + T).
Snippets will be saved and stored as invidual plain text files in a folder named 'snippets'.
This folder is located by default alongside the addon files (unless you enter a custom path in addon preferences).
Blender build-in snippets are also scanned (you can disable it in addon pref).
The addon is shipped with my personal pack of usefull code snippets (all free to use)
once installed just click the reload button in the addon UI to diplay them)

Features

Here description of the button list in order they appear.

UI

Insert paste : Insert in current text at cursor location (do 'Insert new' if no active text)

Insert new : Place the snippet in a new text (named after the snippet)

Reload : Load/Reload the list of snippet's from library. It load only '.txt' or '.py' files
Shift + click on Reload clear the list off the blend file (save space when your done)

Arrows up/down : Just change current snippet.

Add : Create a new snippet in library from current text selection (pop up a windows).
Snippets are saved as standalone '.py' file in the library folder.
Once saved you can open the library (click the icon folder) and arrange your newly created snippets into a suiting category folder (creating folder and subfolder is OK).
Thus it's not necessary, the containing folder name will be important if you use the conversion feature (see below).

Delete : This will delete the selected snippet file (pop up a confirmation windows). This action is irreversible since the snippets text file is deleted from disk.

Open library folder : Open the library folder in your OS browser. shift+click on the button will open at current selected snippet folder.

Search field : options : search between content and title, substractive search, show prefix, reverse order filter by name is currently broken so the feature has been removed

Preview : If activated, a preview of the selected snippet will appear below. Also display a list of def and class. The number of line displayed can be changed in the addon preferences

addon pref UI

Use custom path : Change the source folder of the snippets library. For example, this prove's usefull when multiple user work on a same server to share the same library (if the addon is not already loaded from server).

Secondary path : Manage other folderpath to scan as part of the library. Also choose to add blender build-in snippets in the lib (Those are already accessible with template menu in text editor)

Max preview lines : Choose max line number for preview (default 10)

text editor properties : Choose wich editor option to toggle on when a new textblock is automatically created

Conversion : Enjoy your blender made snippets in your favorite IDE ! This buttons allow you to convert all your library to the format of external editors Sublime text, VScode or atom. The trigger word to call it will be the name of the snippet's containing folder with an heading 's' added. (This is meant to avoid having triggers with standard words)
example: if the snippets was in the folder bpy, in sublime text you would start tapping sbpy to see suggestions of all related snippets. Note for Atom users: Since multiple snippets can share the same prefix, the conversion use this hack to make it work.

Note : You can enter tabstop syntax in your snippets. This will not affect your use of it in blender.
It can be usefull after conversion on external editors (see Conversion above) tabstop

Thanks to tin2tin for the feedbacks