Notifications
Clear all

[Closed] EditNormals.Specify() always causes exception

Specify command of EditNormals modifier never works when it’s triggered by MaxScript.
There’s always an EXCEPTION_ACCESS_VIOLATION occurred:

Here is a simple script to reproduce (generated by macro recorder record action: create teapot > add editNormals modifier > select all normals > click Specify):

Teapot pos:[0,0,0] isSelected:on radius:22.8291 segs:4
modPanel.addModToSelection (Edit_Normals ()) ui:on
actionMan.executeAction 0 "40021"
$.modifiers[#Edit_Normals].EditNormalsMod.SetSelection #{1..530}
$.modifiers[#Edit_Normals].EditNormalsMod.Specify ()
$.modifiers[#Edit_Normals].EditNormalsMod.SetSelection #{}

I’ve tested with Max 2018, 2020.3 on two different PC but still the same problem.

Probably a 3ds Max bug, does anyone know workaround to use EditNormals Specify command with MaxScript?

3 Replies

the source code suggest it’s only valid for editable poly only so…

delete objects
poly = ConvertToPoly(Teapot pos:[0,0,0] isSelected:on radius:22.8291 segs:4)
--modPanel.addModToSelection (Edit_Normals ()) ui:on
addModifier  poly (Edit_Normals ())
actionMan.executeAction 0 "40021"
$.modifiers[#Edit_Normals].EditNormalsMod.SetSelection #{1..530}
$.modifiers[#Edit_Normals].EditNormalsMod.Specify ()
$.modifiers[#Edit_Normals].EditNormalsMod.SetSelection #{}

works

if you can recompile the source then…

bool ret = pData->GetPolyNormals()->SpecifyNormals (mSelLevel, normalSelection);
// Also clear the explicitness of these normals:
if (pData->GetPolyNormals()->MakeNormalsExplicit (mSelLevel, normalSelection, false)) {
	ret = true;
	pData->InvalidateGeomCache();
}

should be replaced with something like…

bool ret;
if (pData->GetFlag (ENMD_TRIMESH)) 
{
	ret = pData->GetTriNormals()->SpecifyNormals (mSelLevel, normalSelection);
	// Also clear the explicitness of these normals:
	if (pData->GetTriNormals()->MakeNormalsExplicit (mSelLevel, normalSelection, false)) {
		ret = true;
		pData->InvalidateGeomCache();
	}

}
else
{
	ret = pData->GetPolyNormals()->SpecifyNormals (mSelLevel, normalSelection);
	// Also clear the explicitness of these normals:
	if (pData->GetPolyNormals()->MakeNormalsExplicit (mSelLevel, normalSelection, false)) {
		ret = true;
		pData->InvalidateGeomCache();
	}
}

will fix it for you in the

bool EditNormalsMod::EnfnSpecifyNormals (BitArray *normalSelection, INode *pNode) 

function in the file EditNormals.cpp

@Klvnk Thanks a lot! Convert to poly before calling specify worked.

About source compiling, where can I find the source to recompile it?

you need to install the SDK (should be part of the max installation) and the correct version of Visual Studio.