Isotropix Forums

How to know if project is loaded completely?

Clarisse Scripting related topics

How to know if project is loaded completely?

Unread postby atnreg » Tue Mar 05, 2019 3:26 pm

Hi!

I have ScriptedClass that processes a scatterer's geometry instances. When I create it, it works fine and whenever I add an item, it reacts to it.

But the problem is that I cannot get it to work correctly on project load. If the scatterer has instances when I save the project, on load the process starts immediately when it populates the instances by project load and that triggers the scatterer attribute on my class and so the whole list takes huge number of passes as it triggers on each added instance and can even crash Clarisse.

So now I would need some kind of is_scene_loading(), is there something like that? :)
With that I could skip processing until all the instances exist i.e. when the project has completed loading.
I tried to find the SDK docs but could not find anything related.

I can make that work by using some 'active' flag that I trigger by a button but I would like to get the process active without need to press a button also on project load :)

Thank you!

Antti
AMD Ryzen Threadripper 2990wx (32 core, 64 thd),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1,Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
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: 425
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: How to know if project is loaded completely?

Unread postby bvaldes » Tue Mar 05, 2019 4:22 pm

Hi,

I never heard of a function like this. Could you provide us a simple scene with the script to test if some functions can do the tricks?
I think that ix.application.is_evaluating() could be what you are looking for but I never had to do that before and I don't really know hot to build a simple setup to mimic yours.

Thanks in advance.
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 335
Joined: Mon Sep 26, 2016 10:44 am

Re: How to know if project is loaded completely?

Unread postby atnreg » Tue Mar 05, 2019 5:13 pm

bvaldes wrote:Hi,

I never heard of a function like this. Could you provide us a simple scene with the script to test if some functions can do the tricks?
I think that ix.application.is_evaluating() could be what you are looking for but I never had to do that before and I don't really know hot to build a simple setup to mimic yours.

Thanks in advance.


Thank you, I tried that but it caused Clarisse to 'disappear' after a while which indicates some kind of infinite loop.
I'll need to check my other code first and then I'll make a simple class that only has that part and try that is_evaluating() with it. I'll post it here either case so you or someone can check what I am doing wrong if I can't get it to work :)

But that I'll do tomorrow so thank you so far, see you later :)

Antti
AMD Ryzen Threadripper 2990wx (32 core, 64 thd),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1,Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
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: 425
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: How to know if project is loaded completely?

Unread postby Braden99 » Tue Mar 05, 2019 7:08 pm

It would be good to have methods like is_project_loading like Antti mentioned.

In the future it would awesome to also be able to subscribe to events like projectLoadEnd or projectLoadStart, and run a Python script. I'd also be interested in seeing a projectSaved callback which could be used to register a Python callback.
Braden99
 
Posts: 47
Joined: Mon Jan 08, 2018 3:05 am

Re: How to know if project is loaded completely?

Unread postby bvaldes » Wed Mar 06, 2019 9:11 am

Hi,

@atnreg maybe it's not possible so you probably do everything good. I just have no idea because I never did something like that and I have to test several things. When I will have your code/scene, I will be able to investigate but it could be not possible to do right now.

@Braden99 you can add a feature request for that. For now there is no callback like that but events are available for GUI and that could be done for other things.

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

Re: How to know if project is loaded completely?

Unread postby atnreg » Wed Mar 06, 2019 2:39 pm

bvaldes wrote:Hi,
@atnreg maybe it's not possible so you probably do everything good. I just have no idea because I never did something like that and I have to test several things. When I will have your code/scene, I will be able to investigate but it could be not possible to do right now.
Regards


No, sadly the problem is elsewhere in my code, I made simple class that has scatterer attribute and then print the number of instances when it changes, it works fine also on project load :?

I will need to simplify the code until the problem disappears, that way I hopefully can find the reason and probably solution as well :)

Gee if Clarisse had Python debugger support...

Antti
AMD Ryzen Threadripper 2990wx (32 core, 64 thd),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1,Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
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: 425
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: How to know if project is loaded completely?

Unread postby atnreg » Wed Mar 06, 2019 2:45 pm

But what is very strange is why the scatterer attribute triggers 40!!! times on project load when it is just simple reference that is pointing to scatterer that has 3 instances??????? :O :O :O
There are not even 40 items in the whole project so how that is possible :o

Antti
AMD Ryzen Threadripper 2990wx (32 core, 64 thd),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1,Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
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: 425
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: How to know if project is loaded completely?

Unread postby atnreg » Wed Mar 06, 2019 4:59 pm

It seems that the overwhelming number of attribute changes is the problem, before Clarisse crashes on my full class, it does the processing of instances 10 times.
This is exactly why we need to know when project loading is done so we can wait before starting 'heavy' processing :)

Is that really normal that simple attribute that refers to a scatterer can cause that many changes during project load? :O

Here is the class code. To test it, just use this as startup script and then create scatterer, add some geometry+pointcloud etc. the usual :) and create item of class 'activate' and add the scatterer to 'scatterer' attribute (I bet you didn't guess that :D) Note that the log shows the attribute change ONCE and gives the number of instances. Then change something in scatterer and log shows that attribute 'scatterer' changes, again ONCE and gives the number of instances.
Now save the project and load it back and see log, there are 40 (may vary on your system as I have no idea where that number comes from) attribute changes :O
activate_class.py
(1.8 KiB) Downloaded 5 times


Any ideas are highly welcome :)

Thank you!

Antti
AMD Ryzen Threadripper 2990wx (32 core, 64 thd),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1,Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
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: 425
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland

Re: How to know if project is loaded completely?

Unread postby bvaldes » Tue Mar 12, 2019 9:30 am

Hi,

Sorry for the late reply, I didn't found any way to execute the script only when Clarisse is fully loaded.
You should add a feature request for that because it looks like it's currently not possible.
Sorry to don't be more useful.

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

Re: How to know if project is loaded completely?

Unread postby atnreg » Tue Mar 12, 2019 11:29 am

bvaldes wrote:Hi,

Sorry for the late reply, I didn't found any way to execute the script only when Clarisse is fully loaded.
You should add a feature request for that because it looks like it's currently not possible.
Sorry to don't be more useful.

Regards


Thank you, this was very big help because now I know I was not doing anything wrong :)

Soon I will post another question related to similar issue but it is still different (not about project load) so stay tuned :D

Thank you!

Antti
AMD Ryzen Threadripper 2990wx (32 core, 64 thd),64GB RAM,NVIDIA GTX 1080ti,Win10
Clarisse 4.0SP1,Blender,Fusion360,Houdini,ZBrush,Onyx,SubstPnt...
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: 425
Joined: Mon Sep 19, 2016 4:20 pm
Location: Helsinki, Finland


Return to Scripting