Difference between revisions of "User:Ivo.grigull"

From The Foundry MODO SDK wiki
Jump to: navigation, search
(Locations to remember)
(Locations to remember)
Line 68: Line 68:
 
==== Locations to remember ====
 
==== Locations to remember ====
 
* VectorImportSVGCommand
 
* VectorImportSVGCommand
* ComponentPlacer::swapComponent
+
* ComponentPlacer::swapComponent, ComponentPlacer::replace2D, place2D
 +
* ComponentPlacer::importSVGComponent
 +
* CurveConstraint.cpp ModifierElement::Eval draws the components in 2d (and 3d of course)
 +
* VectorImportSVGCommand::cmd_Execute
 +
* Core\VectorTools\include\VectorTools\UI\SceneController.h

Revision as of 10:51, 5 July 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


Rebuilding the python plugin

build clean: force: proj:extra\python
build init && build proj:extra\python
cd apps\modo && qmake repack


Finding the scene's workspace

assemblies = [asm for asm in modo.Scene().groups if asm.type=='assembly']
workspaces = [w for w in assemblies if ('SGID', 'workspace') in w.getTags().items()]

Joota

Get components

import Layers
l = Layers.GLOABL_LAYER_OBJECT
layer = l.getSelectedLayers()[0]
layer.getLayerType()
layer.getLayerKey()
#vl = layer.getVectorLayer()
feature = layer.getFeature()
print [modo.Item(i).channel('elid').get() for i in feature.getComponents()]

Locations to remember

  • VectorImportSVGCommand
  • ComponentPlacer::swapComponent, ComponentPlacer::replace2D, place2D
  • ComponentPlacer::importSVGComponent
  • CurveConstraint.cpp ModifierElement::Eval draws the components in 2d (and 3d of course)
  • VectorImportSVGCommand::cmd_Execute
  • Core\VectorTools\include\VectorTools\UI\SceneController.h