Assign Random Material ID to Selection

undo on
(
newMaterial = multiMaterial numsubs:32
for i = 1 to 32 do
newMaterial[i].diffuse = random (color 0 0 0) (color 255 255 255)
$.material = newMaterial

for obj in $ do obj.material = newMaterial[random 1 32]
)

Hello. I found this script. It works in Editable poly, but it does not apply in Edit Poly, so I want to know the solution. I tried various experiments while viewing the Max script help, but it is not good because I am a beginner ... I apologize for any inconvenience caused by using a translator.

Thank you.

AttachmentSize
problem.jpg130.91 KB

Comments

Comment viewing options

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

I do not mean applying material to an existing mat id.

I mean that the selected polygon is created with a random ID and color applied each time.

If you use this script with a shortcut key, editable poly will be applied similar to specifying poly group in zmodeler of zbrush. However, edit poly does not create a new mat id and random color on the selected polygon.

https://www.youtube.com/watch?v=k-61qHttVQc
Originally I tried to use this script, but in 3dsmax 2017 it did not work and I was trying to figure out something else.

I'm sorry I did not get the explanation right. And thank you for your reply.

ZalitZ's picture

Differences between Editable Poly and Edit_Poly modifier

In fact there seem to be a difference between the two. With Editable poly you can use Polyop methods but not with the modifier :"All polyOp methods take as an argument , the poly to operate on. This argument can be either a node value where the base object of the node is an Editable_Poly, or the Editable_Poly base object."
(You can verify this with

polyop.getFaceSelection $

on each version)

It's pretty cool that assigning a material to selected poly automaticaly makes a multimaterial with random ID. But I think that if you want to use it with Edit_poly, you will have to use the modifier's methods like

$.modifiers[#Edit_Poly].materialIDToSet
ZalitZ's picture

Are you sure the Edit Poly one has different face IDs ?

There shouldn't be any difference between a converted Editable Poly and the Edit poly modifier (I could be wrong though).

I rewrote the script. You should try this.

undo on (
	nb = 32 
	for obj in selection do (
		newMaterial = multiMaterial numsubs:nb
		obj.material = newMaterial
		for m in newMaterial.materialList do m.diffuse = random black white 
	)
)

Comment viewing options

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