How to properly set Selection tool data?



  • 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?



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


Log in to reply