ScriptSpot

Forum topic · General Scripting

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

By tassel · 2012-01-12

Description

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 (2)

tassel · 2012-03-12

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")
	)
)

try this

Anubis · 2012-01-12

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")
)