Polygon Selection Tag



  • 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



  • 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()
    

Log in to reply