Notifications
Clear all

[Closed] copy paste modifiers

HelloHello!

Does anybody know how to script the copy-paste modifier procedure? What is exactly happening there?

Im trying to copy a skinmorph mod from one mesh to another, it works by hand but i just cant do it in script. i tried something like that:

smod = obj1.modifiers[#skin_morph]
addmodifier obj2 smod

that works, its an instance and all works as expected, however when i go “make unique” max crashes (i can delete the sourceobject now but it seems its still dodgy somewhere)

normally copy works with modifiers but in this case
smod = copy obj1.modifiers[#skin_morph] crashes max (when i open up the modifier panel)

its weird because it works manually and i can copy the modifier without it being an instance
:banghead:

i just wonder whats happenening in max “under the hood” and if i can reproduce it!

thanks all!

seb

4 Replies

I’d like to know exactly the same thing. I want to be able to batch-paste modifiers across a selection of objects, but the actual mod copy to paste eludes me.

I’m doing a lot of batch processing and needed a tool to copy modifiers to several
objects with a single click, too.
I never had any problems with the following code, which I use in my personal script toolbox.
I’m not familiar with the SkinMorph modifier, so the problem might rather be with that than
the copy function.
Hope that snippet helps anyway.

The GUI items:


  	global VTV_modifier
  	group "Copy Modifier"
  	(
  		checkbutton chkb_modcopy "Copy Modifier" height:18 width:120
  		button btn_applymodcopy "Select a modifier" height:18 width:120 enabled:false
  	)
  

The events:


  	on btn_applymodcopy pressed do
  	(
  		if VTV_modifier == undefined then return 0
  		else
  		(
  			for obj in selection do
  			(
 		 	if validModifier obj VTV_modifier then addmodifier obj (copy VTV_modifier)
  			)
  		)
  	)
  
  	on chkb_modcopy changed val do
  	(
  		local o,s
  		if val then
  		(
  			if selection.count == 1 then
  			(
  				try
  				(
 					o = selection[1]
 					s = modPanel.getcurrentObject()
 					if s != undefined then
  					(
 		 			s = modPanel.getModifierIndex o s
 						print s
 		 			VTV_modifier = copy o.modifiers[s]
 		 		 chkb_modcopy.caption = o.modifiers[s].name
 		 		 btn_applymodcopy.enabled = true
 		 		 btn_applymodcopy.caption = "Apply Modifier"
  					)
 					else chkb_modcopy.checked = off
  				)
  				catch
  				(
 					chkb_modcopy.checked = off
  				)
  			)
  			else chkb_modcopy.checked = off
  		)-- end ON
  		else
  		(
  			chkb_modcopy.caption = "Copy Modifier"
  			VTV_modifier = undefined
  			btn_applymodcopy.caption = "Select a modifier"
 		 btn_applymodcopy.enabled = false	 	
  		)
  	)
   

That works, but it doesn’t actually do what I need! I need the EXACT copy of the mod, as in what it has actually modified.

In my case, I have a fence made up of several hundred segments (split up for game-export reasons). I have just applied a change with the editPoly mod, and want to copy the same changes across the other meshes. I could be wrong in the application of your code, but I think it only copies the modifier itself, not what you’ve done with it.

I’ve got a feeling this would have to be a far more elaborate piece of code, whereby the modifier would be copied across, then the sub-object changes would have to be applied across each copy.

The script copies all the properties / values of a modifier,
but they may not apply to other objects than the original.
An UVWunwrap for example, copied to a clone of an object may not work
properly on that clone, even if it still the same.
Certain processes reorder object properties like the vertex/Tvert arrray
so that the object may be the same visually, but internally is not identical at all.
The change you describe should work using the copy process, given the objects
you paste the modifier to are identical to the base.

If not, I hope you find a solution to your problem.