Get the latest Blender, older versions, or experimental builds.
Stay up-to-date with the new features in the latest Blender releases.
Access production assets and knowledge from the open movies.
Documentation on the usage and features in Blender.
Latest development updates, by Blender developers.
Guidelines, release notes and development docs.
A platform to collect and share results of the Blender Benchmark.
The yearly event that brings the community together.
Support core development with a monthly contribution.
Perform a single donation with more payment options available.
#!BPY
"""
Name: 'Suggest All'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+Space'
Tooltip: 'Performs suggestions based on the context of the cursor'
# Only run if we have the required modules
try:
import bpy
from BPyTextPlugin import *
OK = True
except ImportError:
OK = False
def check_membersuggest(line, c):
pos = line.rfind('.', 0, c)
if pos == -1:
return False
for s in line[pos+1:c]:
if not s.isalnum() and not s == '_':
return True
def check_imports(line, c):
if c >= 7 and line.rfind('import ', 0, c) == c-7:
if c >= 5 and line.rfind('from ', 0, c) == c-5:
def main():
txt = bpy.data.texts.active
if not txt:
return
(line, c) = current_line(txt)
# Check we are in a normal context
if get_context(txt) != CTX_NORMAL:
# Check the character preceding the cursor and execute the corresponding script
if check_membersuggest(line, c):
import textplugin_membersuggest
textplugin_membersuggest.main()
elif check_imports(line, c):
import textplugin_imports
textplugin_imports.main()
# Otherwise we suggest globals, keywords, etc.
list = []
pre = get_targets(line, c)
for k in KEYWORDS:
list.append((k, 'k'))
for k, v in get_builtins().items():
list.append((k, type_char(v)))
for k, v in get_imports(txt).items():
for k, v in get_defs(txt).items():
list.append((k, 'f'))
for k in get_vars(txt):
list.append((k, 'v'))
list.sort(cmp = suggest_cmp)
txt.suggest(list, pre[-1])
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
main()