Hello, I'd love to have some help with the following script. It is an important way we place objects in a scene at our office.
The majority of the code is actually there (already because of many of you) but i like to tie it together with this script and there are some issues that still need to be resolved. De script contains:
1. a button for placing one or multiple objects through my mouse position (this works well already).
2. a spinner which should adjust the z=value when placing objects (default value should be 0).
3. a button to take the z-value of a selected object that is already in the scene and use that value to replace the default 0 value of the spinner (so it can be used to place something on that specific height again).
One of the issues that i also ran into before was that when i had an object which was already on a certain z-value, is that the mouse position is still at z=0, while x and y are based on my mouse position. So what i would like is when i place an object at z=300 through the spinner, that my cursor actually uses the right z=value, instead of staying at z=0.
I hope it makes sense :) and hopefully some of you could help me out.
Thank you!
-- SCRIPT
rollout rollout3 "Placement"
(
button placeObjects "Place" tooltip:"Place the selected objects" width:90 across:3
spinner amount "" type:#integer range:[-10000,10000,0] width:80 align:#center
button useHeight "Use Height" tooltip:"Use the height of a selected object" width:90
on placeObjects pressed do (
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
)
on useHeight pressed do (
if selection.count == 1 do amount.value = selection[1].pos.z
)
)
RolloutFloaterTemplate = newrolloutfloater "Workflow" 319 58
addrollout rollout3 RolloutFloaterTemplate