Notifications
Clear all

[Closed] maxscript to cleanup STL imports ?

Exists somewhere a maxscript to cleanup STL imports ?

e.g.:
Delete “unused” helpers
rename “-DC_Shell” objects

In my case i get many point helpers that are hierarchy linked: A object (DC Shell) is linked to a helper, is linked to a helper … etc.

If i delete all helpers, than i get a clean scene, but all hierarchy is lost.

2 Replies

this can easily be fixed with maxscript.
Could you post a example file?
(with let’s say 10 objects, helpers and so on) so that we can work with that?
This makes it much easier to help you with these things.

I have a self made solution, seems to work fine:

to_delete = #()

fn iter_nodes node_children indent last_name =
(
	indent += 1
	for obj in node_children do
	(
		-- How to make this easier:
		spaces = ""
		for i = 1 to (indent*2) do spaces += "-"
		format "% %
" spaces obj
		
		if (isKindOf obj Helper) do (
			if obj.name != "" and obj.name != "NONE" do (
				last_name = obj.name
			)
			
			if (obj.parent != undefined) and (obj.children.count == 1) then (
				append to_delete obj
			)
		)
		if (isKindOf obj Body_Object) do (
			format "% *** rename Body_Object from '%' to '%'
" spaces obj.name last_name
			obj.name = last_name
		)
		
		iter_nodes obj.children indent last_name
	)
)
base_nodes = for o in objects where o.parent == undefined collect o
for obj in base_nodes do
(
	iter_nodes obj.children 0 undefined
)

for obj in to_delete do (
 	obj.children[1].parent = obj.parent
        delete obj
)