For setting the specific optionVar value you could skip MEL and use this
Python command instead:
# Enable the "renderViewRenderSelectedObj" optionVar using Python
import maya.cmds as cmds
cmds.optionVar(intValue=('renderViewRenderSelectedObj', 1))
Regards,
Andrew Hazelden
On Wednesday, 7 September 2016 19:04:14 UTC-3, I73 wrote:
>
> Well I have a few 'hacks' for rendering the selected object, I would love
> to not use mel.
>
> *mel.eval('optionVar -intValue renderViewRenderSelectedObj 1;')*
> *mel.eval('renderWindowRender redoPreviousRender renderView;')*
> *mel.eval('prepareRender -invokePreRenderFrame;')*
> *mel.eval('prepareRender -invokePostRenderFrame;')*
> *mel.eval('updateEditorFeedbackRenderLayer RenderLayerTab
> defaultRenderLayer;')*
>
> If there is a better way, please feel free to tell me :)
>
> On Wed, Sep 7, 2016 at 2:36 PM, Wesley Keeling <[email protected]
> <javascript:>> wrote:
>
>> It works when I call the eval, but it only works when I first manually
>> render the scene after executing:
>> *import maya.mel as mel*
>> *mel.eval('int $var = 0; if( `optionVar -exists
>> renderViewRenderSelectedObj` ) { $var = (! `optionVar -q
>> renderViewRenderSelectedObj`); } optionVar -intValue
>> renderViewRenderSelectedObj $var;')*
>>
>> It seems to not want to refresh the renderer settings till I manually
>> render.
>>
>> On Wed, Sep 7, 2016 at 2:23 PM, I73 <[email protected] <javascript:>>
>> wrote:
>>
>> Hey Andrew, thanks for the reply, and sorry for the late reply.
>>> So I am still not fully understanding what the render view is doing. Am
>>> I going to have to use mel.eval to call renderViewRenderSelectedObj? Or can
>>> I preform this in python?
>>> Or is there a better way to render out the selected objet only by the
>>> cmds.render('persp', x=300, y=300, abortMissingTexture=True)
>>> Thanks!
>>>
>>> On Friday, August 12, 2016 at 2:28:21 PM UTC-7, Andrew Hazelden wrote:
>>>>
>>>> The Maya Render View's "Render Selected Objects Only" menu item is
>>>> defined and controlled in the following MEL file:
>>>>
>>>> /Applications/Autodesk/maya2017/Maya.app/Contents/scripts/others/renderWindowPanel.mel
>>>>
>>>> Besides the menuItem entry, there are two MEL other functions in this
>>>> script that refer to this specific rendering feature which are "
>>>> *switchSelectObj()*" and "*refreshRenderMenu()*".
>>>>
>>>> Both functions use MEL with an int based optionVar named
>>>> "renderViewRenderSelectedObj" to turn this rendering mode on and off:
>>>> *optionVar -intValue renderViewRenderSelectedObj $var;*
>>>>
>>>> Regards,
>>>> Andrew Hazelden
>>>>
>>>> On Friday, 12 August 2016 17:25:35 UTC-3, I73 wrote:
>>>>>
>>>>> I am trying to render the selected object in the scene, unfortunately
>>>>> the 'Render-> 'Render selected objects only' doesn't output to the script
>>>>> editor so I can't follow the MEL example.
>>>>> Is there anyone that has a working example or command I can use to get
>>>>> a render by selected object?
>>>>>
>>>>> render = cmds.render('persp', x=300, y=300, abortMissingTexture=True)
>>>>>
>>>>>
--
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/bc40467a-619e-469e-8cfb-10d47305c736%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.