Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Redshift deleting using old information

    Cinema 4D SDK
    4
    17
    2.3k
    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.
    • ferdinandF
      ferdinand
      last edited by ferdinand

      Hi,

      I did not really test the user data stuff, I just included it, since I knew you are going to need it. But looking at my code now, the user data stuff does not make much sense. It should probably be node[(m, u)] or node[(s, u)]to test for user data ids (probably the first one). User data DescIDs follow the form ID_USERDATA, x, so for example 700, 1 for the first element. You have to poke around a little bit to find out what is what, but my guess would be node[(m, u)].

      If you keep running into errors, you should try the description stuff I mentioned in the function docstring instead. The approach of the function is not the safest 😉

      PS: You also do not need the line in_did = (in_port.GetMainID(), in_port.GetSubID()), this is just some garbage I forgot to delete before I realised that I was going to need a dedicated function for this 😉

      Cheers,
      zipit

      MAXON SDK Specialist
      developers.maxon.net

      1 Reply Last reply Reply Quote 0
      • SwinnS
        Swinn
        last edited by

        The original code yields image 1:
        Screen Shot 2020-05-31 at 5.13.22 AM.png
        m, u yields image 2:
        Screen Shot 2020-05-31 at 5.14.23 AM.png
        s, u yields image 3:
        Screen Shot 2020-05-31 at 5.15.05 AM.png
        It doesn't look like any of the actual User Data Values (3 of which are colour) are coming through. Here are images of the node and the UD:
        Screen Shot 2020-05-31 at 5.18.21 AM.png
        Screen Shot 2020-05-31 at 5.18.46 AM.png
        Neither m,u or s,u causes the actual User Data to transfer to the nodes before the User Data node gets deleted. Is there something I am missing?

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

          Hi,

          I actually meant doing that inside the get_port_descid function. However, I just did it for you and found out that for user data DescID elements the port returns some gibberish for m, s, u like for example 20000000 1000 -1 for a port for the first user data element for a null (we would at least expect 700 and 1 to pop up in there).

          The problem is that ports for user data elements and the DescID they are being build for always have been a bit weird (see GvNode.AddPort). To build a port for the first user data element of a node, we would initialise it with the DescID (700, 5, 1) (the weird part being the 5, which is the integer for the symbol DTYPE_SUBCONTAINER). The other problem is that ports do not really expose the element they point at to the outside world.

          I am afraid that you will have to wait for MAXON to shed some light on the topic, but I would not hold my breath for them coming up with a solution. It might very well be the case that you cannot infer the DescID for ports pointing at user data elements.

          Cheers,
          zipit

          MAXON SDK Specialist
          developers.maxon.net

          1 Reply Last reply Reply Quote 0
          • SwinnS
            Swinn
            last edited by

            Cool. I will try a different approach. Thanks for all your help on this, zipit. 🙂

            1 Reply Last reply Reply Quote 0
            • SwinnS
              Swinn
              last edited by Swinn

              I tried inputting the User Data directly into a RS port using Python and this code:

              import c4d
              
              def main():
              
                  obj = op.GetObject()
                  neon_col_INPUT = obj[c4d.ID_USERDATA,834]
              
                  # List: Spline, Colour, Power, Gas, Blend.
                  spline_UD = {1: 618}
              
                  for item in spline_UD:
                      rs_mat = doc.SearchObject ("S" + str (item) + " Gas")
                      rs_tag = rs_mat.GetTag(c4d.Ttexture)
                      rs_mat = rs_tag.GetMaterial()
                      outputNode = rs_mat[c4d.REDSHIFT_GRAPH_NODES]
                      gvMaster = outputNode.GetNodeMaster()
                      gvRoot = gvMaster.GetRoot()
              
                      colour = obj[c4d.ID_USERDATA,spline_UD[item]]
                      print colour
              
                      power = obj[c4d.ID_USERDATA,619]
                      gas = obj[c4d.ID_USERDATA,65]
                      blend = obj[c4d.ID_USERDATA,66]
              
                      currentNode = gvRoot.GetDown()
                      while currentNode is not None:
                          if currentNode.GetName() == "RS Material":
                              RSMaterial[c4d.REDSHIFT_SHADER_MATERIAL_EMISSION_COLOR] = colour
                              break
              

              Now my code causes C4D to hang. Can you help?

              1 Reply Last reply Reply Quote 0
              • SwinnS
                Swinn
                last edited by

                I figured out a way to get this to work. They key is separating the User Data out of the RS XPresso node but still maintaining a connection to this node through a regular XPresso node. Cinema won't let me drag Redshift nodes from the RS XPresso window to the C4D XPresso window. Nor can I drag them from the AM.

                The solution is to delete the User Data from the RS XPresso window, paste it into a new C4D Xpresso window, then use Set Driven (Absolute) on the RS nodes I need what is essentially double access to. Cinema then automatically creates a new XPresso node, which I then cut the contents from and paste them into my UD Xpresso node.

                My only question is what is the difference between Set Driven (Absolute) and Set Driven (Relative)? Does it make a difference? Thanks.

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

                  Hi,

                  sorry, I did not see your replies. But I cannot help you as I do neither have access to Redshift nor am very fluent when it comes to Cinemas features.

                  Cheers,
                  zipit

                  MAXON SDK Specialist
                  developers.maxon.net

                  1 Reply Last reply Reply Quote 0
                  • P
                    PluginStudent @Swinn
                    last edited by

                    @Swinn said in Redshift deleting using old information:

                    My only question is what is the difference between Set Driven (Absolute) and Set Driven (Relative)? Does it make a difference?

                    Both setups add a Range Mapper node. In case of 'Relative', this range mapper creates an offset. See the online help.

                    1 Reply Last reply Reply Quote 0
                    • SwinnS
                      Swinn
                      last edited by

                      Thanks, PluginStudent! 🙂

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

                        hi,

                        your question is sometimes not obvious 😄
                        Even with the scene it's a bit compicated.

                        What i can say about your code is that you should be more defensive in your code. Always check the value before continue.

                        For example what if the object is not found ? You should continue to the next item or stop ?

                        for item in spline_UD:
                                rs_mat = doc.SearchObject ("S" + str (item) + " Gas")
                                if rs_mat is None:
                                    # Because we don't have object to continue, we iterate to the next item.
                                    continue
                                ...
                        

                        Cheers,
                        Manuel

                        MAXON SDK Specialist

                        MAXON Registered Developer

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