transfering py-Script to Plugin



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/10/2012 at 13:36, xxxxxxxx wrote:

    Hi all,

    can anybody tell me how to transfer a script to a plugin?
    The script works fine.
    I have coppyed all the examples form the SDK to the pluginfolder

    I've red in the sdk...
    I've red in the forum...
    It could not be so difficult...

    I only need the first step till I can use callcommand

    Thanks a lot



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 02:34, xxxxxxxx wrote:

    Hi,

    What you need is to develop a CommandData plugin, the easiest plugin type.
    Copy the code from this post: https://plugincafe.maxon.net/topic/6663/7259_shortcut-for-commanddata-is-not-working
    Get a unique plugin ID (value for PLUGIN_ID) at this page: http://www.plugincafe.com/forum/developer.asp
    Then in the Execute() function put your script's code.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 13:22, xxxxxxxx wrote:

    You are my hero!!!
    Realy.

    Thanks a lot.

    But one question:
    Wy can't Maxon post such a little, easy thing in there SDK??
    There is so much, but for a beginner nothing.

    Thanks a lot again



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 14:47, xxxxxxxx wrote:

    I'm struggeling again!

    Why does this not work???
    I only try to proceed several commands afer another?

    Here is the code:
    ---------------------------
    """
    Modified Date: 18/10/2012
    """

    import c4d
    import math
    import os

    from c4d import documents, plugins, bitmaps
    #Welcome to the world of Python

    PLUGIN_ID = 1234588880

    class MYPLUGIN(plugins.CommandData) :

    pass

    def Execute(self, doc) :
               c4d.CallCommand(5159)                                # Würfel
            c4d.CallCommand(12305)                      # Konsole...    
               c4d.CallCommand(13957)                      # Konsole löschen

    if __name__ == "__main__":
         # load icon.tif from res into bmp
         bmp = bitmaps.BaseBitmap()
         dir, file = os.path.split(__file__)
         fn = os.path.join(dir, "res", "icon.tif")
         bmp.InitWith(fn)
         # register the plugin
         okyn = plugins.RegisterCommandPlugin(id=PLUGIN_ID, str="V4D-Power-Reducer", info=c4d.PLUGINFLAG_COMMAND_HOTKEY, icon=bmp, help="", dat=MYPLUGIN())

    print "V4D-Power-Reducer ", okyn

    --------------------

    Is there any documentation "step by step" to learn how programming with phyton works??
    Thanks a lot for every hint



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 19/10/2012 at 15:20, xxxxxxxx wrote:

    Step one, -always- use a unique plugin ID that you get from Plugin cafe (link in Yannicks' post)
    Never, ever use a random or someone elses' ID or you are likely to cause corruption.
    You need a separate Plugin ID for every and each plugin you make.

    Python programming per se, is not Cinema specific and there are litterer tons of info
    how to on the web.

    Then I must agree, the first basic hurdles how to set up basic "default" plugin types
    is sorely missing in the SDK. It -is- the biggest problem to get started not having any of that.
    Sebastian, remember a couple of years ago the suggestion to set up this with the different
    types of Faders, buttons, link fields in a default fashion? What happened ? :)

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 20/10/2012 at 04:46, xxxxxxxx wrote:

    Hi Lenard,

    my problem is not the solution of my problem in CINEMA.
    The script recorder is a very easy tool tho find the commands.

    My problems are like this:
    Must commands stand every row exactly under the last row
    Do i have to use 4 or 5 blanks in the struckture
    Why do i always get

    "    def Execute(self, doc) :"
    "IndentationError: unexpected indent"

    My scritp works very well in Cimena als a py-Script.
    What is to be done to change it to an Plugin?
    I found a nice Video in Vimao about the struckture of a plugin.
    But ther is nothing said about:
    Where do i have place my def Funktion()...

    Is there anybody out there who kmows a Book or totorial?
    Is there anybody out there who could help me (I pay the translation)

    Thanks to all

    And: Sory for my horrible englisch



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 20/10/2012 at 10:08, xxxxxxxx wrote:

    Yes, indents are paramount in py as they are used insted of brackets found in other coding types.
    One usually use either a Tab step or four spaces. It is not recommended to mix what to use.
    Either Tab or 4 spaces.
    Check in your text application.

    Any function of yours are normally placed before the Execute()

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/10/2012 at 00:02, xxxxxxxx wrote:

    Thanks to Lennard

    I learn so much this weekend.
    M fault was that I used spaces and tabs mixed

    But now there is a new problem:
    I tryed to define a funktion.
    (Funtions have to be placed before the execute. wright?)

    But nothing happens when the plugin is executet.
    Can somebody give me a smal advice! Please
    Here is my code
    Thanks to all

    """
    V4D-Power-Reducer
    Copyright: VISION 4D
    Written for CINEMA 4D R14

    Modified Date: 18/10/2012
    """

    import c4d
    import math
    import os

    from c4d import documents, plugins, bitmaps
    #Welcome to the world of Python

    PLUGIN_ID = 1029229

    class MYPLUGIN(plugins.CommandData) :
        #pass

    def Execute(self, doc) :
        
            def Test(self) :
                print 'test'
                return True
        
        
            print 'Hello'
            print 'Hello again'
            Test
            #Check_serialinfo
            c4d.CallCommand(5159) # Würfel
            return True

    if __name__ == "__main__":
        # load icon.tif from res into bmp
        bmp = bitmaps.BaseBitmap()
        dir, file = os.path.split(__file__)
        fn = os.path.join(dir, "res", "icon.tif")
        bmp.InitWith(fn)
        # register the plugin
        okyn = plugins.RegisterCommandPlugin(id=PLUGIN_ID, str="V4D-Power-Reducer", info=c4d.PLUGINFLAG_COMMAND_HOTKEY, icon=bmp, help="", dat=MYPLUGIN())
        c4d.CallCommand(13957)                                    # Konsole löschen
        print " "
        print "----------------------------------"
        print "V4D-Power-Reducer ", okyn
        print "----------------------------------"



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 22/10/2012 at 01:10, xxxxxxxx wrote:

    Hi,

    It's not good practice to declare a method inside another; you should declare Test() outside of Execute(). If you only write 'Test' it will not be called, Test is just the method variable. So to call it don't forget '()'. And as it's a class method (Test( self )) self has to be added before:

    self.Test()
    

    I think you should read one of the Python tutorials or books linked in the CINEMA Python SDK documentation (see Meta information: Internet Resources at the bottom of the Index page).


Log in to reply