Value based on Rendering State



  • On 19/12/2017 at 18:25, xxxxxxxx wrote:

    Hello, Plugincafe :)   
    I want to make dependency between values of my object plugin and rendering state.
    This test plugin simply extrudes all polygons, but I want to extrude it by 100 units in render and 0 in viewport. it's working when I'm rendering in picture viewer with this code:  CHECKISRUNNING_EXTERNALRENDERING
    but If I attempt to apply the same technique for in the viewport render(CHECKISRUNNING_EDITORRENDERING) I'm not getting any results. value still remains 0.

    This is full a code that works in the picture viewer:

      1.     def GetVirtualObjects(self, op, hh) :
      2.     
      3.     #Check child Object
      4.         child = op.GetDown()
      5.         if not child: return None
      6.   
      7.     #Create clone
      8.         cloneGenerator = op.GetAndCheckHierarchyClone(hh, child, c4d.HIERARCHYCLONEFLAGS_ASPOLY, False)
      9.         dirty = cloneGenerator["dirty"]
      10.         clone = cloneGenerator["clone"]
      11.         children = clone.GetChildren()
      12.   
      13.         if not dirty: return clone
      14.   
      15.  **    #Rendering State**
      16.  **    	rendering = c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)**
      17.  **    	if rendering is 1: value = 100**
      18.  **    	else: value = 0**
      19.   
      20.     #Extrude all polygons
      21.         settings = c4d.BaseContainer()
      22.         settings[c4d.MDATA_EXTRUDE_OFFSET] = **value**
      23.         res = c4d.utils.SendModelingCommand (command = c4d.ID_MODELING_EXTRUDE_TOOL,
      24.                                              list    = [clone],
      25.                                              mode    = c4d.MODELINGCOMMANDMODE_POLYGONSELECTION,
      26.                                              bc      = settings,
      27.                                              doc     = child.GetDocument())
      28.   
      29.     #Return Result
      30.         return clone
    
    

    I guess this is something related to caching.
    Is it possible to apply the same technique to the viewport render?



  • On 20/12/2017 at 08:31, xxxxxxxx wrote:

    Hi merkvilson, thanks for writing us.

    Checking the rendering status should be done at the beginning of the function rather than after checking the object and child dirtyness. A potential change in the rendering status should also impact the dirty check of your object otherwise you won't be able to perform any action on your model during Viewport rendering.

    Best, Riccardo



  • On 21/12/2017 at 18:55, xxxxxxxx wrote:

    Thanks! :)


Log in to reply