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

    Polygon Selection Tag

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 362 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 17/10/2017 at 23:34, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R18 
      Platform:   Windows  ;   
      Language(s) :       PYTHON  ;

      ---------
      Hello guys,
      I'm currently working on a script and I'm stuck on how can I click on the Select Polygons button in the Polygon Selection Tag with the script, any help is much appreciated.

      -Salah

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

        On 19/10/2017 at 06:59, xxxxxxxx wrote:

        Hi Salah,

        welcome to the Plugin Café forums 🙂

        Don't feel confused, I moved your thread into the Python sub-forum.

        Actually you have two options here.

        One is to press the button as a user would do.
        The function to do so is CallButton(). The problem with buttons is, you can't drag them to the command line to easily get the ID needed for CallButton(). The way I'd recommend is to search the resource/modules sub-folder of your Cinema 4D installation directory. There you find all the resource files. In this case you'll find tpolygonselection.res, the description of the polygon selection tag in resource/modules/c4dplugin/description. There you'll see the buttons use the IDs POLYGONSELECTIONTAG_COMMAND1 to POLYGONSELECTIONTAG_COMMAND6.

        So in order to press the "Restore Selection" button, you'd call (with op being the currently active object and assuming there's only one polygon selection tag) :

        tag = op.GetTag(c4d.Tpolygonselection)
        if tag is not None:
            c4d.CallButton(tag, c4d.POLYGONSELECTIONTAG_COMMAND1) # press "Restore Selection"
            c4d.EventAdd()
        

        The other more versatile option would be to leave the buttons alone and instead work on the selections (BaseSelect) directly.
        This could for example look like so (same assumptions as above and same behavior as "Restore Selection") :

        bsOp = op.GetPolygonS()
        bsTag = tag.GetBaseSelect()
        bsOp.DeselectAll()
        bsOp.Merge(bsTag)
        c4d.EventAdd()
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post