ScriptSpot

Forum topic · General Scripting

change name based on background image name

By cuatcside · 2014-12-10

Description

I have a camera in max file with background image assigned to it. how can I change the name of the camera to the first 3 letter of the background image file name?

For example if the background image is here: "c:\temp\test34.jpg"
the camera name will be "tes"

I tried this in maxscript listener but got stuck.

bg = backgroundimagefilename
x = filterstring bg "\ "
x[size(x)] <== this line is not working

Thanks for any help.

Comments (1)

.

miauu · 2014-12-11


(
	bgImagePath = "c:\\temp\\test34.jpg"
	bgImageName = getFilenameFile bgImagePath
	first3chars = bgImageName
	str = substring  bgImageName 1 3
	format "str: % \n" str
)