skin_wrap meshDeformOps ConvertToSkin in Maxscript - error, or bug?

skin_wrap meshDeformOps ConvertToSkin in Maxscript - error, or bug?

theonlyaaron
Participant Participant
1,449 Views
9 Replies
Message 1 of 10

skin_wrap meshDeformOps ConvertToSkin in Maxscript - error, or bug?

theonlyaaron
Participant
Participant

Hello, I am trying to execute the "ConvertToSkin" function in the "meshDeformOps" on a skin wrap modifier. 

I recieve an "EXCEPTION_ACCESS_VIOLATION" when attempting to call the function, I think properly.

 

I have a function where I am passing it an node and a list of nodes to skinwrap to.

 

The function works until I attempt to "convertToSkin", I have 2 approaches where I try to access the modifier from its stored variable, and where I retrieve it from the node directly. The second, less preferred option is commented out. Both return the same error.

 

The "ValidModifier" is in there to try and "poke" the modifier to initialize it, an old maxscript trick when things are not working properly.

 

Here is the relevant function:

		function skinwrapStealWeights arg_Node arg_List =
		(
			newSkin_Wrap = Skin_Wrap()
			newSkin_Wrap.engine = 0
			newSkin_Wrap.weightAllVerts = true
			newSkin_Wrap.meshList = arg_list

			addModifier arg_Node newSkin_Wrap
			validModifier arg_Node newSkin_Wrap

			--newSkin_Wrap.meshDeformOps.ConvertToSkin on
			arg_Node.modifiers[#skin_wrap].meshDeformOps.ConvertToSkin on

		),

 

I have tested this in 3dsMax 2021 and 2023, I am looking for pointers, or confirmation on my speculation it may be a bug, in which case I can report it.

 

Cheers, 

Aaron

0 Likes
Accepted solutions (1)
1,450 Views
9 Replies
Replies (9)
Message 2 of 10

theonlyaaron
Participant
Participant

I was able to get the ConvertToSkin function to work by setting my selection to only the object that the skin wrap was on, and setting the command panel to the modifier panel before calling the meshDeformOps function.

 

Hopefully this ends up being useful for someone. 

 

			newSkin_Wrap = Skin_Wrap()
			newSkin_Wrap.engine = 0
			newSkin_Wrap.weightAllVerts = true
			newSkin_Wrap.meshList = arg_list

			addModifier arg_Node newSkin_Wrap
			validModifier arg_Node newSkin_Wrap

			max modify mode 
			select arg_Node
			newSkin_Wrap.meshDeformOps.ConvertToSkin on

 

 

0 Likes
Message 3 of 10

denisT.MaxDoctor
Advisor
Advisor

if you do everything right, the command panel does not need to be put into #modify mode

0 Likes
Message 4 of 10

denisT.MaxDoctor
Advisor
Advisor

It makes no sense to ask a question in this form... Well, for example, I could answer, "It works for me!" ... How does that help you?
It always makes sense to give a simple example of a scene in which the issue you describe occurs, and to provide steps so that others can reproduce it.

0 Likes
Message 5 of 10

theonlyaaron
Participant
Participant

Thanks for the reply @denisT.MaxDoctor, ideally I would like to avoid needing the command panel to be in modify mode, and would appreciate if you had any insight into how I could achieve this. I'll prepare reproduceable steps shortly.

0 Likes
Message 6 of 10

denisT.MaxDoctor
Advisor
Advisor

@theonlyaaron wrote:

I'll prepare reproduceable steps shortly.


👍

0 Likes
Message 7 of 10

theonlyaaron
Participant
Participant

Here are the assets and steps to re-create the Memory Exception I have been receiving when attempting to execute the meshDeformOps.ConvertToSkin

 

Here is the same function, modified to use the attached 3dsMax scene ( created in 2023 ) .

 

function skinwrapStealWeights arg_Node arg_List =
(
	newSkin_Wrap = Skin_Wrap()
	newSkin_Wrap.engine = 0
	newSkin_Wrap.weightAllVerts = true
	newSkin_Wrap.meshList = arg_list

	addModifier arg_Node newSkin_Wrap
	validModifier arg_Node newSkin_Wrap

	arg_Node.modifiers[#skin_wrap].meshDeformOps.ConvertToSkin on
)

clearListener()
skinwrapStealWeights $Cylinder002 #($Cylinder001)

 

Cylinder002 ( red )  is desired to be skinwrapped to the blue cylinder002. Then have its weights converted to skin.

 

When no objects are selected, and the command panel is not in #modify mode, the EXCEPTION_ACCESS_VIOLATION occours

 

When no objects are selected, and the command panel is in #modify mode, the EXCEPTION_ACCESS_VIOLATION occurs.

 

When any multiple number of objects are selected, and the command panel is in #modify mode, the EXCEPTION_ACCESS_VIOLATION occurs.

 

Only when the command panel is in #modify mode, and Cylinder002 is the only object selected ( the one that is receiving the skin wrap, and subsequent skin modifier ), does the meshDeformOps .ConvertToSkin operation complete correctly.

 

@denisT.MaxDoctor, or anyone else, If you have any insight, in how to avoid invoking the modifier panel, I would appreciate it.

 

Thanks

 

 

 

0 Likes
Message 8 of 10

denisT.MaxDoctor
Advisor
Advisor

if you want as many people as possible to be interested in your question, provide an example for version 3-4 before the most recent one. According to statistics, no more than 10% of users use the latest version of MAX. Thus, the most suitable version for the sample scene is MAX 2020.

Message 9 of 10

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

@theonlyaaron wrote:

If you have any insight, in how to avoid invoking the modifier panel, I would appreciate it.

 


It's a well known issue that skin methods and operations don't work without the modify panel... They should work in the 2023 version, but not in case of the Skin Wrap to Skin conversion.

Anyway... it's not just skin methods that only work in #modify mode. Indeed, the switching of the panels not just slows down scripts that use these methods, but also it's really very annoying.

The only way to stay within built-in maxscript and minimize flickering is to disable redrawing of the MAX window (or just the command panel if you prefer):

 

 

(
	-- source = $s
	-- <source> is the node that needs be converted 

	WM_SETREDRAW = 11
	MAX_HWND = windows.getMaxHWND()
	windows.sendmessage MAX_HWND WM_SETREDRAW 0 0
	sel = selection as array
	mode = getCommandPanelTaskMode()
	setCommandPanelTaskMode mode:#modify
	modPanel.setCurrentObject source.skin_wrap
	source.skin_wrap.ConvertToSkin on
	if sel.count then select sel else clearselection()
	setCommandPanelTaskMode mode:mode
	windows.sendmessage MAX_HWND WM_SETREDRAW 1 0
)

 

 

Message 10 of 10

theonlyaaron
Participant
Participant

@denisT.MaxDoctor 

 

Thank you, that did the trick wonderfully. I was unaware that one could disable the max instance from updating in windows, and I am sure to use this in the future. 

 

Cheers!

0 Likes