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
    1. Maxon Developers Forum
    2. m_adam
    3. Posts
    M
    • Profile
    • Following 0
    • Followers 8
    • Topics 3
    • Posts 1,460
    • Best 521
    • Controversial 0
    • Groups 2

    Posts made by m_adam

    • RE: How to create a control and switch between multiple fields

      I'm not sure I understand you correctly, you do not have to use QuickTabRadio bar with resource, you just retrieve the int value of the parameter, in the case of the previous example I share with a GetInt32(c4d.MGCLONER_VOLUMEINSTANCES_MODE).

      If you can provide a code example of what is blocking you that would be nice.
      You can find a non-exhaustive list of type of control available in *res file within the C++ documentation in Description Resource.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Document copied for Picture viewer doesnt copy contents of child of a TagData

      Hey you are not supposed to modify the scene graph during the init function.
      Adding children to a tag while it may be possible is as far as I know not something done in Cinema 4D. so for optimization purpose I would not be surprised that they are never copied at all.

      With that's said I would recommend you to use a custom branch to store your BaseList2D as demonstrated in C++ SDK: Custom Branching Code Example .
      In last case you should implement the CopyTo to properly copy your data when your node is copied. But again modifying the scene Graph during the Init is not the way to got.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Determine object category (Generator, Deformer, etc.) via Python

      Hey the internal function is not exposed in Python neither in C++. Sadly the function also use a function that is only exposed in C++ with no proper workaround.

      Here is the C++ implementation of the function

      inline cinema::OBJECTCATEGORY ObjectToCategory(const cinema::BaseObject& object)
      {
      	return ObjectToCategory(object.GetType(), object.GetInfo());
      }
      
      inline cinema::OBJECTCATEGORY ObjectToCategory(cinema::Int32 type, cinema::Int32 objectInfo)
      {
      	cinema::OBJECTCATEGORY category = cinema::OBJECTCATEGORY::OTHER;
      
      	switch (type)
      	{
      		case Oweighteffector:	category = cinema::OBJECTCATEGORY::DEFORMER;		break; // FIX[4850]
      		case Ojoint:					category = cinema::OBJECTCATEGORY::JOINT;				break; // FIX[4853]
      		case Onull:						category = cinema::OBJECTCATEGORY::NULLOBJECT;	break;
      		case Opolygon:				category = cinema::OBJECTCATEGORY::POLYGON;			break;
      		case Osds:						category = cinema::OBJECTCATEGORY::HYPERNURBS;	break;
      		case Ocamera:				
      		case Orscamera:
      			category = cinema::OBJECTCATEGORY::CAMERA; break;
      		case Olight:				
      		case Orslight:
      			category = cinema::OBJECTCATEGORY::LIGHT; 
      			break;
      
      		case Oenvironment:
      		case Oforeground:
      		case Obackground:
      		case Ofloor:
      		case Osky:
      		case Ostage:
      		case Oselection:				category = cinema::OBJECTCATEGORY::SCENE; break;
      
      		case Oworkplane:				category = cinema::OBJECTCATEGORY::GRID; break;
      
      		case 1001414: // ID_TP_PARTICLEGEOMETRY
      		case Ofpgroup: // new particle group
      		case Ofpmultigroup: // new particle multi group
      		case Oparticle:					category = cinema::OBJECTCATEGORY::PARTICLE; break;
      
      		case Ovolume:
      		case Osimulationscene:
      		// ITEM#128166 Alembic: Viewport and Selection Filter recognizes it as Spline
      		case Oalembicgenerator:	category = cinema::OBJECTCATEGORY::GENERATOR; break;
      
      			// ITEM#9437 MoGraph and Spline Display Filter
      		case Omgcloner:					category = cinema::OBJECTCATEGORY::GENERATOR; break; // Omgcloner
      		case Ohair: 						category = cinema::OBJECTCATEGORY::HAIR; break; // Ohair
      
      		default:
      		{
      			// This function is not exposed in Python, so use objectInfo directly
      			if (!cinema::C4DOS_Bo->ObjectTypeToCategory(type, category))
      			{
      				// ITEM#133494 Spline filter doesn't filter splines
      				// i gave ISSPLINE the highest priority back and added switches for alembic and cloner generators above
      				if (objectInfo & OBJECT_ISSPLINE)
      					category = cinema::OBJECTCATEGORY::SPLINE;
      				else if (objectInfo & OBJECT_GENERATOR)
      					category = cinema::OBJECTCATEGORY::GENERATOR;
      				else if (objectInfo & OBJECT_MODIFIER)
      					category = cinema::OBJECTCATEGORY::DEFORMER;
      				else if (objectInfo & OBJECT_PARTICLEMODIFIER)
      					category = cinema::OBJECTCATEGORY::PARTICLE;
      				else if (objectInfo & OBJECT_FIELDOBJECT)
      					category = cinema::OBJECTCATEGORY::FIELD;
      			}
      			break;
      		}
      	}
      
      	return category;
      }
      

      With that's said I've made a note for myself to implement this function in Python (no ETA).
      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: How to create a control and switch between multiple fields

      Hey @lanxiang I guess you are using *.res file to define the layout.
      For the red part this is the first one is defined like that:

      LONG MGCLONER_VOLUMEINSTANCES_MODE
      {
      	CUSTOMGUI QUICKTABRADIO;
      	CYCLE
      	{
      		MGCLONER_VOLUMEINSTANCES_MODE_NONE;
      		MGCLONER_VOLUMEINSTANCES_MODE_RENDERINSTANCE;
      		MGCLONER_VOLUMEINSTANCES_MODE_RENDERMULTIINSTANCE;
      	}
      }
      

      Then based on the value you will need to hide/unhide other elements within the GetDDescription method as shown here.

      The green one is a vector with a step of 1 and its defined like that:

      VECTOR	MG_GRID_RESOLUTION
      {
      	MIN 1;
      	MAX 2000000;
      	STEP 1;
      	OPEN;
      }
      

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Forcing GetDDescription() refresh in ToolData plugin (EventAdd not working)

      Hey @Viktor-Velicko I'm busy this week and I will be able to have a deeper look at it only next week.

      With that's said here are few hints (at least what I would try first).

      • Send COREMSG_CINEMA_FORCE_AM_UPDATE.
      • Call GeUpdateUI.
      • It may not be possible at all to do during a drag operation (but I will ask about it only once the two previous solutions are confirmed to not work, which I do not have the time to test right now).

      Cheers,
      Maxime

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Set VERTEXCOLOR in PaintTool

      Hey @randymills Python provide helper to directly call SetParameter on the correct parameter just with the integer value.
      With that's said internally we construct a DescID which is constructed from one or multiples DescLevel. SetParameter usually only deal DescID, since only DescID are able to identify a given parameter.

      With that's said here is you code working as expected demonstrating you both way.

      import c4d
      
      doc: c4d.documents.BaseDocument  # The currently active document.
      op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
      
      def main() -> None:
          if op is None:
              raise RuntimeError("No object selected")
          
          c4d.CallCommand(431000045) # Create Vertex Color Tag
      
          doc.SetAction(1021286)  #Makes the paint tool active  
          tool = doc.GetAction()  
          tool = c4d.plugins.FindPlugin(tool, c4d.PLUGINTYPE_TOOL)
          if not tool:
              print("Vertex Paint tool not found!")
              return False
          
              
          # Use SetParameter directly
          if True:
              myVertexColor = c4d.Vector(0.0,1.0,0.0) # Green
              
              vertexColorSuccess = tool.SetParameter(c4d.ID_CA_PAINT_TOOL_VERTEXCOLOR, myVertexColor, c4d.DESCFLAGS_SET_NONE)
              if not vertexColorSuccess:
                  print("Failed to set vertex color parameter!")
                  return False
              
              # Debug: Verify the parameter was set
              current_value = tool.GetParameter(c4d.ID_CA_PAINT_TOOL_VERTEXCOLOR, c4d.DESCFLAGS_GET_NONE)
              print(f"Set color: {current_value}")
          
          
                
          
          # Use DescID and DescLevel
          if True:
              myVertexColor = c4d.Vector(1.0,0.0,0.0) # Red
              descLevel = c4d.DescID(c4d.DescLevel(c4d.ID_CA_PAINT_TOOL_VERTEXCOLOR, c4d.DTYPE_VECTOR, 0)) 
              vertexColorSuccess = tool.SetParameter(descLevel, myVertexColor, c4d.DESCFLAGS_SET_NONE)
              if not vertexColorSuccess:
                  print("Failed to set vertex color parameter!")
                  return False
              
              # Debug: Verify the parameter was set
              current_value = tool.GetParameter(descLevel, c4d.DESCFLAGS_GET_NONE)
              print(f"Set color: {current_value}")
          
          
              desc_level = c4d.DescID(c4d.DescLevel(c4d.ID_CA_PAINT_TOOL_VERTEXCOLOR, c4d.DTYPE_VECTOR, 0))    
          
          # tool[c4d.ID_CA_PAINT_TOOL_VERTEXCOLOR]=myVertexColor
          # myVertexColorTag = c4d.DescID(c4d.ID_CA_PAINT_TOOL_VERTEXCOLOR, c4d.DTYPE_VECTOR, 0)
          # tool.SetParameter(myVertexColorTag, myVertexColor, c4d.DESCFLAGS_SET_0)
          c4d.CallButton(tool, c4d.ID_CA_PAINT_TOOL_APPLY_ALL) # Applies the color to all vertices
          c4d.EventAdd()
      if __name__ == '__main__':
          main()
      

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Hide RenderPost settings

      @Dunhou said in Hide RenderPost settings:

      I think you need to override RenderEngineCheck to false, the document said:

      Bool MyRenderer::RenderEngineCheck(const BaseVideoPost* node, Int32 id) const
      {
        switch (id)
        {
          case RENDERSETTING_STATICTAB_MULTIPASS:
          case RENDERSETTING_STATICTAB_ANTIALIASING:
          case RENDERSETTING_STATICTAB_OPTIONS:
          case RENDERSETTING_STATICTAB_STEREO:
            return false;
        }
       
        return true;
      }
      

      Cheers~
      DunHou

      Thanks that's indeed the correct way to do it

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Hide RenderPost settings

      Hi @npwouters I'm sorry I've very limited time, right now I will try to have a look at it tomorrow (just that you do not think we have forgotten you) or in worse case Wednesday.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: How can I add the secondary greyed-out text in the Object Manager?

      Hey you need to react to MSG_GETCUSTOM_NAME_ADDITION and return a dict with the expected string with the "res" key.

      You need to register your object with c4d.OBJECT_CUSTOM_NAME_ADDITION to have the additional name displayed in the Object Manager.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Edge ring selection

      Hi @Tpaxep,

      Welcome to the Maxon developers forum and its community, it is great to have you with us!

      Getting Started

      Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.

      • Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
      • Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
      • Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.

      It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: How to Ask Questions.

      About your First Question

      The tool has indeed been updated, but the docs were not.

      Here is how to call it. Note that you have to pass a polygon index, this is mandatory and it needs to be adjacent to one of the vertex to indicate a direction of the ring selection. Here is your script adapted, to be run on a sphere that was made editable.

      import c4d
      from c4d import utils
      
      def select_ring_edge(obj, v1Id, v2Id, polyId):
          bc = c4d.BaseContainer()
          bc.SetData(c4d.MDATA_RING_SEL_STOP_AT_SELECTIONS, False)
          bc.SetData(c4d.MDATA_RING_SEL_STOP_AT_NON_QUADS, False)
          bc.SetData(c4d.MDATA_RING_SEL_STOP_AT_POLES, True)
          bc.SetData(c4d.MDATA_RING_BOTH_SIDES, False)
          bc.SetData(c4d.MDATA_RING_SWAP_SIDES, False)
          
          bc.SetData(c4d.MDATA_RING_FIRST_VERTEX, v1Id)
          bc.SetData(c4d.MDATA_RING_SECOND_VERTEX, v2Id)
          bc.SetData(c4d.MDATA_RING_POLYGON_INDEX, polyId)
          
          
          bc.SetData(c4d.MDATA_RING_SELECTION, c4d.SELECTION_NEW)
      
          result = c4d.utils.SendModelingCommand(
              command=c4d.ID_MODELING_RING_TOOL,
              list=[obj],
              mode=c4d.MODELINGCOMMANDMODE_EDGESELECTION,
              bc=bc,
              doc=c4d.documents.GetActiveDocument(),
              flags=c4d.MODELINGCOMMANDFLAGS_NONE
          )
          c4d.EventAdd()
          return result
      
      def main():
          doc = c4d.documents.GetActiveDocument()
          obj = doc.GetActiveObject()
          if obj is None:
              c4d.gui.MessageDialog("select obj.")
              return
      
          firstVertex = 346
          secondVertex = 347
          polygonIndex = 312
      
          result = select_ring_edge(obj, firstVertex, secondVertex, polygonIndex)
          if result:
              print("DONE")
          else:
              print("ERROR")
      
      if __name__ == '__main__':
          main()
      

      Note that the same settings also apply for the ID_MODELING_LOOP_TOOL, just modify RING by LOOP in the constant so MDATA_RING_SEL_STOP_AT_SELECTIONS become MDATA_LOOP_SEL_STOP_AT_SELECTIONS.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: How to implement an image control that can receive and generate image data drag events

      Did you had a look at geuserarea_drag_r13.py? There is no else statement but that would be the perfect place to do something specific on single click. But there is no built-in solution you have to kind of track all by yourself as done line 294.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: adding assets to a userdatabase in the assetbrower with Python

      Hi @wen I've moved your topic to the bug section since it's indeed a bug, I will ping you on this topic once the fix is available, it should come in one of the next update.
      The issue is that the internal cache is not properly updated and therefor this is failing.

      With that's said there is a ugly workaround which consist of calling it twice so the cache is properly updated.
      Find bellow a version that is going to work in all versions

      import c4d
      import maxon
      import os
      
      
      def CreateRepFromUrl(url: maxon.Url) -> maxon.UpdatableAssetRepositoryRef:
          """Create a new repository from a given database URL.
          
          If there is no valid database at the given URL, it creates a database at the URL.
          It always create a new repository and the associated database asset, even if there
          are existing repositories for that database.
          """
          # Make type checks
          if not isinstance(url, maxon.Url):
              raise TypeError("First argument is not a maxon.Url")
      
          # Create a unique identifier for the repository.
          rid = maxon.AssetInterface.MakeUuid(str(url), True)
      
          # Repositories can be composed out of other repositories which are called bases. In this
          # case no bases are used to construct the repository. But with bases a repository for all
          # user databases could be constructed for example.
          bases = maxon.BaseArray(maxon.AssetRepositoryRef)
      
          # Create a writable and persistent repository for the database URL. If #_dbUrl would point
          # to a location where no database has been yet stored, the necessary data would be created.
          if c4d.GetC4DVersion() < 2025200:
              try:
                  repository = maxon.AssetInterface.CreateRepositoryFromUrl(
                      rid, maxon.AssetRepositoryTypes.AssetDatabase(), bases, url, True, False, False, None)    
              except Exception as e:
                  repository = maxon.AssetInterface.CreateRepositoryFromUrl(
                      rid, maxon.AssetRepositoryTypes.AssetDatabase(), bases, url, True, False, False, None)    
          else:
              try:
                  repository = maxon.AssetInterface.CreateRepositoryFromUrl(
                      rid, maxon.AssetRepositoryTypes.AssetDatabase(), bases, url, True, False, False)    
              except Exception as e:
                  repository = maxon.AssetInterface.CreateRepositoryFromUrl(
                      rid, maxon.AssetRepositoryTypes.AssetDatabase(), bases, url, True, False, False)    
      
          if not repository:
              raise RuntimeError("Repository construction failed.")
      
          return repository
      
      if __name__ == '__main__':
          if not maxon.AssetDataBasesInterface.WaitForDatabaseLoading():
              raise RuntimeError("Could not load asset databases.")
          dbPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "testdb")
          print(CreateRepFromUrl(maxon.Url(dbPath)))
      

      Cheers,
      Maxime.

      posted in Bugs
      M
      m_adam
    • RE: plugin Loupedeck CT with Redshift

      Hi @shafy sorry for the delay I was away for few times.

      Before we start please read the Support Procedure - About AI-Supported Development. Keep in mind we are not there to develop for you neither integrate or guide you with 3rd party module that you will most likely need in order to control knobs.

      With that's said what you are asking (at least retrieving a parameter and defining it) is possible for Redshift light intensity. It is as easy as drag and dropping the parameter you are interested by into the Cinema 4D Python Console as explained in Python Script Manager Manual - Drag And Drop. Additionally you can also use the Script Log to record a script or change and therefor re-execute it.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: How to expose C++ symbols to Python users as a third party?

      Hi @ECHekman sorry it took me more time than I expected. From my meory octane already have a Python module registered in C++. So I assume you want to add symbols to this python module.

      One important aspect is that the Symbol Parser by itself is completly agnostic of the c4d module therefor you can call it with any Python interpreter. This point is really important because this let you parse your C++ header files whenever you want within your build pipeline.

      With that's said the Symbol Parser is bundled within the mxutils package which needs the c4d and maxon module.
      So in order to have it running with any python intepreter you will need to do the following:

      import sys
      CI_PROJECT_DIR = r"C:\Users\m_adam.INTERN\Documents\MAXON\gitlab\c4d"
      
      # Build path to import the parser_symbol
      maxon_python_path = os.path.join(CI_PROJECT_DIR, "resource", "modules", "python", "libs")
      if not os.path.exists(maxon_python_path):
          raise RuntimeError(f"DEBUG: update_python_symbols - Unable to find {maxon_python_path}")
      
      # Get python311 folder where the symbol parser is located
      mxutils_path, symbol_parser_path = None, None
      for folder in os.listdir(maxon_python_path):
          full_path_folder = os.path.join(maxon_python_path, folder)
          if not os.path.isdir(full_path_folder):
              continue
      
          # We found the mxutils module containing the symbol parser.
          if os.path.exists(os.path.join(full_path_folder, "mxutils", "symbol_parser")):
              mxutils_path = os.path.join(full_path_folder, "mxutils")
              symbol_parser_path = os.path.join(mxutils_path, "symbol_parser")
      
      if None in (mxutils_path, symbol_parser_path):
          raise ImportError(f"Could not find 'symbol_parser' module path in {maxon_python_path}.")
      
      sys.path.append(mxutils_path)
      print(f"DEBUG: Added {mxutils_path} to sys.path.")
      
      # Import the symbol parser and do your stuff.
      import symbol_parser
      # Do something with it
      
      sys.path.remove(mxutils_path)
      

      Then the Symbol Parser paradigm is that you first parse your data and then the parser contain Scope that contains member (a name and a value).
      Therefor once you have parsed your data you can freely output to multiple format if needed. You can also write your own format if you want to.
      In this case because you are using mostly the Cinema API and not the Maxon API I re-use the same output as the one we use for the c4d Python package.
      This output is implemented in c4d\resource\modules\python\libs\python311\mxutils\symbol_parser\output_classic_api.py. Everything in the Symbol Parser is open source so feel free to look at it.

      So to get back to your question find bellow the next code that will parse all the resources files from the Redshift folder and insert them within the "redshift" Python Package. (You usually do not have to do that because Python is parsing automatically the c4d_symbols.h and include such symbols within the c4d Python package this is for the example). With that's said there is basically two ways, one hardcoding the parsed value in your C++ plugin when you register your Python module, the second one using a Python file that will get loaded at the startup of Cinema 4D once your Python module is already loaded and therefor inject symbol into your module.

      import os
      import c4d # Only used to retrieve various C4D paths used in this example, but not really necessary otherwise
      
      # These imports bellow are not bound to the c4d module therefor they can be used with a standard Python3 interpreter
      # But this code is written to be executed in the Script Manager, so you may need to adapt the import statement according to how you run this script.
      from mxutils.symbol_parser.extractor import SymbolParser
      from mxutils.symbol_parser.output_classic_api import _get_symbol_dict_from_parser
      
      
      def ParseRedshiftResources() -> SymbolParser:
          # Parse all Redshift ressource files and resolve their values
          rsDir = os.path.join(os.path.dirname(c4d.storage.GeGetStartupApplication()), "Redshift", "res", "description")
          parser = SymbolParser(rsDir,
                                  parse_mx_attribute=False,
                                  parse_define=True,
                                  parse_enum=True,
                                  parse_static_const=True)
      
          # Parse and resolve. Resolve means:
          #  - Transfrom values that depends to others to their actual integer or float values.
          #  - Transform complex values (such as bit mask, arithmetic, etc) into their actual integer or float values.
          # For more information about what is supported take a look at
          # https://developers.maxon.net/docs/py/2025_2_0/manuals/manual_py_symbols.html?highlight=symbol%20parser#symbols-parser-features
          parser.parse_all_files(resolve=True)
          return parser
      
      
      def OutputPythonFile(parser: SymbolParser):
          def GeneratePythonFileToBeInjected(parser: SymbolParser) -> str:
              """Generate a Python file that will inject all parsed symbols into the 'redshift' Python package when this file get imported.
              This function needs to be called once, most likely during your build pipeline.
              Once you have generated this Python file you should bundle it with your installer and then install it in the targeted Cinema 4D installation.
              See PatchCurrentC4DToInjectParsedSymbol for an example of such deployment
              """
              import tempfile
      
              tempPath = None
              # Retrieve a sorted dict containing the symbol name as key and it's value as values
              # This will flatten all scopes so an enums called SOMETHING with a value FOO in it will result in a symbol named SOMETHING_FOO
              # If you do not want this behavior feel free to create your own solution, this function is public and declared in
              # c4d\resource\modules\Python\libs\python311\mxutils\symbol_parser\output_classic_api.py
              symbolTable = _get_symbol_dict_from_parser(parser)
              
              with tempfile.NamedTemporaryFile('w', delete=False) as tmpFile:
                  tempPath = tmpFile.name
                  
                  tmpFile.write("import redshift\n")
                  
                  for name, value in symbolTable.items():
                      tmpFile.write(f"redshift.{name} = {value}\n")
                  
              
              if not os.path.exists(tempPath):
                  raise RunTimeError('Failed to create the Python File to Inject Symbols in "redshift" Python Package') 
              
              return tempPath
      
          def PatchCurrentC4DToInjectParsedSymbol(fileToBeLoaded: str):
              """This function is going to create a Python file that is going to be called at each startup of Cinema 4D to inject symbols into the "redshift" Python package.
              This is done by placing the previous file in a place where it can be imported by the C4D Python VM.
              And by importing this file by editing the python_init.py file located in the preferences.
              For more information about it please read 
              https://developers.maxon.net/docs/py/2025_2_0/manuals/manual_py_libraries.html?highlight=librarie#executing-code-with-Python-init-py
              """
              import sys
              import shutil
              
              # Pref folder that contains a python_init.py that is laoded once c4d and maxon package is loaded and a libs folder that is part of the sys.path of the c4d Python VM.
              pyTempDirPath = os.path.join(c4d.storage.GeGetStartupWritePath(), f"Python{sys.version_info.major}{sys.version_info.minor}")
          
              # Path to our module that will inject the parsed symbols in the "redshift" Python package
              pyTempRsDirPath = os.path.join(pyTempDirPath, "libs", "rs_symbols")
              # Path to the __init__ file of our module that will be called when we import our module
              # we need to place the file we generated previously in this location.
              pyTempRsFilePath = os.path.join(pyTempDirPath, "libs", "rs_symbols", "__init__.py")
              if not os.path.exists(pyTempRsDirPath):
                  os.mkdir(pyTempRsDirPath)
                  
              if os.path.exists(pyTempRsFilePath):
                  os.remove(pyTempRsFilePath)
                  
              shutil.copy2(fileToBeLoaded, pyTempRsFilePath)
              
              # Now that we have our module that will inject symbols within the "redshift" Python package. We need to get this "rs_symbols" module be called at each startup.
              # So we use the python_init.py file to get loaded once all plugins are loaded. Therefor the Redshift plugin is already loaded and have already setup its "redshift" Python package.
              # We will inject a line in this file to load our "rs_symbols" module
              pyTempInitFilePath = os.path.join(pyTempDirPath, "python_init.py")
              
              isImportRsSymbolPresent = False
              initFileExist = os.path.exists(pyTempInitFilePath)
              # Because this file me be already present and already patched or contain other content
              # We should first check if we need to add our import or not
              if initFileExist:
                  with open(pyTempInitFilePath, 'r') as f:
                      isImportRsSymbolPresent = "import rs_symbols" in f.read()
              
              # prepend our import statement to the file
              if not isImportRsSymbolPresent:
                  with open(pyTempInitFilePath, "w+") as f:
                      content = f.read()
                      f.seek(0, 0)
                      f.write('import rs_symbols\n' + content)
      
          pythonFileGeneratedPath = GeneratePythonFileToBeInjected(parser)
          PatchCurrentC4DToInjectParsedSymbol(pythonFileGeneratedPath)
      
      
      def OutputCppFile(parser):
          # Retrieve a sorted dict containing the symbol name as key and it's value as values
          # This will flatten all scope so an enums called SOMETHING with a value FOO in it will result in a symbol named SOMETHING_FOO
          # If you do not want this behavior feel free to create your own solution, this function is public and declared in
          # c4d\resource\modules\Python\libs\python311\mxutils\symbol_parser\output_classic_api.py
          symbolTable = _get_symbol_dict_from_parser(parser)
          
          contentToPaste =  'auto mod_rs = lib.CPyImport_ImportModule("redshift");\n'
          contentToPaste += 'auto modDict = lib.CPyModule_GetDict(mod_rs);\n'
              
          for name, value in symbolTable.items():
              contentToPaste += f'\nauto name = lib.CPyUnicode_FromString("{name}");\n'
              contentToPaste += 'if (!name)\n'
              contentToPaste += '  CPyErr_Print();\n'
              contentToPaste += f'maxon::py::CPyRef value = lib.CPyLong_FromInt32({value});\n'
              contentToPaste += 'if (!value)\n'
              contentToPaste += '  CPyErr_Print();\n'
              contentToPaste += 'if (!lib.CPyDict_SetItem(modDict, name, value))\n'
              contentToPaste += '  CPyErr_Print();\n'
                      
          return contentToPaste
      
      
      def main() -> None:
          # Parse the Redshift resources and return the parser that hold the parsed values
          parser = ParseRedshiftResources()
      
          # First way: Generate a file that patch the current C4D with a Python file that you need to deploy on the installer. You may prefer this option since you can update this file without having to recompile your plugin.
          OutputPythonFile(parser)
      
          # Second way: Output pseudo C++ code that can be pasted within your C++ plugin after you initialize your custom Python module. You may want to call this whole script before you compile in your build pipeline and put the "cppContent" within a file that will get compiled automatically
          cppContent = OutputCppFile(parser)
      
      if __name__ == '__main__':
          main()
      

      So the system is really modular and being able to run on a regular Python interpreter let you integrate it within your build pipeline to suits your needs.
      If you have any questions, please let me know.
      Cheers,
      Maxime.

      posted in General Talk
      M
      m_adam
    • RE: Move the plane in random effect

      Hi @Fabio-B

      Thank you for reaching out to us. Unfortunately, your question is off topic for the forum you have posted in. Please check the Forum Overview for an overview of the scope of the different forums.

      On this forum we only provide support for third party software developers about the Cinema 4D Software Development Kit. We unfortunately cannot provide end user support, as we lack the tools and the knowledge to do so.

      To receive end-user support, please visit our Support Center and create a ticket for your issue

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: C4D Python: Redshift IPR Start/Stop Control

      @hoganXYZ hi if it does not appear in the script log then there is no clear rules. Sometimes there is another way sometimes now it depends on how it is implemented. For the one you asked I do not think it is possible. Best bet would be to ask Redshift on their forum.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: How to expose C++ symbols to Python users as a third party?

      Hi just to let you know I will answers you next week Monday.

      Cheers,
      Maxime.

      posted in General Talk
      M
      m_adam
    • RE: lhit from BaseVolumeData

      Hi sadly there is not much you can do with it in Python. The only use case is if your want to create a kind of hashmap on the pointer, but I do not see a big use case of that to be honest. I will see if I can improve thing a bit here, because in C++ via the lhit you can retrieve the polygon and the underlying object being hit, which is important information but this is very low on my priority list. So in general regarding shader I would say you better at look at C++ since in any case doing a Shader in Python will most likely be a performance killer.

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: C4D Python: Redshift IPR Start/Stop Control

      Hi @itstanthony you can use c4d.CallCommand(1040239) to toggle the start/stop of the Redshift IPR.
      You can know such command ID by using the Script Log and doing the action you want to.

      Then to check if the command is active you can use c4d.IsCommandChecked(1040239).

      Cheers,
      Maxime.

      posted in Cinema 4D SDK
      M
      m_adam
    • RE: Set RenderData framerate causing C4D to crash

      Hi I was able to reproduce the issue and fix it for the next version.
      The bug is that setting RDATA_FRAMERATE require the RenderData to be part of a document in case the "Use Project Frame Rate" is enabled on the render settings. If this is enabled and this is enabled by default the value you enter will be disregarded. "Use Project Frame Rate" is a new setting added in 2025.2.

      I will ping you once the fix is available.
      Cheers,
      Maxime.

      posted in Bugs
      M
      m_adam