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 properly set Selection tool data?

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

      On 08/08/2017 at 08:34, xxxxxxxx wrote:

      Howdy,

      I was trying to help someone out with a toggle between Live Selection and Rectangle Selection. The kicker is that the user wanted the Only Select Visible elements box off for Rectangle selection.

      I had the following code:

      import c4d

      td = doc.GetActiveToolData() // s**t dont work

      def main() :
          
          if c4d.IsCommandChecked(200000083) :
               # If Live Select is enabled, 
              c4d.CallCommand(200000084)
              bc=doc.GetActiveToolData()
              bc[c4d.MDATA_SELECTLIVE_VISIBLE]=0

      else:
               # Otherwise switch to Live
              c4d.CallCommand(200000083)
              bc=doc.GetActiveToolData()
              bc[c4d.MDATA_SELECTLIVE_VISIBLE]=1
       
          
      if __name__=='__main__':
          main()

      It kinda worked. But if you were in Rectangle Selection and turned ON the Select Visible Elements box manually, then when you use the script to toggle, that box stays on and does not respect the code.

      Is there a correct way to set that data?

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

        On 09/08/2017 at 02:40, xxxxxxxx wrote:

        Hi Bret,

        the actual problem is the parameter ID you are using for the Rectangle Selection. It's not the same as for Live Selection, it's MDATA_SELECTION_VISIBLE.

        Then you may want to consider the use of symbols instead of numerical IDs for the tools as well: ID_MODELING_LIVESELECTION, ID_MODELING_RECTSELECTION

        Finally it feels a bit more natural to me to use GetAction() and SetAction().

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