selected face assign material only

for o in selection where isKindOf o Editable_Poly or isKindOf o Editable_Mesh do
(
topFaces = #{}
minFaces = #{}

gfc = if isKindOf o Editable_Poly then polyop.getfaceCenter else meshop.getfaceCenter
for f = 1 to o.numfaces do
(
if (gfc o f).z == o.max.z do append topFaces f

if (gfc o f).z == o.min.z do append minFaces f
)
o.selectedfaces = topFaces
polyop.setFaceSelection o topFaces

topfaces.material = meditMaterials[22]

)

there is script
i would like to assign material in topfaces only
but this code is error
pls some help ~

Comments

Comment viewing options

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

.

(
	max modify mode
	selObsArr = selection as array
	for o in selObsArr where isKindOf o Editable_Poly or isKindOf o Editable_Mesh do
	(
		select o
		subobjectlevel = 4
		topFaces = #{}
		minFaces = #{}
 
		gfc = if isKindOf o Editable_Poly then polyop.getfaceCenter else meshop.getfaceCenter
		for f = 1 to o.numfaces do
		(
			if (gfc o f).z == o.max.z do append topFaces f
 
			if (gfc o f).z == o.min.z do append minFaces f
		)
-- 		o.selectedfaces = topFaces
		polyop.setFaceSelection o topFaces
 
		o.material = meditMaterials[2]
 
	)
)

But this is not the proper solution. ;)

dussla's picture

thank you

that is good ~
really thank you always

Comment viewing options

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