Maya 2018 doesn't initialize option variables until the settings panel is opened

Maya 2018 doesn't initialize option variables until the settings panel is opened

Anonymous
Not applicable
697 Views
2 Replies
Message 1 of 3

Maya 2018 doesn't initialize option variables until the settings panel is opened

Anonymous
Not applicable

I have made a scene set with Maya's time unit configured to 60 FPS. 

 

I also have a simple plugin, with these two statements in the `initializePlugin` function:

 

```

MGlobal::displayInfo(MGlobal::optionVarStringValue(MString("workingUnitTime")));

MGlobal::displayInfo(MGlobal::optionVarStringValue(MString("workingUnitAngular")));

```

 

I start Maya and open the scene (as describe above, it has the time unit set to 60FPS), and I see the following output in the script editor:

 

```

// film //
// deg //

```

 

So, the Maya API incorrectly reports `film` for the time unit (which is 24FPS). 

 

If I then open the settings panel, press save, and then reload the plugin via the plugin manager, I see the following output:

 

```

// Result: 1 //
// Saving preferences to : /Users/richard-roberts/Library/Preferences/Autodesk/maya/2018/prefs/userPrefs.mel //
// Saving window positions to : /Users/richard roberts/Library/Preferences/Autodesk/maya/2018/prefs/windowPrefs.mel //
// Saving runtime commands to : /Users/richard-roberts/Library/Preferences/Autodesk/maya/2018/prefs/userRunTimeCommands.mel //
// Saving hotkeys to : /Users/richard-roberts/Library/Preferences/Autodesk/maya/2018/prefs/hotkeys/userHotkeys_Maya_Default_Duplicate.mel //
// Saving named commands to : /Users/richard-roberts/Library/Preferences/Autodesk/maya/2018/prefs/userNamedCommands.mel //
// Saving plug-in preferences to: /Users/richard-roberts/Library/Preferences/Autodesk/maya/2018/prefs/pluginPrefs.mel //
// Preferences saved. See Script Editor for details. //

//
// ntscf //
// deg //

```

 

And now, after opening and saving the preferences (in which I made no changes), Maya correctly reports `ntscf` for the time unit (which is 60FPS).

 

What does this happen? Is there an initialization step for Maya's API that I have missed?

0 Likes
Accepted solutions (1)
698 Views
2 Replies
Replies (2)
Message 2 of 3

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

It feels like optionVars not being initialized properly when opening a scene. I'll log it in our system.

 

Meanwhile, you could use *::uiUnit to get correct value,e.g:

 

	MGlobal::displayInfo(MString("") + (int)MTime::uiUnit());
	MGlobal::displayInfo(MString("") + (int)MAngle::uiUnit());
	MGlobal::displayInfo(MString("") + (int)MDistance::uiUnit());

Yours,

Li

Message 3 of 3

Anonymous
Not applicable

Hi Li, 

 

I can confirm querying the working units via the static `uiUnit` methods provides the correct information. Thanks for the quick response! This resolves my implementation issue.


Let me know if you need any further information to reproduce the issue with the query via MGlobal (I've tested this with the latest version of Maya 2018 on both OSX and Windows).

 

Thanks again!

0 Likes