Page 1 of 1

Why does this not work and how can I make it work?

Posted: Mar 14th, '18, 22:06
by MSandro
Hi, I've tried a around several hours to figure out how to load a other project. With no result.
I've found this block in the GP libs:
openProjectFromFile.png (10.08 KiB) Viewed 2381 times
On run this block GP looks like this:
Bildschirmfoto von »2018-03-14 23-06-22«.png
How could I get this to work?

Re: Why does this not work and how can I make it work?

Posted: Mar 15th, '18, 22:52
by vickiS
I'm just wondering how you are trying to implement this. The open project button triggers this function but the button itself is outside the script editor. When I played with this in the script editor it never got past the clearProject method in openProject because the block disappears I think. I also managed somehow to disappear the class methods in the ProjectEditor class browser and cause an Undefined function: blockSpecs error. Reloading fixed that. I tried setting it up in a class browser but that's not working for me either. I haven't tried loading an external file into the system browser.

Re: Why does this not work and how can I make it work?

Posted: Mar 16th, '18, 08:13
by MSandro
Okay, so I have to find a way how to run a script in "background". So it'll not be stopped/removed on a clear.

Edit: I've tried around to solve this about several hours. I used tasks, broadcasts and more. I also tried to add some code to the GP backend, but with no result. I am not sure how to solve this.

I've already tried how to import a class with a small script/block successfully.
Bildschirmfoto_2018-03-16_09-13-03.png (7.03 KiB) Viewed 2345 times
This works fine because no code will be removed.

Re: Why does this not work and how can I make it work?

Posted: Mar 18th, '18, 21:36
by MSandro
I've now found a nice litle workaround:

This works:
Bildschirmfoto vom 2018-03-18 22-18-13.png

This doesn't work:
Bildschirmfoto vom 2018-03-18 22-19-09.png

Because I've found a "openProjectFromFile" in the "Stage" class, I've tried to replace "ProjectEditor" with "Stage" and ... it works!
It could look a bit glitchy but it works. This block only load the given project in the stage, not in the project editor, so all classes you've created are still there. But the project you've want is visible in the stage, GP will automaticaly go into presentation mode too. I think there are more advantages to this method than disadvantages. For example, you can easily add elements to a post-loaded project, such as a close button to return to another project, without having to make any changes in the loaded project.

Here is a example:
(8.91 KiB) Downloaded 120 times