Notifications
Clear all

[Closed] Bone Mirrorring through MaxScript

hum… it doesn’t always work well with ik but bone chain should be fine


(
--//-- 
--//-- select a bone chain including ik and run the script.
--//--
fn XMirror = 
	(
	local Xhwnd=dialogMonitorOps.getWindowHandle()
	local Xstring=UIAccessor.GetWindowText Xhwnd
	--//--
	if Xhwnd != undefined then 
		(
		if Xstring != undefined and (findString Xstring "Mirror") != undefined then 
			(
			UIAccessor.PressButtonByName Xhwnd "X"
			UIAccessor.PressButtonByName Xhwnd "Instance"
			UIAccessor.PressDefaultButton()
			)
		)
	true
	)
--//--
if selection.count != 0 then 
	(
	dialogMonitorOps.registerNotification XMirror id:#findmirror
	dialogMonitorOps.enabled=true
	--//--
	disableSceneRedraw()
	max mirror
	--//--
	dialogMonitorOps.unregisterNotification id:#findmirror
	dialogMonitorOps.enabled=false
	--//--
	Newselection=selection as array
	--//--
	for f in 1 to selection.count do (max select parent)
	--//--
	for f in selection do
		(
		InstanceMgr.GetInstances f &x
		for i in x where (i != f) do f.pos.x=-i.pos.x
		)
	--//--
	select Newselection
	--//--
	for f in selection do
		(
		InstanceMgr.GetInstances f &x
		for i in x where (i != f) do f.name=(i.name+"_Mirror")
		)
	--//--
	InstanceMgr.MakeObjectsUnique Newselection #group
	enableSceneRedraw()
	)
--//--
)

added enable\disable scene redraw but we still see the mirror dialog showing up … so it all depend if you need speed or not :shrug:

 JHN

I see know what I did wrong, it was in the dir of the newBone, I should have multiplied the dir vector with the mirror axis, so -lBone.dir should have been (lBone.dir * [-1,1,1]) this effectively mirrors the direction on X, Matan is doing it in his example, but he’s missing the stretch component in calculating the bone lenght. But now should have plenty of options too choose from!

Cheers,
-Johan

Great it works!

Thanks a lot guys

While i’m here question for you guys, if you don’t mind.
Looking at martroyx (QuebecPower) script i could see that he used these command…
disableSceneRedraw()
enableSceneRedraw()
I believe this is to make you script run faster, but i’m not sure exactly how and when to use it in a script. If anyone is kind enough to explain that would be appreciated, if not it’s all good you guys helped me a lot already.

Have a good one and thanks again all

Hi Guibou,

you disableSceneRedraw() when you need the viewport to stop doing refresh, this way you can select and move stuff around without 3dsmax having to draw those operation… just remember to enableSceneRedraw() when you are done

martin

Page 2 / 2