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

    How to Execute Tools?

    Scheduled Pinned Locked Moved PYTHON Development
    10 Posts 0 Posters 906 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 04/04/2012 at 23:43, xxxxxxxx wrote:

      I'm having all kinds of trouble trying to figure out the proper syntax to execute tools.
      Not just the buttons. But even the attributes don't work as expected.

      Specifically. I'd like to change the things in the character weights manager.
      Example:  tool()[c4d.ID_CA_WEIGHT_TOOL_SHOWALL]=False  #<-----tool is not defined!!!

      And I would also like to execute the various buttons in the manager.
      Example:c4d.CallButton(tool(), ID_CA_WEIGHT_TOOL_FN_CLEARWEIGHT)   #<----This is wrong!!!

      Even the script log in R13 produces code that does not work.
      It says "tool" is not defined.
      What's the secret to getting at these things?

      -ScottA

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 05/04/2012 at 03:36, xxxxxxxx wrote:

        eh,

        not sure what you want to do exactly, but your syntax looks somehow odd to me. what is tool() 
        and where is it definied ? why aren't you just grabing the respective ids ?

        WeightTool[c4d.ID_CA_WEIGHT_TOOL_DISPLAY_POINTS]=1

        for example works pretty well for me. i guess i am getting something wrong here.

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 05/04/2012 at 04:07, xxxxxxxx wrote:

          The SkriptLog is missing that one:

          def main() :  
            # ...  
            def tool() :  
                return doc.GetActiveToolData()
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 05/04/2012 at 08:29, xxxxxxxx wrote:

            Thanks guys.
            But neither of these methods are working for me.
            Strange that it's working for you.

            What's really strange is the weight manager won't respond at all for me. Not even the checkbox's.
            But if I try the same code on something else. Like the NameTool. It does work.
            Except for the CallButton() code part.

            Example:

            import c4d  
            from c4d import *  
              
            def main() :  
              
              c4d.CallCommand(1019952);                             #Activate the Naming Tool  
              
              tool = doc.GetActiveToolData()  
              tool[ID_CA_JOINT_NAMING_REPLACE] = "Cube"               #Works Fine  
              tool[ID_CA_JOINT_NAMING_REPLACE_WITH]= "fdsdf"          #Works Fine  
              c4d.CallButton(tool(), ID_CA_JOINT_NAMING_REPLACE_APPLY)  #Error-->BaseContiner object is not callable  
              c4d.EventAdd()  
            if __name__=='__main__':  
              main()
            

            -ScottA

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 05/04/2012 at 08:58, xxxxxxxx wrote:

              hum,

              not sure if this helps (or is correct 😂 ) , but :

              1. c4d.CallButton(tool(), ID_CA_JOINT_NAMING_REPLACE_APPLY), you treat tool like a method,
              but it isn't a method, but a BaseContainer variable.

              2. CallButton() expects as first argument a BaseList2D, but you pass tool, which is a BaseContainer.
              allthough they sound similiar, there is no inheritance relationship between them.

              edit : after taking a quick look at the inheritance diagram for plugins, i'm not sure anymore if this
              is even possible, as tooldata is not a member of BaseList2D.

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 05/04/2012 at 09:08, xxxxxxxx wrote:

                I've tried all kinds of variations to get that CallButton() code to work. And I cannot figure it out.
                Here's an example of executing a Tag's button using CallButton() code:

                import c4d  
                  
                def main() :  
                  obj = doc.GetActiveObject()  
                  if obj is None: return False  
                  
                  tags = obj.GetTags()  
                  for tag in tags:  
                      if tag.GetType() == c4d.Tpolygonselection:               #A PolygonSelection Tag  
                          tag.SetBit(c4d.BIT_ACTIVE)  
                          c4d.CallButton(tag,c4d.POLYGONSELECTIONTAG_COMMAND1) #Execute the Restore Selection button  
                  
                  c4d.EventAdd()  
                  
                if __name__=='__main__':  
                  main()
                

                I know how to write CallButton() with using Tags & Objects.
                But I cannot figure out how to do it with tools.

                On a positive note. I figured out why my weight manager code wasn't working.
                I must have BOTH the weights manager open...And... The weight brush open at the same time. In order to execute the options in the Weight Manager pallet.
                Example:

                import c4d  
                def main() :  
                  c4d.CallCommand(1019499) # Weight Tool  
                  c4d.CallCommand(1025028) # Weights Manager...  
                  tool = doc.GetActiveToolData()  
                  tool[c4d.ID_CA_WEIGHT_TOOL_WEIGHTS_SELECTION] = 1  
                  
                  c4d.EventAdd()  
                  
                if __name__=='__main__':  
                  main()
                

                It took me a full day to figure that one out.😠

                I'm still stuck on using CallButton() for tools though.😢

                -ScottA

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 05/04/2012 at 13:44, xxxxxxxx wrote:

                  Got it!
                  Once again...I've been running in circles trying to do something. Only to find out that it's not supported in R12! 😠

                  After much head banging and swearing. Here's an R13 example of changing some attributes in the naming tool. And then executing the CallButton() function:

                  import c4d  
                  from c4d import gui  
                    
                  def main() :  
                    
                    c4d.CallCommand(1019952)                                    #Launches the naming tool  
                    tool=doc.GetAction()                                        #Gets the active tool  
                    tool=c4d.plugins.FindPlugin(tool, c4d.PLUGINTYPE_TOOL)  
                    tool[c4d.ID_CA_JOINT_NAMING_REPLACE] = "Cube"               #Set the text to replace  
                    tool[c4d.ID_CA_JOINT_NAMING_REPLACE_WITH]= "fdsdf"          #Set the new text      
                    c4d.CallButton(tool, c4d.ID_CA_JOINT_NAMING_REPLACE_APPLY)  
                    
                    c4d.EventAdd()  
                    
                  if __name__=='__main__':  
                    main()
                  

                  -ScottA

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 05/04/2012 at 13:59, xxxxxxxx wrote:

                    Hey Scott

                    Your frustration is palpable. If its any consolation, your are helping others posting this stuff here.

                    Thanks

                    Paul

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 05/04/2012 at 14:22, xxxxxxxx wrote:

                      That's good to hear.
                      Because at this point. My hands are still shaking from anger.
                      But it does help to calm me down a bit if I ended up helping someone else in the process.

                      -ScottA

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 05/04/2012 at 15:30, xxxxxxxx wrote:

                        😂

                        the sdk sometimes feels like monkey island - the code riddle. with figuring out the id madness
                        for GetAction() and FindPlugin() i guess you have solved the end boss riddle 🙂 enjoy the credits 😉

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