Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a8724da

Browse files
committedNov 17, 2022
Add the menu on plugin load. Initialize optionVars on first run
1 parent 734f847 commit a8724da

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
 

‎scripts/BlurRelax/menu.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def get_create_command_kwargs():
162162
return kwargs
163163

164164

165+
165166
def display_blur_relax_options(*args, **kwargs):
166167
cmds.loadPlugin('BlurRelax', qt=True)
167168
layout = mel.eval('getOptionBox')
@@ -175,6 +176,9 @@ def display_blur_relax_options(*args, **kwargs):
175176
except RuntimeError:
176177
pass
177178

179+
if not cmds.optionVar(exists=BORDER_DDL):
180+
init_option_vars()
181+
178182
pinBehaviors = ["None", "Pin", "Slide"]
179183

180184
cmds.optionMenu(BORDER_DDL, label="Border Behavior")
@@ -311,6 +315,19 @@ def reset_to_defaults(*args, **kwargs):
311315
cmds.floatSliderGrp(DELTA_SLD, edit=True, value=1.0)
312316

313317

318+
def init_option_vars():
319+
"""Initialize the option vars the first time the ui is run"""
320+
cmds.optionVar(intValue=(BORDER_DDL, 1))
321+
cmds.optionVar(intValue=(HARD_DDL, 0))
322+
cmds.optionVar(intValue=(GROUP_DDL, 0))
323+
cmds.optionVar(intValue=(REPROJ_CHK, 0))
324+
cmds.optionVar(intValue=(DELTA_CHK, 0))
325+
cmds.optionVar(floatValue=(REPROJ_SLD, 1.0))
326+
cmds.optionVar(floatValue=(PRESERVE_VOL_SLD, 0.0))
327+
cmds.optionVar(floatValue=(ITERATIONS_SLD, 10.0))
328+
cmds.optionVar(floatValue=(DELTA_SLD, 1.0))
329+
330+
314331
def get_wrap_node_from_object(obj):
315332
"""Get a wrap node from the selected geometry."""
316333
if cmds.nodeType(obj) == 'BlurRelax':

‎src/pluginRegister.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ MStatus initializePlugin(MObject obj) {
3030
MStatus result;
3131
MFnPlugin plugin(obj, "Blur Studio", "1.0", "Any");
3232
result = plugin.registerNode(DEFORMER_NAME, BlurRelax::id, BlurRelax::creator, BlurRelax::initialize, MPxNode::kDeformerNode);
33-
MGlobal::executeCommand("makePaintable -attrType \"multiFloat\" -sm \"deformer\" \"" DEFORMER_NAME "\" \"weights\";");
34-
33+
if (MGlobal::mayaState() == MGlobal::kInteractive) {
34+
MGlobal::executeCommand("makePaintable -attrType \"multiFloat\" -sm \"deformer\" \"" DEFORMER_NAME "\" \"weights\";");
35+
MGlobal::executePythonCommandOnIdle("import BlurRelax.menu");
36+
MGlobal::executePythonCommandOnIdle("BlurRelax.menu.create_menuitems()");
37+
}
3538
return result;
3639
}
3740

@@ -41,4 +44,3 @@ MStatus uninitializePlugin(MObject obj) {
4144
result = plugin.deregisterNode(BlurRelax::id);
4245
return result;
4346
}
44-

0 commit comments

Comments
 (0)
Please sign in to comment.