Repository navigation
Expand file tree
/
Copy pathriglab_plugin.py
More file actions
118 lines (92 loc) · 3.59 KB
/
Copy pathriglab_plugin.py
File metadata and controls
118 lines (92 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# This file is part of riglab.
# Copyright (C) 2014 Cesar Saez
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation version 3.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from wishlib.qt import QtGui
from wishlib.si import si, sisel, log, C, show_qt
def XSILoadPlugin(in_reg):
in_reg.Name = "RigLab Plugin"
in_reg.Author = "csaez"
in_reg.Major = 1.0
in_reg.Minor = 0.0
in_reg.UserData = ""
in_reg.RegisterCommand("QuickLab", "quicklab")
in_reg.RegisterCommand("RigLab Editor", "riglab")
in_reg.RegisterCommand("Create Pose Reader", "reader")
in_reg.RegisterCommand("Curve To Nulls", "curve2null")
in_reg.RegisterCommand("Nulls To Curve", "null2curve")
in_reg.RegisterCommand("Align Nulls To Curve", "align2curve")
in_reg.RegisterCommand("Orthogonalize Selection", "orthogonalize")
in_reg.RegisterCommand("Draw Linear Curve Into Mesh", "draw_linear_curve")
in_reg.RegisterEvent("CloseScene", C.siOnCloseScene)
return True
def XSIUnloadPlugin(in_reg):
log("{} has been unloaded".format(in_reg.Name), C.siVerbose)
return True
def QuickLab_Execute():
log("QuickLab_Execute called", C.siVerbose)
if sisel.Count != 1:
return False
from riglab.layout.quicklab import QuickLab
pos = QtGui.QCursor.pos()
show_qt(QuickLab, modal=True,
onshow_event=lambda x: x.move(pos.x(), pos.y()))
return True
def RigLabEditor_Execute():
log("RigLabEditor_Execute called", C.siVerbose)
from riglab.layout.editor import Editor
show_qt(Editor)
return True
def CreatePoseReader_Execute():
log("CreatePoseReader_Execute called", C.siVerbose)
from riglab.psd.reader import ConeReader
sel = list(sisel)
r = ConeReader.new()
if len(sel):
r.obj.Kinematics.Global.Transform = sel[0].Kinematics.Global.Transform
r.target = sel[0]
return True
def CurveToNulls_Execute():
log("CurvetoNulls_Execute called", C.siVerbose)
from riglab.utils import curve2null
si.SelectObj([n for c in list(sisel) for n in curve2null(c)])
return True
def NullsToCurve_Execute():
log("NullsToCurve_Execute called", C.siVerbose)
from riglab.utils import sel2curve
si.SelectObj(sel2curve(list(sisel)))
return True
def AlignNullsToCurve_Execute():
log("AlignNullsToCurve_Execute called", C.siVerbose)
from riglab.utils import align2curve
curve = si.PickObject()("PickedElement")
if curve:
align2curve(sisel, curve)
return True
def DrawLinearCurveIntoMesh_Execute():
log("DrawLinearCurveIntoMesh_Execute called", C.siVerbose)
from riglab.utils import draw_linear_curve
draw_linear_curve(sisel)
return True
def OrthogonalizeSelection_Execute():
log("OrthogonalizeSelection_Execute called", C.siVerbose)
from riglab.utils import orthogonalize, deep
for obj in sorted(list(sisel), key=deep):
orthogonalize(obj)
return True
def CloseScene_OnEvent(in_ctxt):
log("CloseScene_OnEvent called", C.siVerbose)
import sys
module = "riglab"
if len(module):
for k in sys.modules.keys():
if k.startswith(module):
del sys.modules[k]
return True