IsolateLockToggle does work only at the second try now


can someone tell me why this happens most of the time and how to change the code?

Thank you

The Error:

The Code:
import rhinoscriptsyntax as rs
import scriptcontext as sc

x = False
if sc.sticky.has_key (“IsolateLockState”):
x = sc.sticky[“IsolateLockState”]

if x:
rs.Command("UnIsolateLock Enter ")
sc.sticky[“IsolateLockState”] = False
rs.Command("IsolateLock Enter ")
sc.sticky[“IsolateLockState”] = True (333 Bytes)

Maybe this?

import rhinoscriptsyntax as rs
import scriptcontext as sc

if sc.sticky.has_key("IsolateLockState"):
    rc = sc.sticky["IsolateLockState"]
    rc = False
if rc:
    rs.GetObjects("Select objects to isolate lock", 0, True, True, True)
    rs.Command("_IsolateLock _Enter")
sc.sticky["IsolateLockState"] = not rc

– Dale

Dale thanks for this, tested and it says the following seem like it unlocks instead of IsolateLocking (selecting objects, running the script and the inverted selection is locked - works also as a toggle)

What do you think?

Thank you!

PS: the current script works in most of the cases with double Enter (running the script two times) toggling would work on one click. But there are unpredicted times where it works just fine. have no idea
what is happening :slight_smile: