ScriptSpot

Forum topic · General Scripting

Set images as Background

By SumitSethia · 2016-12-31

Description

Hey Guys,

I'm have 15 cameras of a building for different view with background images for each camera. So i was trying to create a script which basically give a list of all the cameras in the scene and when i selected any camera it will set the camera on the active viewport with background image.

selCam = CameraList.selected
setCam = getNodeByName CameraList.selected
viewport.setCamera setCam
count = selCam.count
setNewCam = (substring selCam 1 (count - 4))
dir = ("D:\Projects\buildingImages\\" + setNewCam + ".jpeg")
backgroundimagefilename = dir
viewport.DispBkgImage = true
completeRedraw()

The problem is that when i click on the camera it do set the background image for that active viewport but it reset all the other viewport with a new background images.

Comments (5)

Thanks

SumitSethia · 2017-01-05

Will look into it.

.

miauu · 2017-01-04

It seams that this bug can;t be solved using pure maxscript.

This code works the same way - all viewports are reset.


(
	bmpImg = bitMapTexture()
	bmpImg.fileName = "D:\\Projects\\Test\\Camera004.jpg"
	setAsBackground bmpImg.bitmap
	viewport.DispBkgImage = true
)

The only solution that I can think of is to use UIAccessors and to set the img to active viewport in a way like this script works: http://www.scriptspot.com/3ds-max/scripts/change-viewport-statistic

.

miauu · 2017-01-03

Post the full code.

Full Code

SumitSethia · 2017-01-04

--Destroy dialog if it already exists.
try(destroyDialog CameraManager)catch()

global CameraManagerFloater
global cameraNames = #()

fn refreshFN = (
CameraList = #()
cameraNames = #()
j = 1
for i in cameras do
(

if classOf cameras[j] == Freecamera do
(
append CameraList i
append cameraNames i.name
)
j = j +1
)
)

rollout CameraManager "Camera Manager" width:260
(

listbox CameraList "Select Camera" width:240 height:16 items:cameraNames

--actions

on CameraManager open do
(
refreshFN()
CameraList.items = cameraNames
)
on CameraManager close do
(

)
on CameraList selected sel do
(
selCam = CameraList.selected
setCam = getNodeByName CameraList.selected
viewport.setCamera setCam
count = selCam.count
setNewCam = (substring selCam 1 (count - 4))
dir = ("D:\Projects\Test\\" + setNewCam + ".jpeg")
backgroundimagefilename = dir
viewport.DispBkgImage = true
completeRedraw()
)
on CameraManager doubleClicked tempItem do
(

)

)

--Create a dialog and assign the rollout to it.
createDialog CameraManager

eliscio · 2019-01-11

I would like to have a small window where I can assign a background image to each respective camera that I have in a scene. I am avoiding using image planes. Anything in existence that can do that?

I tried this script but still not working.

Thanks