Notifications
Clear all

[Closed] select objects if possible

If I have 10 boxes I can execute this no problem:

select #($Box01, $Box02, $Box03, $Box04, $Box05, $Box06, $Box07, $Box08, $Box09, $Box10, $Box11)
 OK

but if I delete box05 then that will fail:

select #($Box01, $Box02, $Box03, $Box04, $Box05, $Box06, $Box07, $Box08, $Box09, $Box10, $Box11)
 -- Runtime error: operation requires a collection of nodes, got: undefined

can someone tell me the concept and how I select the available object from a list?

13 Replies

nodeArr = #($Box01,$Box02,$Box03,$Box04,$Box05,$Box06,$Box07,$Box08,$Box09,$Box10)
for o in nodeArr where isValidNode o do selectMore o

thanks so much miauu this worked great

I was looking into try () catch () and arrays…

just an alternative, since ‘select’ is mapped you can pass it the array directly rather than add each object to the current selection –

nodeArr = #($Box01,$Box02,$Box03,$Box04,$Box05,$Box06,$Box07  ,$Box08,$Box09,$Box10)
select (for o in nodeArr where isValidNode o do collect o)

could possibly be faster on large arrays!

Does “select $Box*” works for you?

1 Reply
(@davewortley)
Joined: 11 months ago

Posts: 0

LOL! I’m not sure even DenisT could optimise that further!

Hahaha, I bet he would!

select $Box* – the way of possible optimization…

the only way that I can optimize it is:
select $box*

For most of fonts it saves several pixels of the screen. Which extends a monitor lifetime.

But when we look at binary codes of B and b we will see that
B is 01000010
and
b is 01100010

so the b takes one bit memory more than B. Which in case of an extensive using of letters b might excessively load the memory.[i]

The conclusion is – use any code optimization wisely!
[/i]

1 Reply
 elT
(@elt)
Joined: 11 months ago

Posts: 0

Hahaha :bowdown:

So if you MADE EVERY CHARACTER A CAPITAL LETTER in a long script you could save maybe 1 or 2kb of memory?

In which case:

SELECT $BOX*

I optimised your code further

Interesting Dave – It would be smaller, yes, but it would feel like the script was selecting boxes in an angry syntax. I would take the hit on the extra bytes just so i didnt feel like my script was shouting at me. :argh:

p.s. whoohoo, my 1,500th post!

1 Reply
(@system)
Joined: 11 months ago

Posts: 0

  FOR STUPIDVARIABLE IN SELECTION COLLECT PUNY ITSY BITSY OBJECTS AARRRRRRRGGGG!! ANGER!
Page 1 / 2