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

    General Question: Which Plugin Type? -> Curvature Comb / Plot

    Cinema 4D SDK
    python
    2
    6
    672
    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.
    • M
      mogh
      last edited by

      Dear Developers,

      I am starting to build a new Plugin, which should in the end, draw Curvature Combs / plots onto the selected edges / splines, preferable real time on editing the splines/models.

      My question is which Plugintype would be best suited ?
      Comb

      Thinking out loud:
      I was thinking a Tag Plugin but It could be to restricted as per the Tag plugin has some programing limits as I understand. Command or Tool plugin could work but I fear it will be clunky from a user experience.
      At best a Polygon model with Hypernurbs applied should display several combs at the same time using the Hypernurbs Subdivision for more "accuracy" than a pure Polygon edge.

      The plugin probably needs a Link Box to "receive" a selection. I am thinking of Ferdinands Dynamyc Link Example would be cool to have more than on comb active but only one "Tag / Plugin / ...." per object ...

      Closest thing C4D has is measure and construct Tool.
      As a starting point I would start to display Combs on Splines ...

      So to Pick the hive mind - > What Plugin Type is best suited for stuff like this?

      Moderators: feel free to move this Topic if aplicable.

      Cheers
      mogh

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @mogh
        last edited by ferdinand

        Hey @mogh,

        Thank you for reaching out to us. The answer depends a bit on the context, and I could write here an essay but I will try to keep it short. Feel free to ask follow-up questions.

        In principle, there are two meaningful ways to do this:

        • Tool: All variants of tool hooks can draw into viewports, e.g., a ToolData hook in Python. The issue with this is that this would be then a tool, i.e., you could not have it enabled in parallel to the move tool. The advantage is that this is exposed in Python and relatively little work.
        • Scene Hook: Scene hooks are the native way to implement nodes which are present exactly once in every scene. They are 'spiders in the net' present in each scene, and can draw, listen to keyboard and mouse inputs, and much more. The issue is here that SceneHookData is not wrapped for Python. In our morning meeting we decided that we will change that in an upcoming version of the Python API, but it is not yet decided if we will include drawing for scene hooks, as the non-implementation of SceneHookData was born out of performance concerns (which are not very practical IMHO).

        A CommandData and GeDialog combo will not work, because while you can retrieve the BaseDraw instances of a document at any time, you need the context of a drawing method for your drawing instructions to be actually registered (otherwise the viewport will just ignore your calls). And neither command nor dialogs have these methods.

        In Python you can sort of emulate a scene hook with an MessageData and ObjectData combo, the message hook scans for new scenes being opened, and then inserts the object as a hidden node. The object could then do the drawing. Via MSG_DOCUMENTINFO the object could then remove itself shortly before the document is being saved. You could also do something similar with a CommandData and TagData combo, i.e., a toggle command which enables or disables "comb drawing" on an object by placing a hidden tag on it.

        What to chose depends on your project details. Scene hooks are the cleanest option. When a tool somehow makes sense, I would go for that. The MessageData + ObjectData combo is very messy, but could technically draw on all objects at once. TheCommandData option would be more meant for drawing on objects one by one. But both of these latter options are not ideal and will require an experienced developer to make them smooth.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • M
          mogh
          last edited by

          Thanks @ferdinand for your considered reply,

          At this stage because I just want to "make stuff" I will start as a tool and perhaps learn / have an idea to transfer it to something more useful.

          The obvious simple minded question - why is a tag Plugin not enough can a tag not draw into viewport ? Or only not via Python?

          Thanks
          mogh

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            Hey,

            A tag can draw into a viewport 🙂 My line of thinking was that you want some form of automatism/ streamlined product. E.g., an "enable/disable comb drawing" button (CommandData) and then a node (TagData/ObjectData) actually implementing it. When you just want to have the ability to manually enhance a spline with some drawing decorations, a tag would be a very good choice.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 1
            • ferdinandF
              ferdinand
              last edited by

              When this is what you want, a Python Programming Tag has also a draw function, i.e., the scripting element inside Cinema 4D. Scripting elements make great prototypes for their full grown plugin counter part (for the Python tag that would be TagData) but can also be very potent on their own while providing phenomenally rapid development speed.

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • M
                mogh
                last edited by

                curvature_comb.png

                not bad for 5 hours of dabbling --- thanks to you @ferdinand

                Gotcha's:
                The Curvature was 90dgree rotated - LLM to the rescue ...

                # c4d.plugins.RegisterTagPlugin( ....
                # That one nearly got me ;-)
                # c4d.TAG_IMPLEMENTS_DRAW_FUNCTION # R22 
                

                cheers

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