Notifications
Clear all

[Closed] Q:- Simple if else

Hi All,
I want to use a if / else statement to assign 2 materials to geometry if the geometry name meets a rule in this case use pattern matching

something like

if geometry name is of pattern *glass* *G* *dave* == true then
(
	a = array of objects meeting rule
        a.material = meditMaterials[2]
)
else
(
        b= array of object not meeting the rule
        b.material = meditMaterials[1]
)


if obj ==  $*glass*  $*G* then
(
	print true
)
else
(
	print false	
)

Hope this makes sense.

b

2 Replies
for obj in selection do case of
(
	(matchPattern obj.name pattern:"*glass*") : obj.material = meditMaterials[2]
	(matchPattern obj.name pattern:"*G*" ignoreCase:false) : obj.material = meditMaterials[2]
	(matchPattern obj.name pattern:"*dave*") : obj.material = meditMaterials[2]
	default : obj.material = meditMaterials[1]
)

thanks for the answer > matchpattern() didnt know it existed, thanks for the pointer

b