Mirror script

Hello everyone,
I have made a script that replaces the default 3ds max Mirror tool, and I need some help. I'm working with containers, so I want be able to mirror the parent container and all of its contents along a chosen axis. Now the problem is that I don't know how to make the whole selection mirror the exact distance from the objects to the parent container's pivot in the opposite direction (just like the default mirror tool does). You can see what I mean from the images below.

Any help would be greatly appreciated.

This is the code I've got so far:

macroScript waRp_Mirror
category:"waRp Tools" 
buttonText:"waRp Mirror"
tooltip:"waRp Mirror"
icon:#("warp_tools_mirror",1)
(
	rollout waRp_Mirror "waRp Mirror" width:144 height:202
	(
		groupBox gb_axis "Axis" pos:[8,11] width:127 height:45
		radioButtons rb_axis "" pos:[22,28] width:97 height:16 labels:#("X", "Y", "Z") columns:3
		groupBox gb_clone "Clone Selection" pos:[9,67] width:127 height:60
		radioButtons rb_clone "" pos:[20,86] width:64 height:32 labels:#("Copy", "No Clone") columns:1
		checkbox cb_collapse "Collapse All" pos:[11,136] width:80 height:20 checked: true
		button btn_mirror "Mirror" pos:[41,163] width:61 height:25
 
		on btn_mirror pressed  do
		(
			--prvo removeTurbo pa collapsni go poly-to
			macros.run "waRp Tools" "waRp_RemoveTurbo"
 
			local selNodes = getCurrentSelection()
			local newNodes
 
			--- CLONE SELECTION ---
			if rb_clone.state == 1 then
			(	
				maxOps.clonenodes $ cloneType:#copy newNodes:&newNodes
 
			    select NewNodes
				ConvertToPoly(selection)
			)
			else
				ConvertToPoly(selection)
			--- ---
 
			--- XFORM MODIFIER ---
			myXform= xform()
			myxform.gizmo.scale=[-1,-1,-1]
			if rb_axis.state == 1 then
			  myxform.gizmo.rotation += quat 1 0 0 0 
			else if rb_axis.state == 2 then
			(
			  myxform.gizmo.rotation += quat 1 0 0 0 
			  myxform.gizmo.rotation += quat 0 0 1 0 
			)
			else
			  myxform.gizmo.rotation += quat 0 0 1 0 
 
			modpanel.addModToSelection(myXform)
			--- ---
 
			--- NORMAL MODIFIER ---
			myNormal = Normalmodifier()
			myNormal.flip=true
			modPanel.addModToSelection(myNormal)
			--- ---
 
			-- collapse objects
			if cb_collapse.checked then
			  ConvertToPoly(selection as array) 			
 
 
			DestroyDialog waRp_Mirror
		)
	)
	on execute do
	(
		if selection.count >= 1 then
			createDialog waRp_Mirror
		else
			messagebox "Select at least one object!" title: "waRp Mirror"
	)
)
AttachmentSize
1.jpg700.96 KB
2.jpg707.03 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

try this fn

-- ARGUMENT OPTIONS
-- axis enums: {#x|#y|#z}. Default X-Axis
-- center (miiror about point3) also you can use any object center. Default: world center
-- clone enums: {#copy|#instance|#reference}. Default instance
 
fn mirrorSelection axis:#x center:[0,0,0] clone:#instance = if selection.count != 0 do
(	
	local ax = case axis of (
		(#x): [-1,1,1]
		(#y): [1,-1,1]
		(#z): [1,1,-1]
	)
	local parentslist = #()
	maxOps.CloneNodes (selection as array) offset:[0,0,0] cloneType:clone newNodes:&clones
	for i in clones do (append parentslist i.parent ; i.parent = undefined)
	about center scale clones ax
	for i = 1 to clones.count do clones[i].parent = parentslist[i]
	free parentslist
)
mirrorSelection()

bga

zarko's picture

Thank you

Great! Simple and effective :D
Thanks barigazy

cage-warp.deviantart.com

barigazy's picture

;)

My pleasure, neighbor. Skopje is not to far from Niš(Serbia)

bga

zarko's picture

Ha ha, yes, I wasn't aware

Ha ha, yes, I wasn't aware that you were from Serbia :)

cage-warp.deviantart.com

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.