ScriptSpot

Forum topic · General Scripting

Move multiple selected objects by mouse position.

By remykonings · 2019-03-14

Description

Hi, This script (without the group code) works for a single selected object. I like it to work the same way with multiple objects. The way underneath doesn’t. I’d like some corrections if possible. Thank you

group selection name:"tempgroup"

tool objectPlacer numPoints:1
(
on freeMove do $tempgroup.pos = [gridPoint.x, gridPoint.y, $tempgroup.pos.z]
)
if selection.count == 1 do startTool objectPlacer

ungroup $tempgroup

Comments (2)

.

jahman · 2019-03-14

you can do it without grouping


(
	tool selectionMover numPoints:1
	(	
		local lastoffset
		local prevCenter = selection.center
		
		on freeMove do
		(
			if lastoffset != undefined do selection.center -= lastoffset
			offset = (gridPoint - prevCenter) * [1,1,0]
			selection.center += offset
			lastoffset = offset
		)
	)

	if selection.count != 0 do startTool selectionMover
)

*

remykonings · 2019-03-18

Thank you Jahman, I appreciate it :)