Logic Machine Forum
delete all objects without tag - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: delete all objects without tag (/showthread.php?tid=4114)



delete all objects without tag - gjniewenhuijse - 28.06.2022

Hello,

Is it possible to delete all objects without tag. This is not possible in the UI, but is it possible in a script?


RE: delete all objects without tag - admin - 28.06.2022

Use this, change the tag name as needed. And make a backup just in case Smile
Code:
tag = 'test'

tagged = {}

objs = grp.tag(tag)
for _, obj in ipairs(objs) do
  tagged[ obj.address ] = true
end

objs = grp.all()
for _, obj in ipairs(objs) do
  if not tagged[ obj.address ] then
    grp.delete(obj.address)
  end
end