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
    1. Maxon Developers Forum
    2. merkvilson
    3. Posts
    • Profile
    • Following 0
    • Followers 6
    • Topics 42
    • Posts 114
    • Best 8
    • Controversial 0
    • Groups 0

    Posts made by merkvilson

    • RE: Plugins Search Path from Preferences

      Thanks @ferdinand

      I wrote this little script for those who want to add one plugin path via the C4D script. I will update it later.
      It will NOT overwrite existing paths. Restart is required for instant result.

      import c4d
      import os
      import json
      
      
      def add_plugin_path(path, restart = False):
      
          if os.path.exists(path): new_path = path.replace("\\", "/")
          else:
              print("Path does not exists")
              return
      
          prefs_folder      = c4d.storage.GeGetC4DPath(c4d.C4D_PATH_PREFS)
          prefs_path        = os.path.dirname(prefs_folder)
          plugins_json_path = os.path.join(prefs_path, 'plugins.json')
      
      
          if os.path.exists(plugins_json_path):
              with open(plugins_json_path,'r',encoding="utf-8-sig") as plugins: plugins_json_raw = plugins.read()
              plugins_dict = json.loads(plugins_json_raw)
              content_dict = plugins_dict["content"]["_impl"]["_data"][1]["content"]
      
              # Check if the new path is already in Plugins Path
              for content_path in content_dict:
                  if os.path.normpath(content_path["_0"]["_path"]) == os.path.normpath(new_path):
                      print(f"'{new_path}' is already in Plugins Path.")
                      return
      
          else:
              plugins_dict = {
                  'identification': 'plugins',
                  'content': {
                      'referenceDataType': 'net.maxon.interface.datadictionary-C',
                          '_impl': {
                              '_mode': 2,
                              '_data': [
                                  {
                                      'dataType': 'net.maxon.datatype.id',
                                      'content': 'searchPaths'
                                  },
                                  {
                                      'dataType': '(net.maxon.interface.url-C,bool)',
                                      'isArray': True,
                                      'content': []}]}}}
      
      
      
          # Create new path content
          new_content = {
              "_0": {
                  "referenceIndex": len(plugins_dict["content"]["_impl"]["_data"][1]["content"]),
                  "referenceDataType": "net.maxon.interface.url-C",
                  "_scheme": "file",
                  "_path": new_path,
                  "_authority": {},
                  "_data": {}
              },
              "_1": True
          }
      
          # Append the new path to the list of paths
          plugins_dict["content"]["_impl"]["_data"][1]["content"].append(new_content)
      
          # Convert the dictionary back to a JSON string
          updated_plugins_dict = json.dumps(plugins_dict, indent=4)
      
          # Write the updated dictionary back to a JSON file
          with open(plugins_json_path, 'w') as plugins_json: plugins_json.write(updated_plugins_dict)
      
          if restart: c4d.RestartMe()
      
      custom_path = r"/Path/To/Plugin/Directory/"
      
      add_plugin_path(path = custom_path, restart = False)
      
      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson
    • Plugins Search Path from Preferences

      Hello.
      I'm trying to access and subsequently modify Plugins Search Path, which is located in the Preferences window.
      I have to accomplish this task via a Python script (not from pyp file).

      I have a problem at the first step when I'm trying to simply access its value and print it.

      import c4d
      
      pid, att = None, c4d.plugins.GetFirstPlugin()
      while att:
          if 'Plugins/Plugins' in str(att):
              pid = att.GetID()
              break
          att = att.GetNext()
      
      prefs = c4d.plugins.FindPlugin(pid)
      plugins = prefs[c4d.PREF_PLUGINS_PATHS]
      print(prefs[c4d.PREF_PLUGINS_PATHS])
      

      In this example, it prints an empty string even though several paths are already added.

      However, if I open the preferences window, it prints the correct values instead of an empty string. Is it possible to bypass opening the prefs window and make the script work correctly?

      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • RE: Dialog window with palette

      Is it possible to save and load the group window in a way similar to the l4d files?

      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson
    • RE: How do I create a menu item on the home screen next to the buttons.

      image.png

      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson
    • RE: How do I create a menu item on the home screen next to the buttons.

      Create a ".pyp" file in the Plugins directory(my_menu.pyp) and try this example.

      import c4d
      from c4d import gui
      
      def EnhanceMainMenu():
          mainMenu = gui.GetMenuResource("M_EDITOR")                 
          pluginsMenu = gui.SearchPluginMenuResource()               
      
      
          menu = c4d.BaseContainer()                                 
          menu.InsData(c4d.MENURESOURCE_SUBTITLE, "My Menu 1")  
          menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Ocube))      
          menu.InsData(c4d.MENURESOURCE_SEPERATOR, True);             
          menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Osphere))     
          menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Oplane))     
      
          submenu = c4d.BaseContainer()
          submenu.InsData(c4d.MENURESOURCE_SUBTITLE, "Menu 2 ")
          submenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_{}".format(c4d.Onull))     
          menu.InsData(c4d.MENURESOURCE_SUBMENU, submenu)
      
          if pluginsMenu: mainMenu.InsDataAfter(c4d.MENURESOURCE_STRING, menu, pluginsMenu)
          else: mainMenu.InsData(c4d.MENURESOURCE_STRING, menu)
      
      def PluginMessage(id, data):
          if id==c4d.C4DPL_BUILDMENU:
              EnhanceMainMenu()
      
      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson
    • Dialog window with palette

      How to create dialog window with pre-loaded pallete(l4d file)?

      I'm not talking about BITMAPBUTTON.
      I'm trying to include an actual undockable palette with all palette functionality, such as orientation change, the ability to hide/unhide text, icon size changing functionality, etc.

      I know that I can drag and drop l4d palette file into C4D and it will create a new window with the palette. I also know how to load a palette with Python script, but it will create a palette in its own window. I need to load the palette into my GeDialog window.

      19005a31-7e06-4bb0-a123-9d8e8d291e01-image.png

      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • Sound effector - Volume

      How to change the sound volume of the Sound Effector via Python Script?

      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • C4D crashes when removing node via MSG_MENUPREPARE

      What am I doing wrong? Need to remove the node under certain circumstances via MSG_MENUPREPARE but it crashes the C4D.
      Is it possible to somehow bypass this behavior? Is this a bug?

      
      import c4d
      import os
      
      
      class OBug_Check(c4d.plugins.ObjectData):
      
          def Message(self, node, type, data):
              if type == c4d.MSG_MENUPREPARE:
                  node.Remove()
      
              return True
      
      
      if __name__ == "__main__":
          c4d.plugins.RegisterObjectPlugin(id=1000003,
                                           str="Bug Check",
                                           g=OBug_Check,
                                           description="OBug_Check",
                                           info=c4d.OBJECT_GENERATOR,
                                           icon=None)
      
      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • Prevent selection

      Is it possible to prevent object/tag plugins from getting selected when clicking on them?

      Currently, If I click on let's say object generator plugin, it gets highlighted in the viewport, highlighted in the objects manager and its attributes manager shows on.
      I want to change the behavior, so if I have selected another non-plugin object and its attributes managers are visible I want to keep it even if I click the plugin object in the scene or the objects manager.

      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • Material node plugin

      Is it possible to create a Python Node Plugin for the Material node?
      I need something as simple as a node with Bool output or the String output port.

      If not, are there any plugins for implementing such feature?

      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • RE: GUI Bitmap Button Properties

      @ferdinand said in GUI Bitmap Button Properties:

      How to change BITMAPBUTTON_BACKCOLOR via the Command?

      I am not sure if I am understanding your question here correctly. You want to change the background color of a button after CreateLayout ran? That is not possible. You can flush layout groups and rebuild them at runtime (with buttons with a new color for example). I showed here once the pattern of a dynamic dialog.

      Is it possible to change the background color based on the toggle state?

      Thanks for your answers!

      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson
    • Can't generate Plugin ID

      Hello!
      I need to generate a new Plugin ID for Cinema 4D's plugin ASAP. But I can't log in to my account on the plugincafe forum.
      I tried to change the password but it changed only the current account password.

      posted in General Talk python
      merkvilsonM
      merkvilson
    • RE: GUI Bitmap Button Properties

      Hey @WickedP
      Thanks for your answer but unfortunately, that's not the case.

      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson
    • GUI Bitmap Button Properties

      Hello everyone!
      I have a few questions.
      3e1e6afb-bdbd-4efa-bc65-f0019ec99755-image.png

      • How to remove padding between buttons?
      • How to change BITMAPBUTTON_BACKCOLOR via the Command? (When pressing on it)
      • How to activate fading fading when the back color is activated?
      import c4d
      
      class test_dialog(c4d.gui.GeDialog):
      
          def CreateLayout(self):
      
      
              self.GroupBegin(id=0, flags=c4d.BFH_SCALEFIT, rows=1, title=" ", cols=2, groupflags=0)
      
              bc = c4d.BaseContainer()
              bc[c4d.BITMAPBUTTON_BUTTON] = True
              bc[c4d.BITMAPBUTTON_ICONID1] = c4d.Ocube
              bc[c4d.BITMAPBUTTON_BACKCOLOR] = c4d.COLOR_BG_PALETTE
              bc[c4d.BITMAPBUTTON_DISABLE_FADING] = False
              self.bitmapButton = self.AddCustomGui(100001,
                                                    c4d.CUSTOMGUI_BITMAPBUTTON, "",
                                                    c4d.BFH_CENTER | c4d.BFV_CENTER,
                                                    0, 0, bc)
      
      
              bc = c4d.BaseContainer()
              bc[c4d.BITMAPBUTTON_BUTTON] = True
              bc[c4d.BITMAPBUTTON_ICONID1] = c4d.Osphere
              bc[c4d.BITMAPBUTTON_BACKCOLOR] = c4d.COLOR_BG_PALETTE
              bc[c4d.BITMAPBUTTON_DISABLE_FADING] = False
              self.bitmapButton = self.AddCustomGui(100002,
                                                    c4d.CUSTOMGUI_BITMAPBUTTON, "",
                                                    c4d.BFH_CENTER | c4d.BFV_CENTER,
                                                    0, 0, bc)
      
              return True
      
      
          def Command(self, id, msg):
      
      
              if id == 100001:
                  print("Click Detected")
                  #Change  BITMAPBUTTON_BACKCOLOR
      
              return True
      
      
      def main():
          global dialog
          dialog = test_dialog()
          dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=-2, defaulth=-2)
      
      
      if __name__ == '__main__':
          main()
      
      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • c4d.gui.ShowPopupDialog Hide search entry

      Hello!

      I have a popup menu dialog with several options. c4d.gui.ShowPopupDialog
      If I add more than a certain number of options, it automatically adds the Search Entry. Is it possible to remove the search entry? 🤔

      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • Display points

      Hello PluginCafe!

      I'm trying to display object points via the tag plugin.
      The code worked fine in older versions of C4D but it has no effect in the latest versions.
      Am I doing anything wrong?

          def Draw(self, tag, op, bd, bh):
      
              bd.SetPen( c4d.Vector(1))
              bd.SetPointSize( 3 )
              bd.SetMatrix_Screen()
              bd.SetDepth(True)
              objMg = op.GetMg() #Get the world (global) matrix 
      
              ptList = op.GetCache().GetAllPoints()
      
              points = [objMg * p for p in ptList]  # Retrieves Global Coordinates
              screenPoints  =  [ bd.WS(p) for p in points ]  # From world to screen Coordinates (in another array)
              bd.DrawPoints(screenPoints, vc = None, colcnt=1, vn=None)
      
              return c4d.DRAWRESULT_OK
      
      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • RE: urllib2.HTTPError: HTTP Error 403

      Code:

      import c4d, urllib2, os
      
      url = r"https://www.patreon.com/posts/24993001"
      
      f = os.path.join(os.path.dirname(c4d.storage.GeGetStartupApplication()), "resource", "ssl", "cacert.pem")
      
      urllib2.urlopen(url, cafile=f)
      

      Error:

      Traceback (most recent call last):
        File "scriptmanager", line 7, in <module>
        File "C:\Program Files\MAXON\Cinema 4D R20 Demo\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 154, in urlopen
          return opener.open(url, data, timeout)
        File "C:\Program Files\MAXON\Cinema 4D R20 Demo\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 435, in open
          response = meth(req, response)
        File "C:\Program Files\MAXON\Cinema 4D R20 Demo\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 548, in http_response
          'http', request, response, code, msg, hdrs)
        File "C:\Program Files\MAXON\Cinema 4D R20 Demo\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 473, in error
          return self._call_chain(*args)
        File "C:\Program Files\MAXON\Cinema 4D R20 Demo\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 407, in _call_chain
          result = func(*args)
        File "C:\Program Files\MAXON\Cinema 4D R20 Demo\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 556, in http_error_default
          raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
      urllib2.HTTPError: HTTP Error 403: Forbidden
      
      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson
    • urllib2.HTTPError: HTTP Error 403

      urllib2 no longer has any effect in Cinema 4D.
      It is worth mentioning that I did not change anything in my code. It was working like a charm.
      I doubt the latest windows update corrupted it.
      Are there any solutions to bypass this limitation?

      Traceback (most recent call last):
        File "C:\Users\Merk\Documents\GIT Projects\c4d_plugins\Symex\symex.pyp", line 74, in <module>
          check.UpdateAtStartUp(version, url, command = 1051407,)
        File "C:\Users\Merk\Documents\GIT Projects\c4d_plugins\Symex\res\modules\checkUpdate.py", line 171, in UpdateAtStartUp
          if NewVersion(version, url,)[0]:
        File "C:\Users\Merk\Documents\GIT Projects\c4d_plugins\Symex\res\modules\checkUpdate.py", line 68, in NewVersion
          htmlsource = urllib2.urlopen(url, cafile=f)
        File "C:\Program Files\MAXON\Cinema 4D R20\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 154, in urlopen
          return opener.open(url, data, timeout)
        File "C:\Program Files\MAXON\Cinema 4D R20\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 435, in open
          response = meth(req, response)
        File "C:\Program Files\MAXON\Cinema 4D R20\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 548, in http_response
          'http', request, response, code, msg, hdrs)
        File "C:\Program Files\MAXON\Cinema 4D R20\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 473, in error
          return self._call_chain(*args)
        File "C:\Program Files\MAXON\Cinema 4D R20\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 407, in _call_chain
          result = func(*args)
        File "C:\Program Files\MAXON\Cinema 4D R20\resource\modules\python\libs\win64\python27.vs2008.framework\lib\urllib2.py", line 556, in http_error_default
          raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
      urllib2.HTTPError: HTTP Error 403: Forbidden
      
      posted in Cinema 4D SDK python
      merkvilsonM
      merkvilson
    • RE: DrawMultipleHUDText issue

      OK. Now I get it. 👌

      Thank you very much! I really appreciate what you've done. 😁

      Have a good day! 💙

      -Merk

      posted in Cinema 4D SDK
      merkvilsonM
      merkvilson