View Full Version : getting dependents of asset
I am looking for a way to get an array of nodes that are dependent on a certain filename, similar to the functionality of the 'info' button in the bitmap/photometric paths utility.
Is this possible, or do I have to traverse all objects/materials/map slots in a scene and ask them specifically is they are using this asset?
|
|
I'm thinking it is the latter but I have not tried this sort of thing in a while.
Can you be a bit more specific to what type of asset you need to reference to. refs.dependentnodes on the right asset type can go a long way. But it dependents a bit on what type of file you are looking for. Is it materials or displacement modifiers etc?
And what version of max?
-Johan
Can you be a bit more specific to what type of asset you need to reference to. refs.dependentnodes on the right asset type can go a long way. But it dependents a bit on what type of file you are looking for. Is it materials or displacement modifiers etc?
And what version of max?
-Johan
ideally all assets, but let's assume that we're just talking about materials, so I'll try to understand what your are going for...I tried all the refs. commands on a bitmap file, and didn't get any results
version is Max2009
Take a look at this code
(
fn getFileRefs objArray =
(
struct refStr ( obj, files = #())
local returnArray = #()
for obj in objArray do
(
local ref = refStr obj:obj
if obj.material != undefined do
(
ATSOps.GetDependencyFileList obj.material &filelist true
join ref.files filelist
)
if obj.modifiers.count > 0 do
(
for i = 1 to obj.modifiers.count do
(
ATSOps.GetDependencyFileList obj.modifiers[i] &filelist true
join ref.files filelist
)
)
append returnArray ref
)
returnArray
)
local result = getFileRefs (selection as array)
print result
)
It's probably not getting all area's of where a asset can hide. Max 2010 has a new asset user interface and I was hoping I could would somehow get the dependencies of a assetuser interface, but I couldn't and since you're using max 2009 it wouldn't work either. So the above code searches in modifiers and materials for assets. Probably multimaterial wouldn't work, but should be easy enough to to add.
Hope it's of some help,
-Johan
Thanks very much for your time and effort, I will give your method a try.
I've tested your code and the one thing that really surprised me is that the ATSOPS.GetDependencyFileList method is working in max2009 even though it is only documented in max2010!
Unfortunately it does not seems to correctly identify missing assets in neither version of max, which is the purpose I needed it for in the first place :(
I will continue trying and post results if I have any.
denisT
04-05-2010, 03:50 PM
I am looking for a way to get an array of nodes that are dependent on a certain filename, similar to the functionality of the 'info' button in the bitmap/photometric paths utility.
Is this possible, or do I have to traverse all objects/materials/map slots in a scene and ask them specifically is they are using this asset?
if you are looking for bitmap files you can use enumerateFiles (see MXS help)
enumerateFiles [<maxwrapper_obj>] <function> [<arg>] [#inactive] [#videoPost] [#render] [#missing] [#localOnly] [#skipCustAttributes] [#skipVPRender] [#firstSubOnly]
Thanks, Dennis! I forgot about the optional maxwrapper_obj argument in enumerateFiles. I will give it a try.
Works great! Thanks again.
CGTalk Moderation
04-05-2010, 07:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.