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. mikeudin
    • Profile
    • Following 0
    • Followers 2
    • Topics 47
    • Posts 132
    • Best 24
    • Controversial 0
    • Groups 0

    mikeudin

    @mikeudin

    Checkout my python tutorials, plugins, scripts, xpresso presets and more
    https://mikeudin.net

    39
    Reputation
    357
    Profile views
    132
    Posts
    2
    Followers
    0
    Following
    Joined Last Online
    Website mikeudin.net Location Spain Age 44

    mikeudin Unfollow Follow

    Best posts made by mikeudin

    • Batch Processor: plugin for python scripts developers

      Hello folks!

      Let me introduce you my new plugin, which is good solution for those people who developing file handling scripts for Cinema 4D R19 and higher.

      The Batch Processor plugin allows to convert between all the 3D formats that are supported by Cinema 4D and supports User Scripts, including scripts with User Interface. Plugin installation contains several scripts that can be used as an example. Also plugin help contains all the necessary information about developing scripts with Batch Processor compatibility.

      Using the Batch Processor, the developer needs to write only code part for processing the document, the plugin takes care of the rest (opening-saving file,collecting, display and saving the script results log).

      Here is an example Demo Script:

      import c4d
      from c4d import gui
      
      '''
      Batch processor User Script Basic Example
      Please follow the code comments 
      https://mikeudin.net/
      
      
      To add User Scipt dialog make sure:
      1. Your dialog is based on gui.Subdialog class
      2. Class must have a name 'UserScriptDialog'
      3. Class must have a class variable 'user_script_container' to store all data on it
      4. Script must have 'main' function that will be executed by Batch Processor
      5. 'user_script_container' from dialog will be used as input argument for 'main' function
      
      '''
      
      class UserScriptDialog(gui.SubDialog):
          """
          A SubDialog to display the passed string, its used as example for the actual content of a Tab
          """
          
          STRING_FIELD = 2000
          INT_FIELD = 2001
      
          # define user_script_container as dictionary
          user_script_container = dict()
          
          def CreateLayout(self):
      
              # Add your dialog gui elements as descibed on Cinema 4D Python API
              # Please use methods which is compatible with Cinema 4D R19+ Python API
              
              bc = c4d.BaseContainer()
              bc.SetBool(c4d.QUICKTAB_BAR, True)  
              bc.SetString(c4d.QUICKTAB_BARTITLE, 'Script Options')
              self.AddCustomGui(1000, c4d.CUSTOMGUI_QUICKTAB, '', c4d.BFH_SCALEFIT, 0, 0, bc)
      
              if self.GroupBegin(1001,flags=c4d.BFH_SCALEFIT | c4d.BFV_TOP,cols=2,rows=1,title='Script Options'):
                  
                  self.GroupSpace(15, 6)
                  self.GroupBorderSpace(15,5,15,10)
      
                  self.AddStaticText(1002, c4d.BFH_LEFT, name='My String Data')
                  self.AddEditText(self.STRING_FIELD, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 10)
      
                  self.AddStaticText(1003, c4d.BFH_LEFT, name='My Integer Data')
                  self.AddEditNumberArrows(self.INT_FIELD, c4d.BFH_LEFT | c4d.BFV_SCALEFIT, 80, 10)
      
                  self.GroupEnd()
      
              return True
      
          def Command(self,id,msg):
      
              # Assign data to 'user_script_container' variable on any user gui interaction
              if id in {self.STRING_FIELD,self.INT_FIELD}:
                  self.user_script_container['int'] = self.GetInt32(self.INT_FIELD)
                  self.user_script_container['string'] = self.GetString(self.STRING_FIELD)
      
              return True
      
      # On execution 'user_script_container' will be used as input argument for 'main' function. 
      # if User Scipt do not contains dialog, 'main' function will be executed without arguments.
      
      def main(data):
          
          '''
          Batch Processor adds some global variables to User Script:
          
          doc - referenced to a processed document, type: c4d.BaseDocument
          doc_index - referenced to an document index in Jobs Queue, type: int
          docs_total - total number of documents in a Jobs Queue, type:int
      
          op - Active Object of processed document, type: c4d.BaseObject 
          mat - Active Material of processed document, type: c4d.Material
          tp - Particle System of processed document, type: c4d.modules.thinkingparticles.TP_MasterSystem
      
          '''
      
          # All data that needed to be printed will be passed to plugin Log tab
          print 'Processed Document Index {0} from {1}'.format(doc_index,docs_total) 
          print 'Document name: ', doc.GetDocumentName()
          print 'Document path: ', doc.GetDocumentPath()
          print 'Document Active Object is ', op
          
          print 'My String data', data['string']
          print 'My Integer data', data['int']
          
          if 3 < doc_index < 7:
              # If index of processed document have a number 4,5,6
              # in this case User Scipt will return error   
              raise Exception('Error!')
      
      

      Here is how it works:

      f873b137-b5f8-4c55-bf8f-fae9a3fc943b-image.png

      I hope the Batch Processor will be the solution that will help automate your work on processing a large number of files using the Cinema 4D Python API!

      posted in General Talk
      mikeudinM
      mikeudin
    • RE: MCOMMAND_JOIN issue

      You have to combine objects to null, for example:

      import c4d
      from c4d import gui
      
      def smc(listy):
          null = c4d.BaseObject(c4d.Onull)
      
          for o in listy:
              o.InsertUnder(null)
      
          res = c4d.utils.SendModelingCommand(command = c4d.MCOMMAND_JOIN,
                                          list = [null],
                                          mode = c4d.MODELINGCOMMANDMODE_ALL,
                                          bc = c4d.BaseContainer(),
                                          doc = doc)
          return res[0]
      
      def main():
          obs = doc.GetActiveObjects(0)
          doc.InsertObject(smc(obs))
          c4d.EventAdd()
      
      if __name__=='__main__':
          main()
      
      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • RE: Plugin OnFloor Final 1.2.4RC1

      How to use this tool with objects grouped in a single null?
      Not working with Figure primitive 🤔 :

      Traceback (most recent call last):
        File "C:\Users\user\AppData\Roaming\MAXON\Cinema 4D R20_4FA5020E\plugins\OnFloor_1.0.0\OnFloor\OnFloor.pypv", line 108, in MouseInput
      
        File "C:\Users\user\AppData\Roaming\MAXON\Cinema 4D R20_4FA5020E\plugins\OnFloor_1.0.0\OnFloor\OnFloor.pypv", line 47, in CenterAxe
            File "C:\Users\user\AppData\Roaming\MAXON\Cinema 4D R20_4FA5020E\plugins\OnFloor_1.0.0\OnFloor\OnFloor.pypv", line 24, in MoveAxe
          ValueError: Invalid object length.
      

      Just in case. Using my Target4D plugin you can drop your object to any surface 🙃
      alt text

      posted in General Talk
      mikeudinM
      mikeudin
    • RE: Dealing with Symbolcache

      May be there is unicode symbols problem. Try this

      f = open(fn.decode("utf-8"))

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • RE: Autocomplete successful but symbol IDs are unrecognized (on Pycharm)

      @bentraje You have to edit your
      "C:\Program Files\MAXON\Cinema 4D R20\resource\modules\python\libs\python27\c4d_init_.py"
      file by adding all symbol ID's as module variables.

      pycharm_example3.png

      Check out an example file, make sure you have a backup!🤞

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • Cinema 4D Script: Web Search Selected Text

      Hello guys! Hope you find it interesting.
      I've written little script which sends copied text to differents web pages for search.
      This script will be very helpfull to work with Cinema4D online SDK directly from Script Manager or Expression Editor.✌ 😎

      Download for free here.

      0_1552493953813_mikeudin_web_search_text.png

      posted in General Talk
      mikeudinM
      mikeudin
    • RE: Export selected objects to separate files

      @klints2
      Try to use IsolateObjects

      A helper routine to copy the objects of document to a new document (returned). All materials associated are also copied over and the links are corrected.

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • Send Python Code To C4D from any Texteditor

      Hello guys!
      I've created little solution to send python code to execute in Cinema 4D. Also it works for editing Pyton Generators, Effectors, Tags and Fields! Thanks for Remote Code Runner - Cinema 4D & Sublime Text plugin by NiklasRosenstein.

      pycharm_example.png

      Download SendPythonCodeToCinema4D

      posted in General Talk python
      mikeudinM
      mikeudin
    • RE: Python equivalent of the Xpresso node "Get nearest point on spline"?

      Hi @ops !
      Take a look to my version of @ferdinands solution. I was made some fixes to the code. Hope you find it usefull.
      find_close_point_on_spline.c4d

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • RE: TranslateDescID with FieldsList

      Hello @ferdinand! Thank you for quick response!
      Here you have sample ObjectData plugin based on this SDK example.

      Fieldlist ObjectData plugin is connected with VertexTag fieldlist by TranslateDescID. When adding Time field to Object plugin it freezes Cinema 4D. Tested on MB Air M1 MacOs 12.6.6

      Source
      fieldlist_translateid_bug.zip

      Demo
      fieldlist_bug.mov.zip

      posted in Bugs
      mikeudinM
      mikeudin

    Latest posts made by mikeudin

    • RE: 2025.0.0 SDK Release

      @ferdinand Cinema 4D 2025 requires at least macOS 13.6+ (Ventura), but Xcode 13.4 requires macOS Monterey 12 😲

      posted in News & Information
      mikeudinM
      mikeudin
    • RE: 2025.0.0 SDK Release

      What XCode version is required to compile plugins for v2025?

      posted in News & Information
      mikeudinM
      mikeudin
    • RE: Copy info from one Object to other Object

      @Manuel said in Copy info from one Object to other Object:

      This is a python bug; it works as expected when using c++.
      I will open a bug report and we will try to fix the issue as soon as possible.

      Still having this bug on 2024.4 🤔

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • RE: Python equivalent of the Xpresso node "Get nearest point on spline"?

      Hi @ops !
      Take a look to my version of @ferdinands solution. I was made some fixes to the code. Hope you find it usefull.
      find_close_point_on_spline.c4d

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • RE: 2024.4 update makes CheckDirty error for ObjectData plugin Fieldlist

      @ferdinand

      It would have been better if you have included line numbers in your stack trace, as without them I have to guess...
      

      Error messages going not in traceback format 🤔
      Here is a sample plugin with same issue.
      odatafieldsexample.zip
      CheckDirty.2024.4.bug.png

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • 2024.4 update makes CheckDirty error for ObjectData plugin Fieldlist

      Hello there!
      After updating to Cinema 4D 2024.4 my plugin causes this Exception:

      ReferenceError: the object 'c4d.modules.mograph.FieldLayer' is not alive
      The above exception was the direct cause of the following exception:
      SystemError: <function VTexterData.CheckDirty at 0x4b3546450> returned a result with an exception set
      

      It happens after adding some fieldlayer to the Field List. What is problem it can be?
      Here is my CheckDirty func:

      def get_field_layers(op):
          
          """ 
          Returns all field layers that are referenced in a field list.
          Source: https://plugincafe.maxon.net/topic/11809/iterating-trough-field-list/2?_=1678357010902
      
          """
          
          def flatten_tree(node):
              
              """ Listifies a GeListNode tree. """
              
              r = []
              while node:
      
                  r.append(node)
      
                  for child in node.GetChildren():
                      
                      r += flatten_tree(child)
                  
                  mask = node.GetMaskHead()
      
                  if mask:
                      for child in mask.GetChildren():
                          r += flatten_tree(child)
      
                  node = node.GetNext()
              
              return r
          
          # get the GeListHead for the FieldList
          root = op.GetLayersRoot()
          if root is None:
              return []
          # Get the first node under the GeListHead
          first = root.GetFirst()
          if first is None:
              return []
          
          # traverse the graph
          return flatten_tree(first)
             
      def CheckDirty(self, op, doc):
          
          fdirty = 0
          desc = op.GetDescription(c4d.DESCFLAGS_DESC_NONE)
          bc = desc.GetParameterI(c4d.VFTAG_TEXT_ANIMATOR_TRANSFORM, None)
          if not bc:
              return
      
          fenabled = [t[c4d.VFTAG_TEXT_ANIMATOR_ENABLE] for t in op.GetTags() if t.CheckType(c4d.Tvfanimatortag)]
          
          get_tvalue = lambda i: fenabled[i] if i < len(fenabled) else False #get correct value in case if tags count != axes count
      
          tfields = [op[c4d.VFTAG_TEXT_ANIMATOR_FIELDS + i] for i in range(len(bc[c4d.DESC_CYCLE])) if get_tvalue(i)]
          
      
          if not tfields:
              return 
      
          for f in tfields:
              if not f or not f.HasContent(): continue
              
              fdirty += f.GetDirty(doc)
              for l in get_field_layers(f):
                  
                  if not l.IsAlive(): continue
                  
                  if l.GetTypeName() in ('Time','Decay','Delay') and l.GetStrength() > 0.0:
                      fdirty += doc.GetTime().GetFrame(doc.GetFps())
                      continue
                  
                  fdirty += l.GetDirty(c4d.DIRTYFLAGS_ALL)
                  lobject = l.GetLinkedObject(doc)
                  if lobject:
                      fdirty += lobject.GetDirty(c4d.DIRTYFLAGS_MATRIX | c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_DESCRIPTION)
      
          fdirty += op.GetDirty(c4d.DIRTYFLAGS_MATRIX)
      
          if fdirty != self.lastFieldsDirty:
              
              self.lastFieldsDirty = fdirty
      
              op.SetDirty(c4d.DIRTYFLAGS_DATA)
      
      posted in Cinema 4D SDK python macos 2024
      mikeudinM
      mikeudin
    • RE: Memory Leak? How to fix loosing memory with python generator?

      @Dunhou You must use text shaping library to get glyphs outlines and convert it to bezier curves.

      posted in Cinema 4D SDK
      mikeudinM
      mikeudin
    • Memory Leak? How to fix loosing memory with python generator?

      Hello guys!
      I using this nice appoach to convert eps text data to spline using AI (Adobe Illustrator) importer. But it seems there is some memory leak because the amount of memory increases every time. How it can be fixed?
      Here is a test file. Thank you!
      gen_eps2.c4d

      posted in Cinema 4D SDK python macos 2024
      mikeudinM
      mikeudin
    • RE: How to use ctypes library with Object Plugin properly?

      @ferdinand Thank very much! i'll check what can i do. 🤔

      posted in General Talk
      mikeudinM
      mikeudin
    • How to use ctypes library with Object Plugin properly?

      Hello guys!
      I need to connect an C lang written lib to make some calculation during getting spline object. Here is a raw example with some details in a comments. Important part: cache created inside lib object. It must be existing during livetime of the Object and free before removing. What is best way to implement this approach? Thx!

      
      from ctypes import *
      class MyPluginData(c4d.plugins.ObjectData):
          
          """SomeObject Generator"""
      
          self.Init(node, isCloneInit):
              
              # It must be called once on object creation and can't be rewritten
              lib = CDLL('my_lib.so') #or dll on Windows
      
          self.Free(node):
          
              """ If your class has a destructor it is called as usual after this function. """
      
              # It must be called on system sleep, app close, object deletion etc.
              # to avoid memory leaks
      
              lib.cleanup()
      
          self.GetContour(op, doc, lod, bt):
      
              """ Here we using lib by calling some lib.foo() and lib.bar()"""
              # During the execution lib object creates some cache that must be cleaned up after object destruction
      
              data = lib.foo() 
      
              # process data
      
              return some_spline 
      
      posted in General Talk python macos windows r21 2024
      mikeudinM
      mikeudin