Very beginner at MAXScript, can't get matchPattern to work

EDIT: by trial and errors (so many errors....) i made it work! thanks anyway

Hi all,

I'm doing a few exercise in maxscript to get the handle of it and i'm trying to modify objects depending on their name. I write my pattern in a Edittext box and i want it to compare with objects in my scene. I managed to have my objects change if i wrote my pattern directly in my script but i can't get it to work with the text i write in my Edittext.

Here is my function to matchpattern and replace the objects

on RecastFromPattern pressed do
(
select geometry
--select all the objects on the scene

for i = 1 to selection.count do
--will do this function as many times as there are objects
(
if (matchPattern selection[i] pattern:"Pattern") then
--will verify the name of each objects and compare it with what was written in the Edittextt box and saved in the variable "Pattern"
(
instanceReplace selection[i] ThePickMaster
--if there is a match it will replace the object of that number of the count with the object previously selected by the pickbutton and saved in the variable ThePickMaster
)
)
)

Can anyone tell me what i'm doing wrong with matchpattern???

Comments

Comment viewing options

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

a= selection as arrayb= for

a= selection as array
b= for i in a where matchpattern i.name pattern:"your text pattern" collect i -- b result is array that contain object name that match your pattern.....after that you can do whatever you want

Comment viewing options

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