Select object FaceMatID's and assign ID seperatly to selected face

Hi,

I Have some problems here, i'm trying to get this work with Mesh and Poly objects, but it only works with mesh objects. Any tip?

		try
		(
			a=#()
			obj =selection[1]
			a = if classof obj == polymeshobject then polyop.getfaceselection obj else getfaceselection obj as array
 
			for i=1 to a.count do
			(
				setfacematid obj a[i] matidvalue
			)
		    update(obj)
		)catch()

Comments

Comment viewing options

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

Ahh. Forgot about this

Ahh. Forgot about this thread. Thank you Anubis.
I ended up with this:

fn fnmatidassign matidvalue=
(
	--a = #()
	--matidvalue = 3
	obj = selection[1] 		
 
case classOf obj of
	(
	Editable_mesh: (
		em =  getfaceselection obj as array
 
			for i=1 to em.count do
				(
					setfacematid obj em[i] matidvalue
				)
					update obj
		)
	Editable_Poly: (
			ep = polyop.getfaceselection obj as array
 
			for i=1 to ep.count do
				(
					polyop.setFaceMatID obj ep[i] matidvalue
				)
					update obj
		) 
 
		Line: (
			if subobjectLevel == 2 then
				for sp = 1 to numSplines obj do
					for se in getSegSelection obj sp do
						setMaterialID obj sp se matidvalue
 
 
			else if subobjectLevel == 3 then
				for sp in getSplineSelection obj do
					for se = 1 to numSegments obj sp do
						setMaterialID obj sp se matidvalue
 
					updateshape obj
		)
		default: (format "Non poly, mesh or shape/spline object!\n")
	)
)

/ Raymond

Anubis's picture

try this

obj = selection[1]
matID = 3
 
case classOf obj of
(
	Editable_mesh: (
		fcSel = getFaceSelection obj
		for f in fcSel do setFaceMatID obj f.index matID
	)
	Edit_Poly: (
		fcArr = polyop.getFaceSelection obj
		polyop.setFaceMatID obj fcArr matID
	)
	default: (format "Non poly or mesh object!\n")
)

my recent MAXScripts RSS (archive here)

Comment viewing options

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