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

    Attach XPresso Graph to GUI via Python

    Cinema 4D SDK
    3
    9
    1.5k
    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.
    • A
      Ashton_FCS_PluginDev
      last edited by Ashton_FCS_PluginDev

      User Information:
      Cinema 4D Version: R19;
      Platform: Windows ;
      Language(s) : Python ;

      Hello Everyone!

      Its been a while I have not post anything. Well I have been getting an error on attaching a xpresso node graph to a gui manual
      dialog. I don't know or understand why its not working but hope y'all can he me. 😞
      Code:

              self.GroupBegin(self.ID_GRP, c4d.BFH_SCALEFIT, 1, 0, "")
              # Static UI Text
              self.AddStaticText(0, c4d.BFH_CENTER, 0, 15, "Node Editor", c4d.BORDER_WITH_TITLE_BOLD)
              # Get Active Document
              doc = c4d.documents.GetActiveDocument()
              if doc == None:
                  return False
              # Search for the Object in the (Objects) List Manger Hierarchy Outliner Tab.
              getnodeobj = doc.SearchObject("node")
              if getnodeobj == None:
                  return ValueError("Make sure the selected object.")       
              # Retrieves the Xpresso Tag
              graphtag = getnodeobj.GetTag(c4d.Texpresso)
              if graphtag is None:
                  raise ValueError("Make sure the selected object get an Xpresso Tag.")        
              else:
                  # Set Xpresso Tag Name
                  graphtag[c4d.ID_BASELIST_NAME]="Custom Node Graph Editor"
                  print(graphtag)
                  """
                  Retrieves the node master and retrieves the Root node (the Main XGroup) 
                  that holds all others nodes and set name of (the Main XGroup)
                  """
                  gvNodeMaster = graphtag.GetNodeMaster()
                  if gvNodeMaster is None:
                      raise RuntimeError("Failed to retrieves the Node Master.")
                  else:
                      nodegraph_root_group = gvNodeMaster.GetRoot()
                      if nodegraph_root_group is None:
                          raise RuntimeError("Failed to retrieves the Root Node.")
                      else:
                          # Set the Main XGroup Name            
                          nodegraph_root_group[c4d.ID_BASELIST_NAME]="Tool Node Editor"
                          print(nodegraph_root_group)
                      # Add to UI
                      self.AddUserArea(self.ID_NODE_VIEWPORT, c4d.BFH_CENTER, 350, 200)
                      self.AttachUserArea(gvNodeMaster, self.ID_NODE_VIEWPORT)
              self.GroupEnd()
      

      Error in Console:
      2019-12-04_6-55-11.png

      But if there is another way of making a custom node graph editor via python , I would love to know. 😁
      Any help would be very much appreciated.

      cheers, Ashton

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        How the Xpresso Node UI is added to a GeDialog is shown here: gedialog_gadgets.cpp

        However, since GvGetWorld() and related functions are not available in Python, I guess it is not possible to use the Xpresso UI in a Python based GeDialog.

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        A 1 Reply Last reply Reply Quote 0
        • A
          Ashton_FCS_PluginDev @s_bach
          last edited by Ashton_FCS_PluginDev

          @s_bach Hi s_bach Is there another way of making a custom node graph editor via python? Cause I dont know c++ , so any tip can be great.

          1 Reply Last reply Reply Quote 0
          • S
            s_bach
            last edited by

            Hello,

            you can implement a custom class based on GeUserArea. In such custom gadget, you can control everything: what is drawn, how it is drawn and how the user interaction works. The problem is that you have implement all of that yourself. So depending on the complexity of your desired solution, this can be a lot of work.

            See this previous discussion: Node Graph

            best wishes,
            Sebastian

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            A 1 Reply Last reply Reply Quote 0
            • A
              Ashton_FCS_PluginDev @s_bach
              last edited by Ashton_FCS_PluginDev

              @s_bach Okay I look at that tread, So pyQt is out of the window sense it's not good to use or wont work the right way and maxon is not going to add it or support it and don't do it for a commercial plugin, The only way is using c4d.gui.GeUserArea (GeUserArea) like Octane Node Graph and cmNodes. It will just be alot of work, when doing this with GeUserArea. I just want make sure I'm understanding everything correctly?

              1 Reply Last reply Reply Quote 0
              • S
                s_bach
                last edited by

                Yes, using GeUserArea is a way of creating a custom node editor (or any kind of custom UI).

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                A 1 Reply Last reply Reply Quote 0
                • A
                  Ashton_FCS_PluginDev @s_bach
                  last edited by

                  @s_bach Okay I will give it a try , and I will do a open source example project for anyone, who would love to do this with python only for Cinema 4D. lol I been making different types c4d python plugins for 3 years now, from 2015 for my studio I work for and I love making c4d plugins. But this will be my first time using GeUserArea Class to the fullest lol.🤣

                  1 Reply Last reply Reply Quote 0
                  • A
                    Ashton_FCS_PluginDev
                    last edited by

                    A little update on the node editor via Python 😉 small demo: Node Graph Editor via C4D Python API Video
                    I will share with the c4d py devs community when I'am done with this beast of a script.
                    2020-02-16_17-40-38.png

                    DunhouD 1 Reply Last reply Reply Quote 1
                    • DunhouD
                      Dunhou @Ashton_FCS_PluginDev
                      last edited by

                      @ashton_fcs_plugindev
                      That is so cool , Is it finish yet? I am new to GeUserArea too , That's a dreamly example to learn GeUserArea.

                      https://boghma.com
                      https://github.com/DunHouGo

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