[Closed] Script to Create Target Camera Relative to Object
Ah! Just saw your post Denis. When I evaluate yours, I get a Runtime Error: ‘Unable to decode value: “9″”
But near as I can tell, my method works with the simple ‘move’ line… or am I missing something?
yes… you are missing that the camera has to be moved in the parent coordinate system… so your line has to be:
in coordsys parent move c [0,50,600]
i don’t understand why my code is not working… try this
try(destroydialog SpectatorCameraDialog) catch()
rollout SpectatorCameraDialog "Spectator Camera" width:200
(
local cameraname = "Spectator_Camera"
edittext cameraname_tx "Name:" text:cameraname fieldwidth:150 align:#right offset:[9,0]
button createcam_bt "Create Cameras" width:192 align:#right offset:[9,4]
on cameraname_tx changed text do
(
cameraname = text
)
on createcam_bt pressed do undo "Create Cameras" on
(
cams = for node in selection collect
(
name = node.name + "_" + cameraname
tm = (transmatrix [0, units.decodevalue "9\'\'", units.decodevalue "-5\'\'"])*node.transform
c = TargetCamera name:name target:(TargetObject name:(name + ".Target")) transform:tm parent:node
)
select cams
)
)
createdialog SpectatorCameraDialog
ah yes, I knew it was too good to be true. of course the extra ‘move’ line I added is relative to world coordinates, so it doesn’t work properly when people are seated at an angle… hm.
Nope! Still a runtime error. Now it says ‘Unable to decode value: “9’’”
Also, this code gives me the error: ‘No ““move”” function for undefined’
try(destroydialog SpectatorCameraDialog) catch()
rollout SpectatorCameraDialog "Spectator Camera" width:200
(
local cameraname = "Spectator_Camera"
edittext cameraname_tx "Name:" text:cameraname fieldwidth:150 align:#right offset:[9,0]
button createcam_bt "Create Cameras" width:192 align:#right offset:[9,4]
on cameraname_tx changed text do
(
cameraname = text
)
on createcam_bt pressed do undo "Create Cameras" on
(
cams = for node in selection collect
(
name = node.name + "_" + cameraname
c = TargetCamera name:name target:(TargetObject name:(name + ".Target")) lens:21.661 fov:79.4535 transform:node.transform parent:node
)
select cams
in coordsys parent move c [150,0,500]
)
)
createdialog SpectatorCameraDialog
here is it. it works now:
try(destroydialog SpectatorCameraDialog) catch()
rollout SpectatorCameraDialog "Spectator Camera" width:200
(
local cameraname = "Spectator_Camera"
edittext cameraname_tx "Name:" text:cameraname fieldwidth:150 align:#right offset:[9,0]
button createcam_bt "Create Cameras" width:192 align:#right offset:[9,4]
on cameraname_tx changed text do
(
cameraname = text
)
on createcam_bt pressed do undo "Create Cameras" on
(
cams = for node in selection collect
(
name = node.name + "_" + cameraname
tm = (transmatrix [0, units.decodevalue "9'", units.decodevalue "-5'"])*node.transform
c = TargetCamera name:name target:(TargetObject name:(name + ".Target")) transform:tm parent:node
)
select cams
)
)
createdialog SpectatorCameraDialog
yes it does! thank yeh kindly sir.
Now on to tutorials so I can learn what all this means!
Just put “in coordsys local” in front of “move”
Funny thread
EDIT: Oh, i missed the second page. So just ignore this