How to delete diffuse bitmap with none texture by maxscript
i donāt understand clear what you want, but ⦠maybe here is what you ask for:
fn deleteUnresolvedBitmatextures =
(
txts = getclassinstances bitmaptexture astrackviewpick:on
for txt in txts where try(txt.anim.bitamp) catch() == undefined do
(
txt.client[txt.subnum].value = undefined
-- or
-- refs.replaceReference txt.client txt.subnum undefined
)
)
i want to remove map where have (JPGE File ) ā this is a bitmap file but it not have filename , i want to remove all (JPGE File ) in my material
thank your for your quick reply , my english is bad and i use google translate
best regard
do you want to delete any bitmaptexture if it contains nonexistent filename?
itās almost the same as āitās bitmap canāt be openedā⦠the function i posted above has to do the job.
here is another one:
fn deleteTextureIfNotExists =
(
txts = getclassinstances bitmaptexture astrackviewpick:on
for txt in txts where not (doesfileexist txt.anim.filename) do
(
txt.client[txt.subnum].value = undefined
-- or
-- refs.replaceReference txt.client txt.subnum undefined
)
)
please tell in advance if you are new to MXS
it not work , i can give you my 3dsmax file here
https://drive.google.com/open?id=16zrCDmXWJOtasd4FTUSyNWdUROT0FHu7
i create a simple maxcript :
nullObject = bitmaptex()
txts = getclassinstances bitmaptexture
for i = 1 to txts.count do
(
if (txts[i].filename == "") do (replaceInstances txts[i] nullObject )
)
it work , but thank you verymuch
best regard
If there is a bitmap that has multiple instances, the first encounter will modify it and the other instances to be the ānullObjectā, right? Then the loop carries on through the original array of bitmaptextures, some of which are now no longer used. Is this one of the logic mistakes?
Honestly Iām struggling to see the other logic mistakes but Iām really curious and enjoy learning from your replies @denisT
Could you give a hint to the other mistakes?
the mistake N1 - is the using absolutely valid bitmap texture object in meaning of NULL object. Itās a beginning of troubles for another two.
ānullobjectā as i said is absolutely valid object but has undefined filename. itās filename value is an empty string (""). So when we replace a texture map with empty filename using the condition " <>.filename == āā " we replace it again with an empty texture map. The replacement doesnāt make sense, and the process itself is endless.
This is the mistake N2
And another one, you are right, we replace all unique (not instanced) empty texture maps with an instance. So all originally different objects become the same in this case. What was not the initial goal at all.
Correction of this collision will be significantly more difficult than the initial problem.
This is the N3.
