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
    • Recent
    • Tags
    • Users
    • Login

    Help with Tag Plugin

    Scheduled Pinned Locked Moved PYTHON Development
    10 Posts 0 Posters 740 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 11/08/2014 at 17:35, xxxxxxxx wrote:

      I have a script that runs a function for each object in a selection. It exports an XML with things like the name, position, ect.

      I want to make a plugin that has some user data (text boxes, floats, etc) and have my script pull the data from the plugin to later add to the XML. What's the best way of doing this?

      I can figure out how to pull data from an existing tag (a material, phong). I just need a custom tag that will store the custom data I need. If someone could post a sample code of a tag plugin to get me in the right direction, It would be greatly appreciated.

      Cheers,
      Joe

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 17/08/2014 at 09:48, xxxxxxxx wrote:

        You wouldn't necessarily have to write a plugin but rather a python tag will work just fine. You can then use python to write/read directly to an XML file or write the data to a multi-line string where you can then access it easily with XPresso or python.

        Hope this helps,

        Shawn

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 21/08/2014 at 11:01, xxxxxxxx wrote:

          Thats for the input. I think for the sake of being user friendly, we would want a custom tag. That way we can have custom user data that is assignable and able to be read. Just having a problem actually making the tag structure... Thanks

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 21/08/2014 at 11:11, xxxxxxxx wrote:

            If you just want a tag plugin to see how to make one. I have a bunch of Python and C++ tag examples on my site: https://sites.google.com/site/scottayersmedia/plugins

            -ScottA

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 21/08/2014 at 12:50, xxxxxxxx wrote:

              Hello,

              the structure of a python tag plugin is pretty much like the structure of any other plugin.

              First you have the actual python plugin source file:

              import os  
              import math  
                
              import c4d  
              from c4d import plugins, bitmaps, utils  
                
                
              class ExamplePythonTag(plugins.TagData) :  
                 
                  
                def Init(self, node) :  
                    # init your plugin here  
                    return True  
                  
                def Execute(self, tag, doc, op, bt, priority, flags) :  
                    # execute the plugin here  
                    return c4d.EXECUTIONRESULT_OK  
                
                  
                
              if __name__=='__main__':  
                plugins.RegisterTagPlugin(id=1027090, str="Example Tag",info=c4d.TAG_EXPRESSION|c4d.TAG_VISIBLE, g=ExamplePythonTag, description="Tpythontag", icon=bitmaps.BaseBitmap())
              

              What you also need is three other files. First the description resource "Tpythontag.res" in the res\description folder. The resource file let's you define the (fixed) parameters of your plugin:

              CONTAINER Tpythontag  
              {  
                NAME Tpythontag;  
                  
                // add your parameters here  
                
              }  
              

              Beside the resource file you have to add a "Tpythontag.h" that defines the IDs for each parameter within a enumeration:

              #ifndef _Tpythontag_H_  
              #define _Tpythontag_H_  
                
              enum  
              {  
                // add your parameters here  
              }  
                
              #endif  
              

              Finally you need to define your string. This is done in the "Tpythontag.str" file in res\strings_us\description:

              STRINGTABLE Tpythontag  
              {  
                Tpythontag    "Example Python Tag";  
                
                  
              }  
              

              Every plugin also needs a "c4d_symbols.h" in the res folder. There you can define IDs for global strings. These strings can be defined in "c4d_strings.str" in the "strings_us" folder.

              You find an overview over python plugin structure[URL-REMOVED] in the SDK, where you also find an example tag plugin[URL-REMOVED].

              Best wishes,
              Sebastian


              [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 25/08/2014 at 19:59, xxxxxxxx wrote:

                This will get me in the right direction. Thanks for the help.

                Also, would there be any way to avoid all the extra files and include the parameters in the pyp file? If not all then at least some of it? Like the ID's?

                Thanks,
                Joe

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 27/08/2014 at 12:25, xxxxxxxx wrote:

                  Hello,

                  To my knowledge it is currently not possible edit the description of a plugin via Python. The *.res and *.h files are needed to inform Cinema about the parameters so it can handle them

                  best wishes,
                  Sebastian

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 27/08/2014 at 15:43, xxxxxxxx wrote:

                    Got it.. One more thing. Is there documentation on making the .res file? I don't want some values to be animatable...

                    Thanks

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      On 28/08/2014 at 12:43, xxxxxxxx wrote:

                      Hello,

                      you can find the full documentation on description resources[URL-REMOVED] in the C++ SDK. To mark a parameter as not animateable simply use ANIM OFF[URL-REMOVED]:

                        
                      CONTAINER Tpythontag  
                      {  
                       NAME Tpythontag;  
                       INCLUDE Texpression;  
                         
                        GROUP ID_TAGPROPERTIES  
                        {  
                            REAL P_X {ANIM OFF;}  
                        }  
                      }  
                      

                      best wishes,
                      Sebastian


                      [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        On 09/09/2014 at 22:35, xxxxxxxx wrote:

                        On top of that shone some sort of light in weight are not chapters your a tale.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post