Easy thing that I'm struggling, Select by "name"

Hi!

I'm really new into scripting, I'm making a script to select some objects that have "SPR" inside theyr name, but... I can only make it work if the name is exactly "SPR"

really basic stuff sorry, maybe my approach is all wrong.

on btn1 pressed do
(
local springs = #()
for i in selection where classof i == point do
(
if ( i.name == "SPR") do
(
print "hello"
)

)
)

this succesfully prints hello when detects SPR as a name, but I tried to put *SPR* so, if it has SPR inside the name, it prints it too but... wont work...

If you could give me a tip of what I'm doing wrong...

Comments

Comment viewing options

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

.

on btn1 pressed do
(
	local springs = #()
	for i in selection where classof i == point do
	(
		if ( matchPattern i.name pattern:"*SPR*") do
		(
		print "hello"
		)
 
	)
)
houourin's picture

Thank you!! I'll check that,

Thank you!! I'll check that, makes lot of sense! :)

Comment viewing options

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