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

    Unable to Set Priority Data for Skin Deformer

    Cinema 4D SDK
    r21 python
    3
    6
    688
    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.
    • B
      bentraje
      last edited by

      Hi,

      With the help of this page, I am able to set priority data on a TAG, but not on the SKIN DEFORMER.

      I get a NoneType error. Is there a separate code for setting priority data for the SKIN DEFORMER?

      Here is the code so far:

      import c4d
      
      def SetPriority(Mode, Value, obj):
      
          pd=obj[c4d.EXPRESSION_PRIORITY]
          print pd # I get a NONE object here for skin deformer
          pd.SetPriorityValue(c4d.PRIORITYVALUE_MODE, Mode)
          pd.SetPriorityValue(c4d.PRIORITYVALUE_PRIORITY, Value)
          obj[c4d.EXPRESSION_PRIORITY]=pd
          return
      
      def main():
          
          obj = doc.SearchObject("skin_deformer")
          SetPriority(4, 2, obj)
      
      # Execute main()
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        hi,

        remember the brackets [] return a copy of the BaseContainer.
        You are updating a copy of the data. Either you need to reinject those data to the object or you can use GetDataInstance to retrieve an instance of the BaseContainer.
        But you still need to reinject your data into this BaseContainer.

        import c4d
        
        def SetPriority(obj, mode, value):
            if obj is None:
                return False
            bc = obj.GetDataInstance()
            if bc is None:
                return False
            pd = bc.GetData(c4d.ID_CA_SKIN_OBJECT_PRIORITY)
            if pd is None:
                print (obj)
                raise ValueError ("can't retrieve expression priority")
            pd.SetPriorityValue( c4d.PRIORITYVALUE_MODE, mode)
            pd.SetPriorityValue( c4d.PRIORITYVALUE_PRIORITY, int(value))
            bc.SetData(c4d.ID_CA_SKIN_OBJECT_PRIORITY, pd)
        
            obj.Message(c4d.MSG_UPDATE)
            return
        
        
        def main():
        
            obj = doc.SearchObject("skin_deformer")
           
            if obj is None:
                raise ValueError("object not found")
            SetPriority(obj, c4d.CYCLE_DYNAMICS,3)
        
            c4d.EventAdd()
        
        # Execute main()
        if __name__=='__main__':
            main()
        
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • B
          bentraje
          last edited by bentraje

          @m_magalhaes
          Thanks for the clarification. The code works as expected.

          Although I find it weird since the code I posted above (from the Cineversity) works for tags despite using the brackets []

          1 Reply Last reply Reply Quote 0
          • B
            bentraje
            last edited by

            Not sure if this would make sense.
            I use the previous code with bracket and just changed obj[c4d.EXPRESSION_PRIORITY] to obj[c4d.ID_CA_SKIN_OBJECT_PRIORITY].

            And it now works as expected.

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by

              Hi,

              you initial code was correct, the only problem was that you used the wrong id. @m_magalhaes probably overlooked the fact that you did write the priority data back (obj[c4d.EXPRESSION_PRIORITY]=pd) and just went for the common mistake in such cases. His version with GetData and SetData is just a bit more verbose and doesn't leave you at the mercy of __getitem__ and __setitem__, i.e. the bracket syntax and also uses the correct id, which "makes it work".

              Cheers,
              zipit

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 1
              • ManuelM
                Manuel
                last edited by

                @zipit said in Unable to Set Priority Data for Skin Deformer:

                probably overlooked

                correct, friday evening

                MAXON SDK Specialist

                MAXON Registered Developer

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