Notifications
Clear all

[Closed] Setting vertex normal

Hello everyone,
is there a way to set vertex normal without Edit_Normals modifier? I can do it with this modifier, but it takes forever to process bigger group of objects, because it works only when the object is selected and max is in modify mode, take a look:

--creating planes
planes = #()
for i = 0 to 49 do
(
	append planes (plane lengthsegs:1 widthsegs:1 width:10 length:10 pos:[i*11,0,0])
)

max modify mode

for p in planes do
(
	--without select p it does not work!
	select p

	addModifier p (EditNormals())
	for i = 1 to 4 do
	(
		p.modifiers[#Edit_Normals].setNormal i [(random -1 1), (random -1 1), (random -1 1)]
		p.modifiers[#Edit_Normals].EditNormalsMod.Select #{i}
		p.modifiers[#Edit_Normals].EditNormalsMod.MakeExplicit()
	)
)

Any tips?

5 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s slow but might be faster by just better using of MXS

fn setCommandPanelRedraw act = 
(
	WM_SETREDRAW = 0x000B
	windows.sendmessage (windows.getchildhwnd #max "Command Panel")[1] WM_SETREDRAW act 0
)

delete objects
with redraw off
(
	num = 100
	planes = for k=1 to num collect (plane lengthsegs:1 widthsegs:1 width:10 length:10 pos:[(mod (k-1) 10)*11, (k-1)/10*11, 0])

	seed 0 
	setCommandPanelRedraw 0
	max modify mode
	select planes
	norm = EditNormals()
	modpanel.addmodtoselection norm
	for p in planes do
	(
		nn = #{1..norm.GetNumNormals node:p}
		for n in nn do norm.setNormal n (normalize (random [-1,-1,-1] [1,1,1])) node:p
		norm.MakeExplicit selection:nn node:p
	)
	setCommandPanelRedraw 1
	select selection
	completeredraw()
)

but sure… with SDK the same task takes almost nothing.

yes you can use the sdk to extend mxs…

and … if you will do all Edit_Normals operations with disabled ref-messaging it will be much faster.

denisT, thanks for that, it works like 10 times faster now! What do you mean by “ref-messaging”?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

search this forum for my posts with a key “disableRefMsgs()”