Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Value based on Rendering State

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 513 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          Thanks! 🙂

          1 Reply Last reply Reply Quote 0
          • First post
            Last post