Notifications
Clear all

[Closed] How to delete diffuse bitmap with none texture by maxscript

please help me , it very important to me

9 Replies

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

1 Reply
(@denist)
Joined: 10 months ago

Posts: 0

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 this is a null object, the word ‘delete’ in your context means apply

here are four lines of code and three logical mistakes. Who can find them all?

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?

1 Reply
(@denist)
Joined: 10 months ago

Posts: 0

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.

Cool, all clear – thanks!