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

    How to just open a certain window instead of toggling

    Cinema 4D SDK
    python
    2
    3
    433
    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.
    • K
      kng_ito
      last edited by

      Hi,

      I want to write a script that opens a certain window when executed, but when I use CallCommand(), it closes the window that is already open.
      Is there any way to open that window when it is not open and do nothing when it is already open?

      Any help would be greatly appreciated.

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

        Hello @kng_ito,

        Thank you for reaching out to us. You have deleted this topic, which likely means that you found the solution yourself. This question has been answered before and you likely found one of these answers, but I think it does not hurt to answer this again, especially since I already wrote the answer and then sat in a never ending meeting 🙂 In general, we also prefer topics not to be deleted, but rather have them pointing to the correct solution, so that future readers will find solutions over multiple search entries.

        Answer

        This can be solved in this specific case with c4d.IsCommandChecked. I have provided an example at the end of the posting. A related subject is GeDialog folding and opening for dialogs a user has implemented; an example for that can be found here.

        Cheers,
        Ferdinand

        """Example for opening the Material Manger.
        
        Run this script as a Script Manger script, it will only open the Material Manager, but not close
        it by executing the command twice.
        
        Using c4d.IsCommandChecked allows to execute commands only when they indicate to not already be 
        running. In the case of commands which open some form of dialog, this means that the command is
        only executed when the dialog is not already open. This requires the CommandData plugin hook to
        implement CommandData.GetState() to return its state.
        """
        
        import c4d
        
        IDM_MATERIAL_MANAGER: int = 12159
        
        def main() -> None:
            # When the Material Manager command indicates not to be already running, invoke its command.
            if not c4d.IsCommandChecked(IDM_MATERIAL_MANAGER):
                c4d.CallCommand(IDM_MATERIAL_MANAGER)
            
            
        if __name__ == '__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • K
          kng_ito
          last edited by

          Hi @ferdinand,

          I deleted my original post because I realized the question contained my misunderstanding.
          And now your answer has completely solved the problem I had.

          Thank you very much for your detailed response!

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