Optimizing code

Hello
I am trying to optimize my code. Need to select a object class in a specific layer.
I am working with code that consists of two stages:
1: Selecting all objects in the layer.
2: Selecting splines from selected objects.

(
local allNodes = #(), theNodes = #()
for n in selection do (n.layer.nodes &theNodes ; join allNodes theNodes)
select allNodes
select(for obj in selection where classof obj.baseObject==line collect obj)
)

I am looking for a way to exclude the first part while keeping the result.
Any ideas on how to do this? Any help appreciated.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

(
	all_nodes = #()
	tmp = #()
	for layer in makeuniquearray (for s in selection collect s.layer) do
	(		
		layer.nodes &tmp	
		join all_nodes tmp		
	)
	arr = makeUniqueArray all_nodes
	format "%\n" arr.count
)
miauu's picture

.

Yep, that is true. :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.