[Closed] Need help with max script
Hi every one, I’m a newbie in using MAX script, can anyone help me write a script to select in SME all material have name contain a string. Example : i have some material in SME name : #1 wood, #2 wood, old wood, #1 steel, #2 steel, old steel … and I want seclect all material have name contain “wood” : #1 wood, #2 wood, old wood. Thank for any help !
for the discription
a=sme.getview sme.activeview
r=dotnetclass "system.text.regularexpressions.regex"
msel = #()
for m in material.classes do join msel (getclassinstances m)
a.setselectednodes (for m in msel where r.ismatch m.name "wood$" collect m)
instead wood$
to wood
if not need end with wood
instead msel and below if not need limit to material node
for i = 1 to a.getnumnodes() where classof (m =a.getnode i) == mixininterface and r.ismatch m.name "wood$" do m.selected=true
However, using Regex for this particular task is clearly redundant and, furthermore, it is slower compared to the built-in MatchPattern function.
I like regular expression because of it’s controllability , lots of my string handling works hard to solve by mxs
I love regular expressions… but the day after I use them, I forget all the syntax. So I try to use the good old-school wildcards.