Toggle knife cut planes



  • Hello There,

    in earlier days (R19 and before) I had a script to toggle the planes from our plane knife cut tool. Sadly it's not working anymore (R21).
    What I was able to create was a simple plane cut script for each plane, but I need now three shortcuts to switch them instead of one.
    Does anybody have an idea, how this script will look like, with one shortcut?

    Thank you very much!

    Best,
    Peter

    import c4d
    from c4d import gui
    
    def main():
        def tool():
            return c4d.plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
    
        def object():
            return doc.GetActiveObject()
    
        def tag():
            return doc.GetActiveTag()
    
        def renderdata():
            return doc.GetActiveRenderData()
    
        def prefs(id):
            return c4d.plugins.FindPlugin(id, c4d.PLUGINTYPE_PREFS)
    
        c4d.CallCommand(431000164, 431000164) # Plane Cut
        tool()[c4d.MDATA_KNIFEPLANE_PLANE_MODE] = 2
        tool()[c4d.MDATA_KNIFEPLANE_PLANE] = 0
    
    if __name__=='__main__':
        main()
        c4d.EventAdd()
    


  • hello,

    if i understood correctly the question you should just add one the to current value of the MDATA_KNIFEPLANE_PLANE with a % (modulo) of 3. So the value will come back to 0 instead of going to 4.

        tool()[c4d.MDATA_KNIFEPLANE_PLANE] = (tool()[c4d.MDATA_KNIFEPLANE_PLANE] + 1) % 3
    

    Cheers,
    Manuel



  • @m_magalhaes PERFECT! thank you very much!

    import c4d
    from c4d import gui
    
    def main():
        def tool():
            return c4d.plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
    
        def object():
            return doc.GetActiveObject()
    
        def tag():
            return doc.GetActiveTag()
    
        def renderdata():
            return doc.GetActiveRenderData()
    
        def prefs(id):
            return c4d.plugins.FindPlugin(id, c4d.PLUGINTYPE_PREFS)
    
        c4d.CallCommand(431000164, 431000164) # Plane Cut
     tool()[c4d.MDATA_KNIFEPLANE_PLANE] = (tool()[c4d.MDATA_KNIFEPLANE_PLANE] + 1) % 3
    
    if __name__=='__main__':
        main()
        c4d.EventAdd()
    


  • i forgot to mention:

    For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

    I've added the tags and marked this thread as a question so when you considered it as solved, please change the state :)

    Cheers,
    Manuel


Log in to reply