Delete SME views script causing error

Delete SME views script causing error

TB_RIO
Advocate Advocate
5,971 Views
22 Replies
Message 1 of 23

Delete SME views script causing error

TB_RIO
Advocate
Advocate

I have used this script for a while in conjunction with the 'show materials for selected' in order to quickly get materials in and out of the Slate Editor. Recently (I think it corresponds with me updating to Vray 5) the clear SME views one causes the below error, and a lot of the time causes max to crash.

 

I'm a complete scripting luddite and don't know what this means unfortunately, can anyone help!?

 

Or is there a more sensible way of doing it now (I'm on 2020)

here's the script:

----------------------------------------------------------------------------------------
-- Version:		v1.0
-- Author:			Aleksey Sheremetov  - https://kotiger.co/
----------------------------------------------------------------------------------------

macroScript Delete_SME_Views
category:"Kotscript"
tooltip:"Delete SME views"
buttontext:"DeleteViews"

(
	ViewsTotal = sme.GetNumViews ()
	ViewIndex = 1
	for i in 1 to ViewsTotal do 		
	(
		view = sme.GetView (ViewIndex)
		if matchPattern view.name pattern:"*View*" then
		(
			sme.DeleteView (sme.GetViewIndex (view)) false
		)
		else
		(	
			ViewIndex += 1
		)
	)
)

 

0 Likes
5,972 Views
22 Replies
Replies (22)
Message 21 of 23

calberto.cart
Advocate
Advocate

Ok I did another test with everything cleaned, delete a missing plugin and now It works beautifully, without freezes nor crashing, Ill keep up testing, thank u so much!!!

0 Likes
Message 22 of 23

denisT.MaxDoctor
Advisor
Advisor

@calberto.cart wrote:

Ok I did another test with everything cleaned, delete a missing plugin and now It works beautifully, without freezes nor crashing, Ill keep up testing, thank u so much!!!


Of course, it's great that you can now delete all views if you clear the scene beforehand. But the purpose of deleting all views is to clean up the scene. So it is desirable to do the whole cleaning in one automatic process.
In vain, you don't post a simple example file that can be used to reproduce failures. Knowing such "problem materials" or "scene conditions" will be useful to others.

0 Likes
Message 23 of 23

denisT.MaxDoctor
Advisor
Advisor

 

Here is the right way to delete all sme views:

(
	if sme.GetMainframe() == undefined do sme.Open() 
	while sme.GetNumViews() do sme.DeleteView 1 false
)	

 

This is how to delete only "View*" named views.

(
	if sme.GetMainframe() == undefined do sme.Open() 
	for k = sme.GetNumViews() to 1 by -1 
		where matchpattern (sme.GetView k).name pattern:"View*" do sme.DeleteView k false
)	

 

 

0 Likes