ScriptSpot

Forum topic · General Scripting

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

By houourin · 2016-02-02

Description

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 (2)

.

miauu · 2016-02-02


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 · 2016-02-03

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