Notifications
Clear all

[Closed] sceneMaterials doesn't update?

Hello,

Create 2 objects, assign unique material to each.
sceneMaterials.count outputs 2.
Delete 1 object.
sceneMaterials.count still outputs 2.

Who can help me on this?

Thanks in advance!

4 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

The SceneMaterials content is only updated when materials are added and when the scene is saved/loaded. (Not sure why, but that’s how it is).

So if you keep on adding materials, the only way I know to update the content and remove the “orphaned” materials is to perform some form of a file operation.

One way would be to call holdMaxFile(), but if your scene is large, it would mean wasting time. Thus, it is a much better idea to save an EMPTY Max file and delete it immediately.

sceneMaterials.count –> 2
theFile = (GetDir #Scene + “\_temp.max”) –define the file name
saveNodes #() theFile –save no objects in the file
deleteFile theFile –delete it again
sceneMaterials.count –> 1

Great idea bobo. I know that will come in handy

Really clever method, Bobo, thank you!

Nice Spot macrod, and a sublime solution bobo. Cheers.

I am just starting a material cleaning program, and I would have had my head hurting for ages over that one.

much appreciated,

Rich