Navigation

    • Register
    • Login
        No matches found
    • Search
    1. Home
    2. mikeudin
    mikeudin

    mikeudin

    @mikeudin

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

    37
    Reputation
    91
    Posts
    337
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online
    Website mikeudin.net Location Spain Age 41

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    mikeudin 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 •
    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 •
    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 •
    RE: Dealing with Symbolcache

    May be there is unicode symbols problem. Try this

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

    posted in Cinema 4D SDK •
    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 •
    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 •
    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 •
    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 •
    RE: C++ Plugin Development Tutorials

    @kbar Thank you! Great job!

    posted in Maxon Announcements •
    RE: Developing .obj sequence exporter for selected objects

    May be Polygonize can help you.

    Make a clone of the document and turn all objects into polygon based objects.

    posted in Cinema 4D SDK •

    Latest posts made by mikeudin

    RE: CommandData plugin catch Switching documents event

    @ferdinand Thank you!

    posted in Cinema 4D SDK •
    CommandData plugin catch Switching documents event

    Hello everyone!
    I trying to use this code from here to catch switching documents event with CommandData plugin Dialog.

    def Message(self, type, data):
            
            if type == c4d.MSG_DOCUMENTINFO:
                if data['type'] == c4d.MSG_DOCUMENTINFO_TYPE_LOAD:
                    print ("Document holding object was set active")
                    return True
            
            return True
    

    But it's seems is not working in this case. Is it possible to know when user changes active document in case of CommandData plugin?
    Thank you!

    posted in Cinema 4D SDK •
    RE: How to make a Python Plugin...

    @noseman seems that it's needs to be updated
    https://github.com/nrosenstein-c4d/c4d-prototype-converter/issues/52

    posted in Cinema 4D SDK •
    RE: How to know is DescID is "takeble"?

    @m_magalhaes Thank you!

    posted in Cinema 4D SDK •
    How to know is DescID is "takeble"?

    Hello guys!
    There is way to know possibility to create take for DescID?
    Something like a DESC_ANIMATE parameter with values DESC_ANIMATE_OFF, DESC_ANIMATE_ON, DESC_ANIMATE_MIX.

    posted in Cinema 4D SDK •
    RE: How to make a Python Plugin...

    Thank you @noseman!

    @noseman said in How to make a Python Plugin...:

    convert Scripts to Plugins

    There is a nice solution to make it easy
    https://plugincafe.maxon.net/topic/10699/14153_c4d-prototype-to-plugin-converter

    Also a lot of Cinema 4D plugins examples for different cases are presented here
    https://github.com/PluginCafe/cinema4d_py_sdk_extended/tree/master/plugins

    posted in Cinema 4D SDK •
    RE: How to open Script Manager and set what Script it is showing?

    @kbar I think much better to create your own Edit Script dialog with blackjack and... Save and Execute Buttons. Use GeDialog.AddMultiLineEditText with a flags DR_MULTILINE_SYNTAXCOLOR and DR_MULTILINE_PYTHON.

    posted in Cinema 4D SDK •
    How to get/set single vector value from USERDATA

    Hello!
    After dragging to console there is no way to get single value from vector UserData parameter.

    >>> Cube[c4d.ID_USERDATA,2,c4d.VECTOR_Z]
    Vector(0, 0, 0)
    >>> Cube[c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X]
    52.0
    

    Screenshot 2022-05-17 at 22.30.10.png

    And no way to set this single value:

    >>> Cube[c4d.ID_USERDATA,2,c4d.VECTOR_Z] = 12
    Traceback (most recent call last):
      File "console", line 1, in <module>
    TypeError: __setitem__ expected c4d.Vector, not int
    

    There is a soution without creating a new c4d.Vector() variable? 🤔 I need to get dragged to plugin dialog c4d.DRAGTYPE_DESCID from one single vector UserData parameter.
    Thank you!

    posted in Cinema 4D SDK •
    RE: StringToNumber to BaseTime

    Great, thank you guys!

    posted in Cinema 4D SDK •
    StringToNumber to BaseTime

    Hi guys!
    Is it possible to convert string value to BaseTime with this function?

    Converts a string to a data value of type float, int or c4d.BaseTime.

    >>> c4d.utils.StringToNumber('11', c4d.FORMAT_FRAMES, doc.GetFps())
    11.0
    >>> c4d.utils.StringToNumber('11', c4d.FORMAT_SECONDS, doc.GetFps())
    11.0
    >>> c4d.utils.StringToNumber(11, c4d.FORMAT_FRAMES, doc.GetFps())
    11.0
    

    After some tests i had no luck with it.😬🤷‍♂️

    >>> doc[c4d.DOCUMENT_MINTIME] = c4d.utils.StringToNumber('11', c4d.FORMAT_FRAMES, doc.GetFps())
    Traceback (most recent call last):
      File "console", line 1, in <module>
    TypeError: __setitem__ expected c4d.BaseTime, not float
    >>> 
    

    Thank you!

    posted in Cinema 4D SDK •