Notifications
Clear all

[Closed] move a selected group of objects to mouse point

ive been trying to figure out how to use the pick point function but im not sure if its appropriate.

if i have a selected group, i just want to move that group to the location of the mouse point on screen. would anyone be able to guide me down the right path for this?

thanks for any help guys!

5 Replies

What were you trying?

Maybe the problem you’re having is that the script is moving all objects inside the group as well


p=pickpoint()
sel=selection as array
for s in sel do
(
	if (isgroupmember s!=true) then 
	(
		s.pos=p
	)
)

J.

thanks for the reply. thats pretty similar to what ive tried typing in actually, but but when i execute the script and i have a selection, nothing acutally happens.

and for some reason now it works though i haven’t changed anything. odd. hopefully it will stay that way!

what im doing with it is placing an xref object thats imported at the click of the mouse point. the model gets moved properly. however, when i save the file, close it, and re open, all objects placed with the function apear at the world centre.

macroScript Quickmodel3 category:“Objects” tooltip:“xref Quickmodel3”
(
filename = maxFilePath + “quickmodels\03.max”
objectname = “house03”
New_Object = xrefs.addNewXrefobject filename objectname
p=pickpoint()
New_Object.pos=p
)

i’m really thinking about this problem as soon as but finally i found the the resualt
i made this code from one month and i hope it help you
this code you can move any object selected or for all objects in your scene
i made this code becouse someone give me the scene imported from autocad and the scene found in position more than [80000,60000,0] and after we working in the scene we found 3dsmax can’t render it… after that i made the code and solve this problem…

in this code:
-you can offset all objects in scene without seletion or for selection
-you can move the objects by make two click from the first clike to secound click or write the numbers you want in [x,y,z]
-you can save and load the file have the numbers you added it before
-import by the code to make move and import in the same time and merge too.


 --global obj_pckd_dis = undefined
 global main_clone = #()
 ---------------------------------------
 	rollout aboutscript "About Script"
 	(
 		label head1"Offset Scene"
 		bitmap AROMA_logo filename: "$UI\Icons\Slman_AromaLogo.bmp"
 		Hyperlink mail1 "hogo_bingo@hotmail.com" align:#center address:"mailto:info@brainstorm-me.com" color:(color 10 90 200) hovercolor:(color 255 0 0)
 		Hyperlink url1 "www.graphicaroma.com" align:#center address:"http://www.graphicaroma.com" color:(color 10 90 200) hovercolor:(color 255 0 0)
 
 
 
 	)
 --------------------------------------
 rollout ofstscen "Offset Scene"
 (
 	group "Define the Distance"
 	(
 		button gt_dst "Offset From To"
 	)
 	group "Offset Distance"
 	(
 		button lod_fil "Load Offset File"
 		spinner x_ofst "Offset in X" range:[-1000000000,1000000000,0] scale:1 align:#left width:200 type:#integer
 		spinner y_ofst "Offset in Y" range:[-1000000000,1000000000,0] scale:1 align:#left width:200 type:#integer
 		spinner z_ofst "Offset in Z" range:[-1000000000,1000000000,0] scale:1 align:#left width:200 type:#integer
 		button sav_fil "Save Offset File"
 	)
 	
 	group "Offset Objects"
 	(
 		checkbox ckb_sel "Offset For Selection"
 		button go_ofst ">>> >>> Offset Scene <<< <<<"
 	)
 	
 	group "Importing"
 	(
 	button mrg_obj "Merge File and Offset"
 	button imprt_obj "Import File and offset"
 	)
 	
 	on gt_dst pressed do
 	(
 		pt_1 = pickpoint()
 		pt_2 = pickpoint()
 		x_ofst.value = pt_2.x-pt_1.x
 		y_ofst.value = pt_2.y-pt_1.y
 		z_ofst.value = pt_2.z-pt_1.z
 	)
 	
 	on lod_fil pressed do
 	(
 		lod_input = getopenfilename caption:"Load Offset File" types:"Offset File (*.ofst)|*.ofst"
 		try (input_file = openfile lod_input)catch()
 		if input_file != undefined do
 		(
 			x_ofst.value = readvalue input_file
 			y_ofst.value = readvalue input_file
 			z_ofst.value = readvalue input_file
 			close input_file
 		)
 	)
 	
 	on go_ofst pressed do
 	(
 		if ckb_sel.state == false then
 		(
 			progressStart "Starting Offset All Objects"
 			undo on
 			(
 				mov_objs = for i in objects collect i
 				curiter = 0
 				itemnum = mov_objs.count
 				for i in mov_objs do
 				(
 				if i.parent == undefined do
 					(
 						curiter += 1
 						m = ((curiter as float)/(itemnum as float))*100
 						move i [x_ofst.value,y_ofst.value,z_ofst.value]
 						progressUpdate m
 					)
 				)
 				mov_objs = undefined
 			)
 			progressEnd()
 		)
 		else
 		(
 			progressStart "Starting Offset All Objects"
 			undo on
 			(
 				mov_objs = for i in Selection collect i
 				curiter = 0
 				itemnum = mov_objs.count
 				for i in mov_objs do
 				(
 				if i.parent == undefined do
 					(
 						curiter += 1
 						m = ((curiter as float)/(itemnum as float))*100
 						move i [x_ofst.value,y_ofst.value,z_ofst.value]
 						progressUpdate m
 					)
 				)
 				mov_objs = undefined
 			)
 			progressEnd()
 		)
 	)
 	
 	on sav_fil pressed do
 	(
 		sav_output = getsavefilename caption:"Save Offset File" types:"Offset File (*.ofst)|*.ofst"
 		out_file = try (createfile sav_output)catch()
 		if out_file != undefined then (format "%,%,%" x_ofst.value y_ofst.value z_ofst.value to:out_file)
 		if out_file != undefined then close out_file
 	)
 	
 	on ckb_sel changed state do
 	(
 		if ckb_sel.state == true then go_ofst.text = ">>> >>> Offset Selection <<< <<<"
 		else (go_ofst.text = ">>> >>> Offset Scene <<< <<<")
 	)
 	
 	on mrg_obj pressed do
 	(
 		--mrg_fle = getmaxfilename --#select--caption:"Get Others Objects to Offset it"
 		
 		max file merge
 		progressStart "Starting Merge and Offset All Objects"
 		mrg_objs = for i in selection collect i
 		curiter = 0
 		itemnum = mrg_objs.count
 		for i in mrg_objs do
 		(
 			if i.parent == undefined do
 			(
 				curiter += 1
 				m = ((curiter as float)/(itemnum as float))*100
 				move i [x_ofst.value,y_ofst.value,z_ofst.value]
 				progressUpdate m
 			)
 		)
 		mrg_objs = undefined
 		progressEnd()
 	)
 	
 	on imprt_obj pressed do
 	(
 		max file import
 		progressStart "Starting Import and Offset Objects"
 		imprt_objs = for i in selection collect i
 		curiter = 0
 		itemnum = imprt_objs.count
 		for i in imprt_objs do
 		(
 			if i.parent == undefined do
 			(
 				curiter += 1
 				m = ((curiter as float)/(itemnum as float))*100
 				move i [x_ofst.value,y_ofst.value,z_ofst.value]
 				progressUpdate m
 			)
 		)
 		imprt_objs = undefined
 		progressEnd()
 
 	)
 	
 )
 --------------------------------------
 --------------------------------------
 rollout Aboutme "About Me" 
 (
 	label Script_name_label "Offset Scene v2.0" align:#center
 	label by_label "by" align:#center
 	label my_name_label "Abdelsalam Ahmed" align:#center
 	HyperLink email_label "hogo_bingo@hotmail.com" align:#center address:"mailto:hogo_bingo@hotmail.com" color:(color 10 90 200) hovercolor:(color 255 0 0)
 	label copyright_label "Copyright© 2007 AROMA" align:#center
 )
 
 
 -- create the rollout window and add the  rollout
 if OffsetSceneFloater!= undefined do
 				(
 				closerolloutfloater OffsetSceneFloater
 				)	
 
 OffsetSceneFloater = newRolloutFloater "Offset Scene v2.0" 270 400 1000 50
 
 addRollout aboutscript	OffsetSceneFloater rolledup:true
 addRollout ofstscen	OffsetSceneFloater
 addRollout Aboutme OffsetSceneFloater rolledUp:true
 
 

the best thing in code is it can move any thing like the group and the biped and the linked object the code have a filter to the child object becouse if we move all the child will move by the parent and move agian by itself…

enjoy

nice work. thanks for sharing! i should be able to find some handy stuff in there. so what part in there is it that gets around the saving problem im having do you think?

or am i having a completely different problem?