ScriptSpot

Forum topic · General Scripting

where....collect?

By JokerMartini · 2012-03-06

Description

Is there a method for doing something along the lines of
for obj in selection where obj.name collect (collect only unique) obj

Comments (3)

barigazy · 2012-03-07

Maybe this can help

fn collect_UniqueNames =
(
local tempArr = #(), ghv = gethashvalue
for obj in objects where (finditem tempArr (g = gethashvalue obj.name 0)) == 0 collect (append tempArr g ; obj.name)
)
uniqueNamesArr = collect_UniqueNames()

collecting by unique name?

Anubis · 2012-03-06

if so, an possible way:

objNames = for obj in selection collect obj.name
objNames = makeUniqueArray objNames
uniObjs = for n in objNames collect (getNodeByName n)

Yes, you just wrote it ;)

Garp · 2012-03-06

red_boxes = for obj in $box* where obj.wirecolor == red collect obj