Script for Poth editable poly and Edit Poly modifier


#1

Hello! I’m new to scripting, so would appreciate some help!
I’m trying to create a script that have button that affect Poth editable poly and Edit Poly modifier
but it affect only on editable poly .

Blockquote

try(cui.unRegisterDialogBar MasterBrushs)catch()
try(DestroyDialog MasterBrushs) catch()
rollout MasterBrushs “Master Brushs” width:150 height:283
(
button ‘btn1’ “X” pos:[15,27] width:30 height:30 align:#left
on btn1 pressed do
(
$.paintDeformAxis =3
$.paintDeformValue = 2
$.paintDeformStrength = 0.2
)
)

createdialog MasterBrushs
cui.registerDialogBar MasterBrushs

Blockquote
and thanks for help


#2
(
	selObj = selection[1]
	if classOf selObj == Editable_Poly then
	(
		selObj.paintDeformAxis =3
		selObj.paintDeformValue = 2
		selObj.paintDeformStrength = 0.2
	)
	else
	(
		if classOf (epMod = selObj.modifiers[1]) == Edit_Poly do
		(
			max modify mode
			epMod.paintDeformAxis = 3
			epMod.paintDeformValue = 2
-- in max2020 the Modify Panel must be open so the next  setting to be set
			epMod.paintDeformStrength = 0.2
		)
	)
)

#3

I 'm really appreciate you’re help
i have another question, please!!!
When I press the button without selecting any item, I get a problem and the script is no longer working
Is there a code for that ?
my script all about paint deformation
Annotation%202022-09-09%20231518


#4

The code expect an editable poly object or an object with applied Edit Poly modifier to be selected. If nothing is selected you will see the above error.

This will show you a message when no object is selected.

(
	if selection.count == 1 then
	(
		selObj = selection[1]
		if classOf selObj == Editable_Poly then
		(
			selObj.paintDeformAxis =3
			selObj.paintDeformValue = 2
			selObj.paintDeformStrength = 0.2
		)
		else
		(
			if classOf (epMod = selObj.modifiers[1]) == Edit_Poly do
			(
				max modify mode
				epMod.paintDeformAxis = 3
				epMod.paintDeformValue = 2
	-- in max2020 the Modify Panel must be open so the next  setting to be set
				epMod.paintDeformStrength = 0.2
			)
		)
	)
	else
		messagebox "Select an object" title:""
)

#5

thanks pro it’s worked very well