Scripts
Bake object transforms
Copy and paste
Emailer
Flush
Implode explode
Instantiate
Make names unique
Poly counter
Print selection
Reset viewport
Selector
Poly counter
macroScript polyCounter
category:"MaxPack"
buttonText:"Poly Counter"
tooltip:"Poly Counter"
(
rollout rll_polyCounter "Poly Counter"
(
dotNetControl lv_objects "System.Windows.Forms.ListView" pos:[5,5] width:740 height:300
fn initRollout =
(
lv = lv_objects
lv.gridLines = true --same as in ActiveX
lv.View = (dotNetClass "System.Windows.Forms.View").Details
lv.fullRowSelect = true --same as in ActiveX
lv.HideSelection = false
lv.Columns.add "Object" 190
lv.Columns.add "Location" 190
lv.Columns.add "Material" 130
lv.Columns.add "Class" 100
lv.Columns.add "Faces" 55
lv.Columns.add "Vertices" 55
)
fn update_objects =
(
lv = lv_objects
lv.Items.Clear()
theRange = #() --array to collect the list items
for x in 1 to xrefs.getXRefFileCount() do
(
xref_objects = #()
xrefObj = xrefs.getXRefFile x -- returns first XRef Scene object
join xref_objects (getChildren xrefObj.tree.children) -- objects in the XRef Scene object,
for obj in xref_objects where superClassOf obj == geometryClass and ClassOf obj != Targetobject do
(
li = dotNetObject "System.Windows.Forms.ListViewItem" obj.name
li.tag = dotNetMXSValue obj --DotNet value holding the MAXScript value
li.SubItems.add (filenameFromPath xrefObj.filename)
if obj.material != undefined then
(
li.SubItems.add obj.material.name
)
else
(
li.SubItems.add "--"
)
li.SubItems.add (classOf obj as string)
li.SubItems.add (obj.mesh.numfaces as string)
li.SubItems.add (obj.mesh.numverts as string)
append theRange li --we add the list item to the array
)
)
for obj in geometry as array where ClassOf obj != Targetobject and isProperty obj.mesh #numfaces do
(
li = dotNetObject "System.Windows.Forms.ListViewItem" obj.name
li.tag = dotNetMXSValue obj --DotNet value holding the MAXScript value
li.SubItems.add "Scene"
if obj.material != undefined then
(
li.SubItems.add obj.material.name
)
else
(
li.SubItems.add "--"
)
li.SubItems.add (classOf obj as string)
li.SubItems.add (obj.mesh.numfaces as string)
li.SubItems.add (obj.mesh.numverts as string)
append theRange li --we add the list item to the array
)
lv.Items.AddRange theRange --when done, we populate the ListView
)
on rll_polyCounter open do
(
initRollout()
update_objects()
)
on rll_polyCounter resized size do
(
lv_objects.width = size.x - 10
lv_objects.height = size.y - 8
)
on lv_objects DoubleClick args do
(
select lv_objects.SelectedItems.Item[0].tag.value
)
on lv_objects ColumnClick args do
(
--showProperties args.Column
lv_objects.sort() --args.Column
cols = #("Object","Location","Material","Class","Faces","Vertices")
--print (cols[args.Column+1])
case cols[args.Column+1] of
(
"Faces":
(
lv = lv_objects
theRange = for li in 0 to lv.Items.Count-1 collect lv.Items.Item[li]
fn compareFN v1 v2 =
(
local d = v1.tag.value.mesh.numfaces - v2.tag.value.mesh.numfaces
case of
(
(d < 0.): 1
(d > 0.): -1
default: 0
)
)
qsort theRange compareFN
lv.Items.Clear()
lv.Items.AddRange theRange
)
"Vertices":
(
lv = lv_objects
theRange = for li in 0 to lv.Items.Count-1 collect lv.Items.Item[li]
fn compareFN v1 v2 =
(
local d = v1.tag.value.mesh.numverts - v2.tag.value.mesh.numverts
case of
(
(d < 0.): 1
(d > 0.): -1
default: 0
)
)
qsort theRange compareFN
lv.Items.Clear()
lv.Items.AddRange theRange
)
)
)
)
createDialog rll_polyCounter width:750 height:310 style:#(#style_resizing, #style_minimizebox, #style_maximizebox, #style_titlebar, #style_sysmenu)
)