Properties
Similar Topics
Statistics
Comments
23
Participants
3
Subscribers
4
Votes
2
Views
1718
Share
Answered
Hi all,
I need to produce quite a few images. I prepared a ggb construction which draws what I want according to the values of two sliders.
I'd like to iterate on the values of the sliders and produce an svg image for each iteration.
Since the combinations are as many as 121, I'd like to do that with some sort of batch script.
In order to do so, I need a script command for exporting the graphics view to svg.
I skimmed through the scripting commands, but I was not able to find anything like that.
Is there a way of obtaining what I want with a script?
Thanks a lot for any insight
Francesco
- GeoGebra
- Help
- Partners
-
Contact us
- Feedback & Questions
- This email address is being protected from spambots. You need JavaScript enabled to view it.
- +43 677 6137 2693
© 2023 International GeoGebra Institute
Updated, SVG export
https://test.geogebra.org/~...
PNG export
https://test.geogebra.org/~...
Modify the two sliders so that they depend from one slider and use the command ExportImage on a script on that slider. And build the export filename with dynamic text depending on either the two sliders or the third slider.
No example -> no example solutions.
Hi Loco,
thanks a lot for your help! I looked at the list of ggb script commands, but for some reason I missed ExportImage. Now that I think of it, I believe I have already used it a while ago. I must have forgotten.
I'm going to try to control the sliders through a script associated to a button, and nested for loops.
If I fail, I'll do as you suggest (I'm guessing I need modulo operator and integer division).
Thanks a lot again!
Francesco
Hi again,
I ended up following your advice. I ran into a problem, though. I'm working on chrome, on a macbook.
Apparently, the instruction
ExportImage("filename", fname, "view", 1,"type","svg");
does not directly export the image, but causes a confirmation window to appear. The user needs to push a button to save each file.
Is there a way to bypass this, and save all the files in "silent mode"?
If there is a unavoidable prompt i then there is no easy way out of GGb that i know of. May be the JS-way of Mr Borcherds might help.
If that is no help i suggest to have a look into the Option of multi page pdf export (type: pdf & slider n). With some 3rd party tools it should be easy to split the pages up and translate the content to svg. Could work or not i cant promise .
The last method i can think of is a brute force bot approach. Modify the GGb-File by a script (unpack, modify the slider values and pack it), open it via script (should be possible), wait for some time to load fully and process scripted UI tasks (simple repetitive mouse & keyboard tasks) (it is also possible to omit the file modifying and set the slider values here)... rinse and repeat.
Never done that so cant give a promise on that either. Just some ways of approach.
There are some other possible ways that depend on your file content.
Okay a quick test with your file shows my that my last first suggestion works. The only problem is that your file naming will be lost.
This gave me the 100 SVGs.
Open https://www.geogebra.org/m/ctvsnmzx
Copy and paste this in the browser's console (F12)
Note: I've redefined things so that they update with DD to keep it simple, for example
... and here's an automatic version:
https://test.geogebra.org/~...
Change these parameters as you need
really cool! Thanks one thousand times!
So you're using js but outside the applet, from the html page... I tried using js from inside the applet, but came up with nothing useful.
I roughly understand how the script works... So you create a zip object, populate it with the svg files and finally you save the zip file. Very cool.
I'm not sure I understand some details... for instance the "api" argument in pretty much all the functions.
Anyway this saves me a ton of work. So far I had to create the images individually, by hand.
Thanks, really
Francesco
Updated, SVG export
https://test.geogebra.org/~...
PNG export
https://test.geogebra.org/~...
Hi Michael,
thanks a lot, this is very interesting.
I tried downloading and "reverse engineering" your code.
So far I was not able to make your code work on my webpage. Initially I thought this had to do with the three scripts you include at the top of your code (jszip.js, jszip-utils.js and FileSaver.js) from a local folder ("../").
I downloaded those codes from github, put them just outside the folder containing the copy of your html page.
Unfortunately this does not seem to change anything.
I'd really like to make it work, so that I can tweak the filenames and some other details (and, of course, so that I learn something new).
Do you have any insight as to why I'm not able to make your webpage work on my website?
Thanks a lot
Francesco
Comments have been locked on this page!