[Closed] a way to collect maps by bitmap?
Is there any way to build an array of maps based on a particular bitmap? Almost like a “getOwner this” type of thing? Or maybe something with refs.dependents?
The only way I’ve been able to accomplish this in the past is to cycle through all the materials and maps in the scene and run IF statements checking for classOf map == bitmaptexture and then checking the bitmap.filename. It’s a horribly inefficient way to accomplish this, but I’ve not been successful finding anything in the maxscript reference that’s faster.
Does anyone have any suggestions?
Thanks!
Bitmap is not a max object. So any methods those use dependency check can’t help you. What do want to do with these found Bitmaps (filenames)? The knowing of it might help to find the better search method.
Try getClassInstances() instead.
Obviously, you will still have to call it once for each class you want (bitmapTexture is not necessarily the only map in Max that can have a bitmap, esp. if you are using VRay).
As an example, suppose you wanted to switch out all occurances of “abc.jpg” with “xyz.jpg”.
One way is to sort through all the materials and all the maps, and find all the occurances of “abc.jpg” and then just switch the bitmap.filename. But I would have to assume that if there’s a way to just access the “parent(s)” of that bitmap, the task could be completed much faster… or at least in a way that you know you’re not skipping over anything. Because when you sort through all the materials and all the maps, you have to be very sure you’re checking ALL the material types (standard, vray, multi-sub, blend, etc.) and all the different map types…
know what I mean?
I think first of all you have to narrow the searching area. For example exclude all materials those don’t have the searching files.
You can use something like:
fn getEnumeratedFiles node pattern: = if iskindof node MAXWrapper do
(
fn addFile file list pattern:pattern =
(
if pattern == unsupplied or matchpattern file pattern:pattern do appendifunique list file
)
local files = #()
enumerateFiles node addFile files
files
)
where <node> attribute is any maxwrapper that potentially can have the files (object, material, texturemap, modifier, ca, etc.).
After that go deeper and deeper into this node:
getSubMtl, getSubTexmap for materials;
getSubAnim for something else;
etc.
or search for all properties which classof Bitmap. That’s my plan.
if you exactly know that searching bitmap(s) can be inside texturemaps only, or might be used by some material class you can use above mentioned getClassInstances function.