Print all scene objects Parent-Child combo names to txt file in 3Ds max using maxscript

Print all scene objects Parent-Child combo names to txt file in 3Ds max using maxscript

arthvaja
Participant Participant
1,549 Views
4 Replies
Message 1 of 5

Print all scene objects Parent-Child combo names to txt file in 3Ds max using maxscript

arthvaja
Participant
Participant

Hey there,

 

I have a scene where I have lots of objects and their child objects too. however, I want to print all parent objects names and their child object names to the .txt file in the proper way using max script.
I tried to print selection by selecting parent first and then Childs but I didn’t get it in proper manner and that also printed position and transformation data which I don’t need.

 

Expected text file printing Format:

<Parent 1 object name>
<child 1>
<child 2>
<child 3>

 

<Parent 2 object name>
<child 1>
<child 2>

<child 3>
object list.png

0 Likes
Accepted solutions (1)
1,550 Views
4 Replies
Replies (4)
Message 2 of 5

denisT.MaxDoctor
Advisor
Advisor

maybe at least xml or json format?

0 Likes
Message 3 of 5

arthvaja
Participant
Participant

yeah, .json file also workable for me.

0 Likes
Message 4 of 5

Swordslayer
Advisor
Advisor
Accepted solution
(
	local outputFileName = @"C:\TMP\output.json"
	local json = python.import "json"
	local py = python.import "builtins"

	local outputFile = createFile outputFileName
	local output = py.dict #()

	for obj in objects where obj.children.count > 0 or obj.parent == undefined do
		output[obj.name] = py.list (for c in obj.children collect c.name)

	format (json.dumps output) to:outputFile
	close outputFile
)

 

If you're on max 2020 or earlier, you'd use python.import "__builtin__" instead of python.import "builtins".

0 Likes
Message 5 of 5

arthvaja
Participant
Participant

Thanks, it really worked for me.

0 Likes