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
    • Register
    • Login
    1. Home
    2. DEDAAN
    D
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Best 0
    • Controversial 0
    • Groups 0

    DEDAAN

    @DEDAAN

    0
    Reputation
    1
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    DEDAAN Unfollow Follow

    Latest posts made by DEDAAN

    • RE: Change texture node colorspace

      Okay, I was able to get it to work, now I just need some kind of way to get the selected nodes, is there any way to do this?
      node.GetBit(c4d.BIT_ACTIVE) doesn't seem to work with the new nodes and I'm unable to find a solution so far.

      Cheers,
      Daan

      posted in Cinema 4D SDK
      D
      DEDAAN
    • RE: Change texture node colorspace

      Hey, thanks for the help!

      I've changed type hinting, just to make sure that was not the source of the problem.
      The weird thing is, this is the whole script, so I have no clue where the traceback error is coming from.
      InternedId is indeed not in my code.

      Even this script is giving that error now and that one was working just fine earlier today 🤔
      https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/master/scripts/05_modules/node/access_graph_entities_2024_2.py

      import c4d
      import maxon
      
      doc: c4d.documents.BaseDocument # The active document.
      
      def main():
          # For the selected mateiral in the currently active document ...
          for material in doc.GetActiveMaterials():
              # ... get its node material reference and step over all materials which do not have a
              # Redshift graph or where the graph is malformed.
              nodeMaterial: c4d.NodeMaterial = material.GetNodeMaterialReference()
              if not nodeMaterial.HasSpace("com.redshift3d.redshift4c4d.class.nodespace"):
                  continue
      
              graph: maxon.GraphModelRef = nodeMaterial.GetGraph(
                  "com.redshift3d.redshift4c4d.class.nodespace")
              if graph.IsNullValue():
                  raise RuntimeError("Found malformed empty graph associated with node space.")
      
              # Get the root of the graph, the node which contains all other nodes.
              root: maxon.GraphNode = graph.GetRoot()
      
              # Iterate over all nodes in the graph, i.e., unpack things like nodes nested in groups.
              # With the mask argument we could also include ports in this iteration.
              for node in root.GetInnerNodes(mask=maxon.NODE_KIND.NODE, includeThis=False):
      
                  # There is a difference between the asset ID of a node and its ID. The asset ID is
                  # the identifier of the node template asset from which a node has been instantiated.
                  # It is more or less the node type identifier. When we have three RS Texture nodes
                  # in a graph they will all have the same asset ID. But their node ID on the other hand
                  # will always be unique to a node.
                  assetId: maxon.Id = node.GetValue("net.maxon.node.attribute.assetid")[0]
                  nodeId: maxon.Id = node.GetId()
      
                  # Step over everything that is not a Texture node, we could also check here for a node
                  # id, in case we want to target a specific node instance.
                  if assetId != maxon.Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler") and node.GetBit(c4d.BIT_ACTIVE):
                      continue
      
                  print("texture node found")
                  port = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tspace_id")
                  port.SetPortValue("RS_INPUT_COLORSPACE_RAW ")
      
      if __name__ == "__main__":
          main()
      
      Traceback (most recent call last):
        File "scriptmanager", line 45, in <module>
        File "scriptmanager", line 37, in main
      TypeError: 'InternedId' object is not callable
      
      posted in Cinema 4D SDK
      D
      DEDAAN
    • Change texture node colorspace

      Hi
      I'm trying to change the colorspace of the selected texture nodes in a existing node material.

      I came across these topics but am unable to get it to work.
      https://developers.maxon.net/forum/topic/14331/editing-rs-nodes-with-python
      https://developers.maxon.net/forum/topic/14236/change-the-colorspace-of-redshift-texture-node/4?_=1672651116634

      Since I'm not very experienced with python, and especially for cinema I took this scripts as a starting point;
      https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/master/scripts/05_modules/node/access_graph_entities_2024_2.py

      This is what I have currently, but I'm getting the following error;

      Traceback (most recent call last):
        File "scriptmanager", line 73, in <module>
        File "scriptmanager", line 63, in main
      TypeError: 'InternedId' object is not callable
      

      Anyone able to help me out? 🙂

      import c4d
      import maxon
      
      doc: c4d.documents.BaseDocument # The active document.
      
      def main():
          # For the selected mateiral in the currently active document ...
          for material in doc.GetActiveMaterials():
              # ... get its node material reference and step over all materials which do not have a
              # Redshift graph or where the graph is malformed.
              nodeMaterial = c4d.NodeMaterial = material.GetNodeMaterialReference()
              if not nodeMaterial.HasSpace("com.redshift3d.redshift4c4d.class.nodespace"):
                  continue
      
              graph = maxon.GraphModelRef = nodeMaterial.GetGraph(
                  "com.redshift3d.redshift4c4d.class.nodespace")
              if graph.IsNullValue():
                  raise RuntimeError("Found malformed empty graph associated with node space.")
      
              # Get the root of the graph, the node which contains all other nodes.
              root = maxon.GraphNode = graph.GetRoot()
      
              # Iterate over all nodes in the graph, i.e., unpack things like nodes nested in groups.
              # With the mask argument we could also include ports in this iteration.
              for node in root.GetInnerNodes(mask=maxon.NODE_KIND.NODE, includeThis=False):
      
                  # There is a difference between the asset ID of a node and its ID. The asset ID is
                  # the identifier of the node template asset from which a node has been instantiated.
                  # It is more or less the node type identifier. When we have three RS Texture nodes
                  # in a graph they will all have the same asset ID. But their node ID on the other hand
                  # will always be unique to a node.
                  assetId = maxon.Id = node.GetValue("net.maxon.node.attribute.assetid")[0]
                  nodeId = maxon.Id = node.GetId()
      
                  # Step over everything that is not a Texture node, we could also check here for a node
                  # id, in case we want to target a specific node instance.
                  if assetId != maxon.Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler") and node.GetBit(c4d.BIT_ACTIVE):
                      print("texture node found")
                      port = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tspace_id")
                      port.SetDefaultValue("RS_INPUT_COLORSPACE_RAW ")
      
      
      
      
      
      if __name__ == "__main__":
          main()
      
      posted in Cinema 4D SDK 2024 python windows
      D
      DEDAAN