Isotropix Forums

Is it possible to unregister a Scripted Class?

Clarisse Scripting related topics

Is it possible to unregister a Scripted Class?

Unread postby atnreg » Thu Jan 11, 2018 1:37 pm

Hi!

I made separate script that I associated in a button in toolbar. That way I can run it anytime I need. And in that script I can register my classes, Clarisse does not crash if there is something wrong, it gives the error message so it works nicely.
BUT if I register Scripted Class in it, further executions will not replace the class.

So is there some way to 'unregister' the class, otherwise I still need to restart Clarisse every time I make changes in my Scripted Class? :)

Also, is there some way to force Clarisse to restart, some 'safe' forced crash or something like that if no 'nice' way? :D
Clarisse restarts fast but it would be nice to get back to same point when testing those custom classes without saving all the time.

Thank you again!

Antti
Intel i7(6-core),32GB RAM,NVIDIA GTX 1080ti+GTX Titan Black,Win10 64bit
Clarisse 3.6,Fusion360,Blender,ZBrush,Onyx,(3D-Coat,Lightwave+Octane...)
Clarisse since 2016-09-29 (Py 2017-01-04), Python since 2016-11-10
I do all 3D stuff for fun, no business
atnreg
 
Posts: 277
Joined: Mon Sep 19, 2016 5:20 pm
Location: Helsinki, Finland

Re: Is it possible to unregister a Scripted Class?

Unread postby bvaldes » Thu Jan 11, 2018 6:27 pm

Hi,

There is a way to remove a scripted_class, a bad way that you shouldn't use but it works. This is not recommended to you the following script outside of the startup_script but I tried, you can.
You can delete a class via python so potentially you can delete also Clarisse's classes so be careful

python code

ix.application.get_factory().get_classes().remove("my_scripted_class") # Replace my_scripted_class by the name of your class

There is a big refresh issue, sometimes the created item with the removed class will switch to unknown class sometimes not... You should maybe delete all the items using the class before remove it.

There is, unfortunately, no way to restart Clarisse quickly. Expect maybe by launching a Python subprocess that will open another Clarisse with the current project as an argument and then close the current Clarisse.

I hope that the code I provide you will be enough.

Regards
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 173
Joined: Mon Sep 26, 2016 11:44 am

Re: Is it possible to unregister a Scripted Class?

Unread postby atnreg » Thu Jan 11, 2018 7:12 pm

Hi!

Thank you VERY much, EXACTLY what I was looking for! :mrgreen:
I added that call to each of my scripted class just before the register call so that I can just execute the class script and it always removes the possibly existing old version and it does not even complain on the first run (when there is no such class registered yet) :)

Now I can develop my classes by just running the helper script that does the register, no need to restart Clarisse :mrgreen:

Is there some danger with this, I only use it for replacing the class with new version so do you think it is safe? :)

Thank you again!

And also thank you for the new Clarisse 3.6 as well, total surprise but of course pleasant one as always!

Antti
Intel i7(6-core),32GB RAM,NVIDIA GTX 1080ti+GTX Titan Black,Win10 64bit
Clarisse 3.6,Fusion360,Blender,ZBrush,Onyx,(3D-Coat,Lightwave+Octane...)
Clarisse since 2016-09-29 (Py 2017-01-04), Python since 2016-11-10
I do all 3D stuff for fun, no business
atnreg
 
Posts: 277
Joined: Mon Sep 19, 2016 5:20 pm
Location: Helsinki, Finland

Re: Is it possible to unregister a Scripted Class?

Unread postby bvaldes » Fri Jan 12, 2018 10:04 am

Hi,

If it's only to develop, I think it's safe but I have no idea what happens if you do that in a real project with lot's of scripted class, with instances...
So keep in mind that it is not a perfect solution and be careful when you use it and where you use it in your code.

Have fun with the 3.6 ;)

Regards
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 173
Joined: Mon Sep 26, 2016 11:44 am

Re: Is it possible to unregister a Scripted Class?

Unread postby atnreg » Fri Jan 12, 2018 12:14 pm

ok then I will comment it out when development is done just in case :)

Thank you again!

Antti
Intel i7(6-core),32GB RAM,NVIDIA GTX 1080ti+GTX Titan Black,Win10 64bit
Clarisse 3.6,Fusion360,Blender,ZBrush,Onyx,(3D-Coat,Lightwave+Octane...)
Clarisse since 2016-09-29 (Py 2017-01-04), Python since 2016-11-10
I do all 3D stuff for fun, no business
atnreg
 
Posts: 277
Joined: Mon Sep 19, 2016 5:20 pm
Location: Helsinki, Finland


Return to Scripting