Save world to .rube file from script

General discussion about the R.U.B.E editor
Post Reply
Voptiplex
Posts: 35
Joined: Thu Nov 14, 2013 1:07 pm

Save world to .rube file from script

Post by Voptiplex »

Hi Chris,

is it possible to save the rube file from rubescript ?
I am creating different template (scale and postion) of one world and would like to save the current world after scale step in script.
The file name needs to be set as well .... ;-)

Can I maybe access the editor functionality from script ? Like open the file menu and simulate a mouse click on save file ?

Thanks,
Thomas
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Save world to .rube file from script

Post by iforce2d »

Although you can't do that from within the GUI, you automate scripting and saving by invoking RUBE as a command-line utility (it will start without the GUI if given some parameters on the command line). There is some discussion on this here: viewtopic.php?f=6&t=380

In your case, it sounds like you would have to prepare multiple scripts to get the multiple scales you need, and run multiple invocations as a command-line utility. Note that the cursor position will be 0,0 when starting up so if you want the scale to be about some other point, you would need to setCursor() first.
Voptiplex
Posts: 35
Joined: Thu Nov 14, 2013 1:07 pm

Re: Save world to .rube file from script

Post by Voptiplex »

Hi,

thanks for your answer, calling rube from the command line works well.

I do have two problems here though:
1) I tried searching for an issue in the forum where you had answered regarding scripting and export.
But when type anything in the forum search I do just get:
The following words in your search query were ignored because they are too common words: export script.
I tried searching with google but did not find the issue either.

You would save yourself a lot of duplicate work if the search in the forum could be improved.


2) If I executed my script in the editor, everything worked, but I got a pop-up, that one of my bodies had a radius of less than 0.05m. (I do understand, that Box2D works best between 0.1m and 10m so that radius of 0.05 would be a diameter of 0.1m.)
The problem is now that when calling rube from the command line, that popup would just crash rube !
From the stacktrace below you can see a segmentation fault when a delayed pop-up was supposed to be started.
Changing the diameter for 0.1m stopped the pop-up and everything worked.

Have a you seen this problem before ?
As mentioned before I am working on the latest OSX and maybe it is related.

Thanks,
Thomas


Process: rube [8231]
Path: /Applications/rube-mac32-1.7.3/R.U.B.E.app/Contents/MacOS/rube
Identifier: com.iforce2d.rube
Version: 1.7.3 (1.7.3)
Code Type: X86 (Native)
Parent Process: sh [8228]
Responsible: Terminal [692]
User ID: 501

Date/Time: 2015-12-01 14:09:16.346 +0100
OS Version: Mac OS X 10.11.1 (15B42)
Report Version: 11
Anonymous UUID: 20AFBF20-5FA7-C79E-6F07-5CFD02F58CC5

Sleep/Wake UUID: 366C7CFD-1890-49F2-89F5-FA2EF1DBD226

Time Awake Since Boot: 13000 seconds
Time Since Wake: 6300 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000000000007c

VM Regions Near 0x7c:
-->
__TEXT 0000000000001000-00000000005f0000 [ 6076K] r-x/rwx SM=COW /Applications/rube-mac32-1.7.3/R.U.B.E.app/Contents/MacOS/rube

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.iforce2d.rube 0x00022412 MainWindow::canPushDelayedMessageBox() + 18
1 com.iforce2d.rube 0x002e2e4a Shape::setRadius(float) + 266
2 com.iforce2d.rube 0x001db14f MetaFixture::setShapeRadius(int, float) + 63
3 com.iforce2d.rube 0x000a2532 EditorDocument::shape_setRadius(MetaFixture*, int, float) + 162
4 com.iforce2d.rube 0x002d10e9 scaleBodies_nonMirrored(EditorDocument*, std::set<MetaItem*, std::less<MetaItem*>, std::allocator<MetaItem*> >&, b2Vec2, b2Vec2, float, bool, bool) + 3865
5 com.iforce2d.rube 0x002d5fe2 scaleBodies(EditorDocument*, std::set<MetaItem*, std::less<MetaItem*>, std::allocator<MetaItem*> >&, b2Vec2, b2Vec2, float, bool, bool) + 130
6 com.iforce2d.rube 0x00241574 scale_bodies(CScriptArray*, int, float, float) + 292
7 com.iforce2d.rube 0x003fc240 endcopy + 3
8 com.iforce2d.rube 0x003fca48 CallSystemFunctionNative(asCContext*, asCScriptFunction*, void*, unsigned long*, void*, unsigned long long&) + 827
9 com.iforce2d.rube 0x003fb215 CallSystemFunction(int, asCContext*, void*) + 450
10 com.iforce2d.rube 0x004399ec asCContext::ExecuteNext() + 6848
11 com.iforce2d.rube 0x0043f5a7 asCContext::Execute() + 1023
12 com.iforce2d.rube 0x0008e466 EditorDocument::runScript_Impl() + 566
13 com.iforce2d.rube 0x0035e005 main_ni() + 8853
14 com.iforce2d.rube 0x00015520 main + 240
15 com.iforce2d.rube 0x00014f29 _start + 208
16 com.iforce2d.rube 0x00014e58 start + 40
Voptiplex
Posts: 35
Joined: Thu Nov 14, 2013 1:07 pm

Re: Save world to .rube file from script

Post by Voptiplex »

Mmmhhh, thinking about the crash of point 2) above and the crash in viewtopic.php?f=7&t=480.
Could the crashes be caused by Rube picking up some Qt 5.5 libs from my system, while Rube is based on Qt 4.8 ?

Maybe Rube needs to run in virtualenv or be statically linked ?
Or is Qt 4.8 too old for the latest OSX ?

Cheers,
Thomas
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Save world to .rube file from script

Post by iforce2d »

1) that is a problem with phpbb just having a terrible search function, I think I would need to do a full upgrade of the forums to fix it, assuming the problem has been taken care of in later versions of phpbb. The best way for now is actually to use google, you can specify the scope of the search by including a site: qualifier, eg.

site:www.iforce2d.net/forums scripting export

... should limit the results to threads on this forum.

2) No, that is probably a bug in RUBE rather than a problem with different Qt versions being used. I'll look into it.
Voptiplex
Posts: 35
Joined: Thu Nov 14, 2013 1:07 pm

Re: Save world to .rube file from script

Post by Voptiplex »

Hi,

please put he crash investigation of issue 2 on-hold till I have more info.
See https://www.iforce2d.net/forums/viewtopic.php?f=7&t=480 for reasons.

BR,
Thomas
Post Reply