Profile
- Name
- Cut Around Selected
- ID
- 103639
- Shared with
- Public
- Parent
- None
- Children
- None
- Created on
- June 24, 2020 at 22:38 PM UTC
- Updated on
- June 24, 2020 at 22:38 PM UTC
- Description
This recipe will cut around a selected segment, leaving it isolated from all other segments
To make the recipe skip cutting around segment, add a note to that segment that contains the string "<NC>"
Best for
Code
function checkAndCut(segment)
-- Check if segment is within range (to avoid crashing foldit)
if (segment <= structure.GetCount()) and (segment > 0) then
-- Check if no cut flag in note.
if not string.find(structure.GetNote(segment), "<NC>") then
structure.InsertCut(segment)
end
end
end
function main()
-- Iterate through all segments
for segment=1, structure.GetCount() do
-- Check if the segment is selected
if selection.IsSelected(segment) then
-- Cut around segment, but do it safely to avoid crashing.
checkAndCut(segment)
checkAndCut(segment-1)
end
end
print("Done")
end
function cleanup(err)
if string.find(err, "Cancelled") then
print("User Cancelled")
else
print(err)
end
return err
end
xpcall(main, cleanup)