Set images as Background

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
SumitSethia's picture

Thanks

Will look into it.

miauu's picture

.

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's picture

.

Post the full code.

SumitSethia's picture

Full Code

--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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.