[macro] check if a colour exists in a specify level

[macro] check if a colour exists in a specify level

moraschini
Enthusiast Enthusiast
735 Views
6 Replies
Message 1 of 7

[macro] check if a colour exists in a specify level

moraschini
Enthusiast
Enthusiast

Hello everyone, is possible check with a macro if a colour exists in a specify level?

colour: 181,102,0

level: 170

thanks in advance for the help

 

0 Likes
Accepted solutions (1)
736 Views
6 Replies
Replies (6)
Message 2 of 7

icse
Advisor
Advisor
Accepted solution

Try this:

 

EDIT SELECTION MODEL TYPE LEVEL
EDIT SELECTION MODEL FILTER "170"
EDIT SELECTION MODEL TYPE COLOUR
EDIT SELECTION MODEL FILTER "181,102,0"

if max(apply(folder('model'), "number_selected('model', this.Name)")) > 0 {
	message info 'Found a surface'
}

 

0 Likes
Message 3 of 7

moraschini
Enthusiast
Enthusiast
hello, if it isn't a furface but a bidimensional line?
0 Likes
Message 4 of 7

icse
Advisor
Advisor

yes, this should also find lines.(everything in lvl '170' with your given color '181,102,0')

0 Likes
Message 5 of 7

moraschini
Enthusiast
Enthusiast
hello @icse, it works well, one question, can you explain me the funcion "max" and "applay" please?
i did't find in the guide.
thanks a lot for your help
0 Likes
Message 6 of 7

icse
Advisor
Advisor

Apply:

string apply( list list, string expression )

Returns a new list consisting of the values obtained by applying 'expression' to each element of the input list list. In the expression you can give the keyword this to refer to the current list item

Example: Add "_1" to a list of strings
STRING LIST mlist = {'a', 'b', 'c', 'd'}
STRING LIST ulist = apply(mlist, "this + '_1'")
print ${ulist[0]}
// prints "a_1"
print ${ulist[1]}
// prints "b_1"
Example: To find the minimum Z value of the toolpaths in an NCProgram
PRINT = min(apply(folder('ncprogram'), 'limits(this)[4]')) 

 

max:

real max( list numeric a )

Find the largest value in a list of numbers.
Message 7 of 7

moraschini
Enthusiast
Enthusiast

thnaks a lot @icse 

0 Likes