3ds Max Script to Export List of Group Names to Excel File

Hi All,

I've only really got very limited knowledge of Scripting so I'm currently really struggling with this.
Basically we need a script that will export a list of items in a scene, specifically the Grouped items, to an Excel sheet.
I've managed to find the Script, but the problem is if we have 4 chairs in the scene it changes the end digit incrementally and we need the names the same as the Group name.
Is there a way to add in something that will count up the same named Groups and put this number in a separate column in Excel?
Thanks in advance for any help. And by all means if anyone needs any help with something more in our remit then just let us know.

fn printAllGroups txtFile =
(
helper = for node in helpers where isGroupHead node collect node.name
if helper.count == 0 then messageBox "No Groups in the scene!" title:"INFO" beep:off else
(
(dotnetclass "System.IO.File").WriteAllLines txtFile helper ; free helper
)
)
printAllGroups @"c:\temp\SceneGroups.xls"

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pixamoon's picture

`

Hi, try this:

fn sorter a1 a2 =
	case of (
		(a1 > a2): 1
		(a2 < a2): -1
		default: 0
	)
 
fn printAllGroups txtFile =
	(
		ghelper = for gnode in helpers where isGroupHead gnode collect gnode.name
		if ghelper.count == 0 then messageBox "No Groups in the scene!" title:"INFO" beep:off else
			(
				qsort ghelper sorter
				nameArr = #()
				a = 0
				for i = 1 to ghelper.count do (
					if i != ghelper.count and ghelper[i] == ghelper[i+1] then a += 1 else a = 0
					append nameArr ((if a > 0 then a as string else "") + "|" + ghelper[i] as string)
				)
				--print nameArr
				(dotnetclass "System.IO.File").WriteAllLines txtFile nameArr
				free ghelper
				free nameArr
			)
	)
printAllGroups "c:\\temp\\SceneGroups.xls"

When you import to Excel use "|" to separate columns.
Hope it helps.

Nastrazel's picture

So close

Hi Pixamoon,

Thanks for taking a look, really appreciate the help.
Sorry it's taken me a long time to get back to this portion of my project.
It all exports ok and imports like you said with "|".
However, instead of listing how many items of the same name it is coming out like the attached snippet image.

Basically if there's x number of groups with the same name I need it to add them all up and put how many there are in the first column (if this is possible)and the group name in the second column

Any further help would be greatly appreciated.

Many Thanks

AttachmentSize
capture.jpg 14.45 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.