-- dw Texture Usage 1.0 -- dim_walker@mail.ru -- www.dimwalker.com ( result = #() fn compareFN v1 v2 col: = ( case of ( (v1[col] < v2[col]): -1 (v1[col] > v2[col]): 1 default: 0 ) ) fn fill_result = ( local st = timestamp() local currmat = meditmaterials[medit.GetActiveMtlSlot()] local subs = currmat.materialIDList local subsIDList local subsIDList = #() for i = 1 to currmat.numsubs do ( append subsIDList i ) result = #() for i = 1 to currmat.numsubs do ( append result 0 ) for i = 1 to subs.count do ( result[subs[i]] = #(0,0,0,0) result[subs[i]][1] = 0 result[subs[i]][2] = subs[i] result[subs[i]][3] = (getSubMtl currmat subs[i]).name result[subs[i]][4] = (getSubMtl currmat subs[i]).maps[2].filename ) for k in selection do( if classof k == Editable_Poly and k.mat == meditmaterials[medit.GetActiveMtlSlot()] do ( local thepoly = k local totalfaces = thepoly.getNumFaces() for i = 1 to totalfaces do ( local polyid = thepoly.GetFaceMaterial i local curarea = polyOp.getFaceArea local mod1 = mod polyid subsIDList.count if (mod1 == 0) then realid = subsIDList.count else realid = subsIDList[mod1] --format "polyid - %\t realid - %\t i - %\t mod1 - %\n" polyid realid i mod1 result[realid][1] += ((curarea thepoly i)/10000) ) ) ) local et = timestamp() format "done in % sec\n" ((et-st)/1000.0) ) fill_result() rollout listview_rollout "Texture Usage" ( on listview_rollout close do gc() fn initListView lv = ( lv.gridLines = true lv.View = (dotNetClass "System.Windows.Forms.View").Details lv.fullRowSelect = true lv.BorderStyle = FixedSingle -- None, Fixed3D lv.LabelEdit = false layout_def = #(#("Area", 2000),#("id", 1000),#("Material Name", 3500)) for i in layout_def do ( column = lv.Columns.Add i[1] ) ) fn fillInSpreadSheet lv = ( local currmat = meditmaterials[medit.GetActiveMtlSlot()] local subs = currmat.materialIDList theRange = #() for i = 1 to subs.count do ( li = dotNetObject "System.Windows.Forms.ListViewItem" ((result[subs[i]])[1] as string) sub_li = li.SubItems.add ((result[subs[i]])[2] as string) sub_li = li.SubItems.add ((result[subs[i]])[3] as string) append theRange li ) lv.Items.AddRange theRange ) imgtag it_matpreview "mat_preview" pos:[5,5] width:100 height:100 bitmap:(openbitmap result[1][4]) transparent:(color 0 255 255) across:2 dotNetControl lv_objects "System.Windows.Forms.ListView" pos:[110, 5] width:300 height:190 --align:#left button b_iurefresh "Refresh" pos:[5,110] width:100 height:18 on listview_rollout open do ( initListView lv_objects fillInSpreadSheet lv_objects ) on lv_objects ColumnClick colIndex do ( qsort result compareFN col:(colIndex.Column+1) lv_objects.Items.Clear() fillInSpreadSheet lv_objects ) on lv_objects ItemSelectionChanged theListItem do ( clicked_id = lv_objects.items.item[theListItem.ItemIndex].subitems.item[1].text as integer listview_rollout.controls[1].bitmap = openbitmap ((getSubMtl meditmaterials[medit.GetActiveMtlSlot()] clicked_id).maps[2].filename) ) on b_iurefresh pressed do ( fill_result() lv_objects.Items.Clear() fillInSpreadSheet lv_objects ) ) try(destroyDialog listview_rollout)catch() createDialog listview_rollout 430 200 )