macroScript ExtensionChange
category:"jb_scripts"
ButtonText:"TexExtensionChange"
Tooltip:"TexExtensionChange"
(--macro begins
local TexExtensionChange
(
fn GetBitmapTextures theObjects =
(
texMaps = #()
for obj in theObjects do
(
join texMaps (getClassInstances bitmapTexture target:obj asTrackViewPick:off)
)
makeUniqueArray texMaps
)
texMaps = (GetBitmapTextures objects)
fn changeOutExt inExt outExt =
(
for texMap in texMaps do (
objName = getFilenameFile texMap.filename
-- remove the point in string
inExt = trimleft inExt "."
outExt = trimleft outExt "."
-- add a point and change the extension
inex = "."+inExt
if getFilenameType texMap.filename == inex do texMap.filename = (objName + "." + outExt)
)
)
)
rollout TexExtensionChange "Tex Extension Change"
(
label lbl1 "Change Texture Extension" pos:[10,6] width:193 height:20
editText edt1 "from" pos:[11,27] width:90 height:20
editText edt2 "to" pos:[115,27] width:90 height:20
button btn1 "Change" pos:[219,27] width:130 height:20
on btn1 pressed do (
with undo on
(
changeOutExt edt1.text edt2.text
)
)
button btn2 "Condense Material Editor" pos:[219,54] width:130 height:20
on btn2 pressed do (
with undo on
(
defaultMtlLibFile = MeditUtilities.getDefaultLibraryFile()
if defaultMtlLibFile != undefined do
(
defaultMtlLib = loadTempMaterialLibrary defaultMtlLibFile
usedMtls = #()
for i in 1 to meditMaterials.count do
(
if MeditUtilities.isMaterialInUse meditMaterials[i] == true do
append usedMtls meditMaterials[i]
)
global _meditMaterialsBeforeReset = #()
for i in 1 to meditMaterials.count do
(
append _meditMaterialsBeforeReset meditMaterials[i]
if i <= usedMtls.count then
meditMaterials[i] = usedMtls[i]
else if i <= defaultMtlLib.count then
meditMaterials[i] = defaultMtlLib[i]
else
meditMaterials[i] = defaultMtlLib[defaultMtlLib.count]
)
)
)
)
)
createDialog TexExtensionChange 356 80
)--macro end