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

On 12 July 2016 at 07:11, Geordie Martinez <[email protected]>
wrote:

> 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")
>
> ​
>
> On Mon, Jul 11, 2016 at 2:43 PM, likage <[email protected]> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/7c3cafbc-6b19-47b0-b864-9d541bc3e7c6%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/7c3cafbc-6b19-47b0-b864-9d541bc3e7c6%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CABPXW4gS5yP4OzZp%3D8EW5zdqLTg5ZX44%3D9gHw3_j%3DMgVM-tpvQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CABPXW4gS5yP4OzZp%3D8EW5zdqLTg5ZX44%3D9gHw3_j%3DMgVM-tpvQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



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

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FHkQawfFtV0ER4AqgUBcRGcAQq1MDCTzAKnFi%3DEEuFu4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to