Re: [Maya-Python] Getting the year of the Maya version used

610 views
Skip to first unread message

Justin Israel

unread,
Jul 12, 2016, 1:41:17 AM7/12/16
to Python Programming for Autodesk Maya
Does the cutstring give you anything consistent? 

cmds.about(c=True)[:4]

On my machine, the year is the first 4 characters.



On Mon, Jul 11, 2016 at 3:43 PM likage <dissid...@gmail.com> wrote:
I was wondering what is the best way that I can grab the year of the Maya version and just the year that I am using - eg. 2012, 2014 etc?

I know that there is a command - cmds.about(v=True) which returns me 'Extension for Autodesk Maya 2014 Service Pack 2' but any ideas in which I can improve on it?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/7c3cafbc-6b19-47b0-b864-9d541bc3e7c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Geordie Martinez

unread,
Jul 12, 2016, 2:11:09 AM7/12/16
to python_inside_maya

Here is one way to use regex. it’s not super elegant, but it gets the job done.
hope this helps.

import re
# get combinations of 4 numbers in a row like 2014, 2015, 2016, etc.
pattern = re.compile(r'''.*(\d{4})''') 
res = pattern.search(mc.about(v=True))
if res.groups():
    print("version {0}".format(res.groups()[0]))

else:
    print("this doesn't give me a version")

Mark Jackson

unread,
Jul 12, 2016, 3:39:07 AM7/12/16
to python_inside_maya
the easiest way to get the version is to actually call the mel command that internally just does a regex to return you just the version

mel.eval('getApplicationVersionAsFloat')

been using that in all out codebase for as long as I can remember to by-pass having to worry about processing the return from the about command

cheers

Mark


For more options, visit https://groups.google.com/d/optout.



--
-------------------------------------
Mark Jackson
CEO / Technical Director
red9consultancy.com

CharlieWales

unread,
Jul 12, 2016, 3:58:02 AM7/12/16
to python_in...@googlegroups.com

Mel command:
getApplicationVersionAsFloat

Mahmoodreza Aarabi

unread,
Jul 20, 2016, 5:03:43 AM7/20/16
to Python Programming for Autodesk Maya

In maya 2016 it gives me this
# Result: u'2015' #

??

On Tuesday, July 12, 2016 at 10:11:17 AM UTC+4:30, Justin Israel wrote:

Does the cutstring give you anything consistent? 

cmds.about(c=True)[:4]

On my machine, the year is the first 4 characters.



On Mon, Jul 11, 2016 at 3:43 PM likage <dissid...@gmail.com> wrote:
I was wondering what is the best way that I can grab the year of the Maya version and just the year that I am using - eg. 2012, 2014 etc?

I know that there is a command - cmds.about(v=True) which returns me 'Extension for Autodesk Maya 2014 Service Pack 2' but any ideas in which I can improve on it?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Mahmoodreza Aarabi

unread,
Jul 20, 2016, 5:05:35 AM7/20/16
to Python Programming for Autodesk Maya

cmds.about(c=True) >> # Result: u'201502261600-953408' #

On Tuesday, July 12, 2016 at 10:11:17 AM UTC+4:30, Justin Israel wrote:

Does the cutstring give you anything consistent? 

cmds.about(c=True)[:4]

On my machine, the year is the first 4 characters.



On Mon, Jul 11, 2016 at 3:43 PM likage <dissid...@gmail.com> wrote:
I was wondering what is the best way that I can grab the year of the Maya version and just the year that I am using - eg. 2012, 2014 etc?

I know that there is a command - cmds.about(v=True) which returns me 'Extension for Autodesk Maya 2014 Service Pack 2' but any ideas in which I can improve on it?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages