macroscript ScanPlugins category:"Bobo_s Tools"
(

--Scan Plugins
--Version 0.11
--Started: 2/16/2000
--Edited:  4/30/2000
--by Borislav Petrov
--http://gfxcentral.com/bobo/
--------------------------------------------------

global plugscan_float

fn collect_subs my_node =
(
subanims_array = #(my_node)

i = 0

while i < subanims_array.count do
(
i +=1
for j = 1 to subanims_array[i].numsubs do
	(
	append subanims_array subanims_array[i][j]
	)
)
subanims_array
)


fn collect_subdirs start_path =
(
paths_array = #(start_path)
i = 0
while i < paths_array.count do
(
i +=1
try(sub_paths = getDirectories (paths_array[i]+"*"))catch(exit)
if sub_paths.count > 0 then join paths_array sub_paths 
)
paths_array
)


rollout plugscan_roll "Scan Files For Classes"
(
edittext file_name text:"Ready." width:165 align:#center offset:[-2,0]
progressbar dir_progress height:10 width:160 align:#center color:(color 155 0 0)
progressbar show_progress height:10 width:160 align:#center color:(color 0 0 155)
button start_search "START SCAN" width:160 height:30 align:#center

on start_search pressed do
(

start_dir = getSavePath caption:"Select ROOT to scan for MAX Files"

if start_dir != undefined then
(

num_files = getFiles (start_dir+"\\plugins_scan*.log")
out_filename = (start_dir+"\\plugins_scan"+ ((num_files.count+1) as string) +".log")

out_file = createfile out_filename

format "=====================================================\n" to:out_file 
format "MAX PLUGINS SCAN Version 0.11 \n" to:out_file 
format "(c) 2000 by Borislav Petrov \n" to:out_file 
format "\n" to:out_file 
format "DATE: % \n" localtime to:out_file 
format "ROOT SCAN DIRECTORY: % \n" start_dir to:out_file 
format "=====================================================\n" to:out_file 

all_files = #()
scan_dirs = collect_subdirs start_dir 
for d in scan_dirs do
(
try
(
search_files = getFiles (d+"*.max")
)
catch(search_files = #())
join all_files search_files
)--end d



for f = 1 to all_files.count do
(
file_name.text = getfilenamefile all_files[f]
dir_progress.value = (100.0*f/all_files.count)

result = loadMaxFile all_files[f]
if result then
(
format "\n" to:out_file 
format "=====================================================\n" to:out_file 
format "MAX FILE NAME: % \n" all_files[f] to:out_file 
format "=====================================================\n" to:out_file 

cls_array =#()

counter = 0
show_progress.value = 0
scene_objects = $* as array
for o in scene_objects do
(
counter += 1
show_progress.value = (100.0*counter/scene_objects.count)
subs = collect_subs o
for i in subs do
(
try
(
cls = (classof i.object)
if cls != UndefinedClass and cls != SubAnim and findItem cls_array cls == 0 then 
(
format "Class:      % \n" cls to:out_file 
format "Superclass: % \n" (superclassof i.object) to:out_file 
format "ClassID:    % \n" (i.object.classid) to:out_file 
format "_____________________________________________________\n" to:out_file 
append cls_array cls
)--end if 
)
catch()
)
)--end o loop
)--end if
)--end f loop
format "\n=====================================================\n" to:out_file 
format "END OF FILE % \n" start_dir to:out_file 
format "=====================================================\n" to:out_file 

show_progress.value = 0
dir_progress.value = 0
close out_file
edit out_filename
)--end
file_name.text = "Ready."
)--end on

)--end roll


try(closerolloutfloater plugscan_float)catch()
plugscan_float = newrolloutfloater "SCAN PLUGINS" 200 155 100 100
addrollout plugscan_roll plugscan_float

)--end script