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

    Default Object: How to apply those defaults?

    Cinema 4D SDK
    c++ r20 r21 s22 r23
    2
    11
    1.0k
    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.
    • fwilleke80F
      fwilleke80
      last edited by fwilleke80

      Follow-up: The behavior is the same when using the FieldList of any Effector. Adding a Field from the FieldList does not add the default object that the user has set.

      So I guess it's nothing we can change. Or is there a way to load those default settings from somewhere and apply them? There must be, as the code that adds objects from the Create or the plugin's menu obviously does it 😉

      www.frankwilleke.de
      Only asking personal code questions here.

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hi,

        sorry for the delay, the default properties are stored in the Browser. you can retrieve them with GetDefaultObject. You will find more information on that page

        BaseObject* myDefaultObject = static_cast<BaseObject*>(SDKBrowser::GetDefaultObject(Opyramid));
        	if (myDefaultObject == nullptr)
        		myDefaultObject = BaseObject::Alloc(Opyramid);
        
        	if (myDefaultObject == nullptr)
        		return maxon::NullptrError(MAXON_SOURCE_LOCATION);
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • fwilleke80F
          fwilleke80
          last edited by fwilleke80

          Hi,

          oops, sorry, didn't see your reply earlier (I never get notification emails).

          Thank you very much, that should be the solution at least for the objects I create in my code 🙂

          However, I guess, there is no way to use the default object for Fields created by the FieldList customgui, right?

          Cheers,
          Frank

          www.frankwilleke.de
          Only asking personal code questions here.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            @fwilleke80 said in Default Object: How to apply those defaults?:

            However, I guess, there is no way to use the default object for Fields created by the FieldList customgui, right?

            I don't think so. But what's strange is that it does create your default field if you use the palette (icon on top).
            We could maybe consider that as a bug.
            I need to check the code to see why there's such a difference between the palette and the customGUI.

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            fwilleke80F 1 Reply Last reply Reply Quote 0
            • fwilleke80F
              fwilleke80
              last edited by

              Good to know, thank you for looking into it!

              Cheers,
              Frank

              www.frankwilleke.de
              Only asking personal code questions here.

              1 Reply Last reply Reply Quote 0
              • fwilleke80F
                fwilleke80 @Manuel
                last edited by fwilleke80

                @m_magalhaes said in Default Object: How to apply those defaults?:

                I don't think so. But what's strange is that it does create your default field if you use the palette (icon on top).
                We could maybe consider that as a bug.
                I need to check the code to see why there's such a difference between the palette and the customGUI.

                I guess, that's because menus and palettes create the objects using menu item resource IDs like PLUGIN_CMD_440000266 (e.g. in /resource/c4dplugin/menus/c4d_m_editor.res), which I guess was a quick solution back when it was coded. It's a kind of CommandData that creates the objects, apparently invoking SDKBrowser::GetDefaultObject(). This has probably just been forgotten in the FieldListCustomGui.

                I wonder if there's a way to call that 'secret' CommandData from a plugin.

                Cheers,
                Frank

                www.frankwilleke.de
                Only asking personal code questions here.

                1 Reply Last reply Reply Quote 0
                • ManuelM
                  Manuel
                  last edited by

                  hi,

                  those commands are created whenever you register a plugin/tools etc.

                  after having a look at it, i confirm it's a bug, the object is allocated without checking for the content browser.

                  if it's in your objectData, you could maybe listen to the message MSG_DOCUMENTINFO_TYPE_OBJECT_INSERT, check if it's a field object and check if it's the default one or the browser one. Than replace according to what you want.
                  I didn't tested it myself but it could work.

                  But that's maybe too mush work for a "detail"

                  Cheers,
                  Manuel

                  MAXON SDK Specialist

                  MAXON Registered Developer

                  1 Reply Last reply Reply Quote 0
                  • fwilleke80F
                    fwilleke80
                    last edited by

                    Oh, that is actually a good idea, thank you!
                    I'll try that!

                    Cheers,
                    Frank

                    www.frankwilleke.de
                    Only asking personal code questions here.

                    1 Reply Last reply Reply Quote 0
                    • fwilleke80F
                      fwilleke80
                      last edited by fwilleke80

                      @m_magalhaes said in Default Object: How to apply those defaults?:

                      MSG_DOCUMENTINFO_TYPE_OBJECT_INSERT

                      Sadly, it seems that MSG_DOCUMENTINFO is not sent when adding a Field via the FieldList CustomGui. I had been hoping that message would be triggered by BaseDocument::InsertObject() and GeListNode::InsertUnder() (and related functions).
                      I guess, we have to do without default objects in this case 😕

                      Cheers,
                      Frank

                      www.frankwilleke.de
                      Only asking personal code questions here.

                      1 Reply Last reply Reply Quote 0
                      • ManuelM
                        Manuel
                        last edited by

                        well sorry for the misleading.
                        I was thinking it should work because the object is inserted with doc->InsertObject

                        Cheers,
                        Manuel

                        MAXON SDK Specialist

                        MAXON Registered Developer

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