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

    Inherit Default Object Creation Behavior in the Palette?

    Cinema 4D SDK
    r21 python
    2
    9
    957
    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.
    • B
      bentraje
      last edited by

      Hi,

      Is there a way I can inherit the default object creation behavior in the palette?
      For instance, if you have the primitives in the separate pallet,
      holding Alt + LMB the Cube Icon makes the selected object the child of the new cube.
      or holding Shift + LMB the Cube Icon makes the selected object the parent of the new cube.

      Currently, what I have in my plug-in is a clickable icon that creates a cube but doesn't take into account the Alt/Shift behaviors.

      So, is it possible to inherit the default object creation behavior to the plug-in form?

      Thank you for looking at my problem.

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        the C++ API has the function InsertCreateObject() which can be used to insert an object into a document using the modifiers.

        Apparently, this function is not available in the Python API.

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • B
          bentraje
          last edited by

          @s_bach

          Thanks for the confirmation. So I guess, I should use the key modifiers manually.
          Just wondering, is there a better way to implement this?

          This is a working code but just wondering if there is a better way of doing this:

              def Command(self, id, msg):
          
                 # 2000 is the button ID
          
                  bc = c4d.BaseContainer()
                  shift = False
                  ctrl = False
                  alt = False
          
                  if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD,c4d.BFM_INPUT_CHANNEL,bc):
                      if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QSHIFT:
                          shift = True
                      if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QCTRL:
                          ctrl = True
                      if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QALT:
                          alt = True
                  
                  if id==2000 and shift == False and alt == False:
                      print "Create Cube"
          
                  if id==2000 and shift==True:
                      print "Create Cube and make it a child of the selected object"
          
                  if id==2000 and alt==True:
                      print "Create Cube and make it a parent of the selected object"
          
                  return True
          

          Thank you for looking at my problem.

          1 Reply Last reply Reply Quote 0
          • S
            s_bach
            last edited by

            Hello,

            typically, c4d.gui.GetInputState() is used to check a specific key e.g.

            state = c4d.BaseContainer()
            res = c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.KEY_ENTER, state)
            

            But if your code works for you, I guess its fine.

            best wishes,
            Sebastian

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • B
              bentraje
              last edited by

              @s_bach

              Thanks for the response, but I'm confused when you said:
              typically, c4d.gui.GetInputState() is used to check a specific key e.g.

              Correct me if I'm wrong but I'm already using c4d.gui.GetInputState() above.

              To rephrase the just wondering if there is a better way of doing this: question. I guess, is there a way I can shorten the code? The reason is the whole plugin will have many commands with modifier keys.

              1 Reply Last reply Reply Quote 0
              • S
                s_bach
                last edited by

                @bentraje said in Inherit Default Object Creation Behavior in the Palette?:

                The reason is the whole plugin will have many commands with modifier keys.

                Hello,

                as a I said, c4d.gui.GetInputState() is typically used to check a specific key e.g. the "Enter" key. The qualifier keys are pressed along with this tested key or not.

                If you want to reuse your code, you can simply put it in a sub-function that returns a list or a dictionary that describes the current state of the qualifier keys.

                best wishes,
                Sebastian

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • B
                  bentraje
                  last edited by

                  Hi @s_bach

                  RE: as a I said, c4d.gui.GetInputState()
                  Correct me if I'm wrong but I guess you are trying to distinguish the specific keys and the qualifier keys. In my post above, I didn't know the distinction so I just treat all the keyboard keys as both the specific keys and qualifier keyys.

                  Can I clarify, if the c4d.gui.GetInputState() is preferred for the specific keys.
                  What command should I use for the qualifier keys?

                  1 Reply Last reply Reply Quote 0
                  • S
                    s_bach
                    last edited by

                    Hello,

                    I don't think there is a specific command to check for qualifier keys. By themselves, these keys typically don't do anything; so what is typically checked is if another key is pressed and a modifier key is pressed along that key.

                    best wishes,
                    Sebastian

                    MAXON SDK Specialist

                    Development Blog, MAXON Registered Developer

                    1 Reply Last reply Reply Quote 1
                    • B
                      bentraje
                      last edited by

                      @s_bach

                      Thanks for the clarification

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