Difference between revisions of "User:Ivo.grigull"

From The Foundry MODO SDK wiki
Jump to: navigation, search
Line 19: Line 19:
 
     return imp.load_module(name, file, filename, data)
 
     return imp.load_module(name, file, filename, data)
 
  jedi = import_(r'C:\Python27\Lib\site-packages\jedi')
 
  jedi = import_(r'C:\Python27\Lib\site-packages\jedi')
 +
 +
 +
=== Jedi completion ===
 +
<syntaxhighlight lang="python">
 +
# Jedi completion example
 +
 +
import imp, os, os.path
 +
 +
def import_(filename):
 +
    (path, name) = os.path.split(filename)
 +
    (name, ext) = os.path.splitext(name)
 +
    (file, filename, data) = imp.find_module(name, [path])
 +
    return imp.load_module(name, file, filename, data)
 +
 +
jedi = import_(r'C:\Python27\Lib\site-packages\jedi')
 +
 +
s = '''import imp, os, os.path
 +
os.p'''
 +
 +
script = jedi.Script (s, 2, 4, '')
 +
c = script.completions()
 +
c[8].complete
 +
</syntaxhighlight>

Revision as of 12:26, 13 May 2016

Schematic connection

SDK Interfaces

SDK Objects

Creating an undo context in a fire and forget script

http://pastebin.com/AWNV6vGd

Your scripts can simply do
lx.eval('undo.init')
and it'll create an undo context for you.

Python

Using imp

import imp, os, os.path
def import_(filename):
    (path, name) = os.path.split(filename)
    (name, ext) = os.path.splitext(name)
    (file, filename, data) = imp.find_module(name, [path])
    return imp.load_module(name, file, filename, data)
jedi = import_(r'C:\Python27\Lib\site-packages\jedi')


Jedi completion

# Jedi completion example
 
import imp, os, os.path
 
def import_(filename):
    (path, name) = os.path.split(filename)
    (name, ext) = os.path.splitext(name)
    (file, filename, data) = imp.find_module(name, [path])
    return imp.load_module(name, file, filename, data)
 
jedi = import_(r'C:\Python27\Lib\site-packages\jedi')
 
s = '''import imp, os, os.path
os.p'''
 
script = jedi.Script (s, 2, 4, '')
c = script.completions()
c[8].complete