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
    • Recent
    • Tags
    • Users
    • Login

    Setting Gradient Interpolation for Sketch and Toon

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 471 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 02/05/2014 at 22:35, xxxxxxxx wrote:

      I am building a plugin that renders using Sketch and Toon, I am writing a bit that checks is S&T is enabled, if not turns it on and sets the settings to what I need them to be.

      My problem is I want to set the Gradient Interpolation on the Shading tab to 'Smooth Knot'

      I have absolutely no idea how to get/set this value..

      I don't suppose anyone here knows do they?

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

        On 03/05/2014 at 01:24, xxxxxxxx wrote:

        Hi Anadin,

        it´s written in the SDK like:

        Gradient.SetData( id , data )
        Sets a data item from the gradient container.
        GRADIENT_INTERPOLATION_SMOOTHKNOT Smooth knot.
        To be more specific, with:

        gradient.GetData(c4d.GRADIENT_INTERPOLATION),"ID"
        You can get the interpolation id

        I´m not sure if this helps?

        martin

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

          On 04/05/2014 at 00:49, xxxxxxxx wrote:

          Ooh that looks interesting, didn't think to search for a generic gradient - I think you are on to something but I can't figure out how to use it..

          import c4d
          from c4d import gui
          #Welcome to the world of Python

          XRes = 1024
          YRes = 768
          OutputPath = '/Users/user/Desktop/test.png'

          def main() :    
              print "Setting RenderData"
              #Get the current documents render settings
              RenderData = doc.GetActiveRenderData()
              print "RenderData : " + str(RenderData)
              #Store a copy of those settings
              RenderDataBackup = RenderData.GetClone()
              #Access the basedraw of the render view (filters etc.)
              BaseDraw = doc.GetActiveBaseDraw()
              #Basic Settings
              RenderData[c4d.RDATA_AUTOLIGHT] = False
              RenderData[c4d.RDATA_SAVEIMAGE] = True
              RenderData[c4d.RDATA_ALPHACHANNEL] = True
              RenderData[c4d.RDATA_STRAIGHTALPHA] = True
              RenderData[c4d.RDATA_XRES] = float(XRes)
              RenderData[c4d.RDATA_YRES] = float(YRes)
              RenderData[c4d.RDATA_FORMAT] = 1023671
              RenderData[c4d.RDATA_MULTIPASS_SAVEIMAGE] = False
              
              #Actual Output
              RenderData[c4d.RDATA_PATH] = OutputPath

          #Add Sketch And Toon if it's not there and required and set up the defaults

          if c4d.modules.CheckSketch() : #if Sketch and Toon is installed && it is wanted. set it up and use it (Do the check)
                  rd = doc.GetActiveRenderData() # Get the current renderdata
                  vp = rd.GetFirstVideoPost() # Get the first Video Post in the Renderdata object
                  if vp == None:
                      SketchEffect = c4d.BaseList2D(1011015) # set a baseList2D with the ID of Sketch and Toon
                      rd.InsertVideoPost(SketchEffect) #insert the S&T video post
                      vp = rd.GetFirstVideoPost()

          BrowseRD(vp, True) #Run the Function

          if vp.GetName() == "Sketch and Toon": #if S&T was found, the rdata name var should be "Sketch and Toon"...
                      SketchEffect = vp #Set the "SketchEffect" variable to the current S&T

          else: #if not, set the "SketchEffect" to a NEW S&T videopost
                      SketchEffect = c4d.BaseList2D(1011015) # set a baseList2D with the ID of Sketch and Toon
                      rd.InsertVideoPost(SketchEffect) #insert the S&T video post

          SketchEffect[c4d.OUTLINEMAT_SHADING_BACK] = 0
                  SketchEffect[c4d.OUTLINEMAT_SHADING_OBJECT_MODEL] = 1
                  
          c4d.Gradient.SetData(c4d.GRADIENT_INTERPOLATION)

          #Remove Sketch Tags and Replace?
              #Make Sketch Mat?
              c4d.EventAdd()
              
          def BrowseRD(rd, children) : #function that scrolls through the video post effects to find S&T
              if not rd: return
              
              if rd.GetName() == "Sketch and Toon":
                  print("S&T Vido Post is Present...")
                  return
              
              BrowseRD(rd.GetNext(), children)
              if children:
                BrowseRD(rd.GetDown(), children)

          if __name__=='__main__':
              main()

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

            On 04/05/2014 at 08:45, xxxxxxxx wrote:

            get it,set it and write it back to your effect

              
            gradient=SketchEffect[c4d.OUTLINEMAT_SHADING_GRADQUANT]  
            print gradient.GetData(c4d.GRADIENT_INTERPOLATION),"ID"  
            gradient.SetData(c4d.GRADIENT_INTERPOLATION,2)  
            print gradient.GetData(c4d.GRADIENT_INTERPOLATION),"ID2"  
            SketchEffect[c4d.OUTLINEMAT_SHADING_GRADQUANT]=gradient  
              
            

            cheers martin

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

              On 08/05/2014 at 05:08, xxxxxxxx wrote:

              aha! thanks so much Martin

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