Is there a way to moving playhead/current time in After Effects? - adobe

In short, I need to reset the playhead back to frame 1 at the time of the script running.
I'm creating a script for exporting a handful comps after updating some text.
One export will be a jpg, and then 2 short videos. I am using app.executeCommand(2104) which is Save Frame As to add the current frame to the render queue for the jpg export. Otherwise, AE would be trying to export a jpg sequence even if only 1 frame long. This affects the output name and the settings of the export. I haven't found an easy way of avoiding the added formatting.
I will be giving this to inexperienced coworkers, who will surely forget to reset the playhead before hitting my export button. So I was trying to force the playhead back to the beginning within the script.
Export Changes
I have tried updating the output render settings with a Time Span Start and Time Span Duration but that changed it back into the jpg sequence.
I thought I could trick/hack it by creating a new comp and then deleting. since when doing it by hand it moves the playhead to zero of the newly created comp. however, when changing focus back to the JPG comp the playhead jumped back to where it was originally.
I have searched through both of the official Adobe guides for scripting and the usual net forums but I haven't found a single command that works for moving the playhead other than by hand. I'm hoping I just missed something obvious.

The playhead-time-thingy-line is called the CTI (Current Time Indicator) in AE-Land. So this should work.
app.project.activeItem.time = 0;
(How) can I move the CTI from within a script?

Related

Stop audio when enter room in Gamemaker?

Having some trouble with getting audio to stop playing when you enter a specified room. I've tried a few different ways, including coding it completely using if statements and audio_play_sound/audio_stop_sound and audio_play_music/audio_stop_music, but both of those didn't work and just layered the music over and over until it created a mess of sound.
Currently, I've tried to do it this way, but upon entering the room the music just keep playing and won't stop.
Anyone know how to get this to work?
I'm using the latest version of Gamemaker.
Cheers
Your issue is that the audio_stop_sound() method accepts an instance of the sound, rather than the name of your sound object.
I'm doing this without Game Maker Studio here to verify the code, but the best way to do this is to save the index returned when you start a sound, and use that index later on to stop it.
For example to start your sound (called MainMenuTheme):
global.MENU_SOUND = audio_play_sound(MainMenuTheme, 1, 1);
Then to stop it
if (audio_is_playing(global.MENU_SOUND))
{
audio_stop_sound(global.MENU_SOUND);
}
Basically when you start a looping sound, store its index in a global variable so you are able to stop it when you need to, from a different screen or object.

Reset text output from R in spotfire

I have written a code to generate texts based on certain conditions in Spotfire using R. The code refreshes automatically whenever a selection is made. Since there are a lot of if-else condition used in R, the code takes a noticeable time to refresh the content. The dashboards change but the text changes after a lag.
Is there anyway to reset the text output while the R code runs so that the user doesn't get confused?
I've go some Python triggered data function that can take between 5 minutes to an hour to execute. The hardest part is getting the HTML of a text area to update. What I've currently implemented is a loading bar coded by Halpenfield. Something I've been meaning to try but haven't gotten to yet is a more descriptive popup.
These won't reset the displayed text before executing code but they will make it clear to the user something is happening. There might be a way to do directly what you are asking with two HTML's and a forced refresh like Halpenfield uses.

Why everything in RStudio workspace vanishes every time I close it?

Every time I close and open the RStudio, everything in the panels including all the data frames, functions, values, etc. vanishes and some very old ones that I have deleted long ago appears. I save workspace when I want to close it, but this happens every time. Importing my large dataset and generating everything again every time takes a lot of time. What can I do?
You can save your workspace and restore it under Tools -> Options -> General.
Please see picture below.
In addition you can also use:
save.image(file='Session.RData')
And load it later:
load('Session.RData')
However, generally speaking, some consider it bad to keep/save your environment/workspace.

How to see original script or function from RData?

I created a very small script (without saving) in RCmdr top window, but I only saved the workspace.
When I reload this I can't see anything that was in the top window originally. My mistake I know, but is there a way to see any hint of the functions etc I may have called, from the workspace file? I can see the objects - but not what created them.
If you open a new R session, try hitting the up-arrow keys. The normally invisible .Rhistory file is usually loaded at the start of a new session if the prior session ended normally. If the session is open in a GUI hten you may be able to display the list of commands with a menu command. This may also display that file:
loadhistory(file = ".Rhistory")
The history is cumulative, so unless you had a really long session intervening you may still be able to get code going back for several session. I think it keeps the last 500 entries by default. Actually turns out to be 512. See:
?history

Display opencv frames in a window with button and text control

I'd like to ask you some information about a problem which i want to solve.
At the moment, I have two opencv applications:
application A: where i track an object with two types of algorithms and each time i save a frame in an image file and i control the application behavior with some commands which i write in the shell
application B: where i have a loop which reads every time the image file and display it
So, I launch these two applications together in order to track the object with appA and to display results with appB which reads everytime the frames saved by appA in the hard disk.
I want to integrate application B in application A in order to show a window (like this: http://lnx.mangaitalia.net/window.jpg) in order to have a loop which shows image in the first area and to use buttons in order to give commands which at the moment i write in the shell.
Do you think it's possible to display the frames in an area with Qt or opengl or wxwidgets?
Which solution is the better and the easier to apply?
At the moment, my application B is very simple:
while(1)
{
Mat img=imread("result.jpg",1);
if(!img.empty())
imshow("HOG",img);
if(waitKey(200)==27) break;
}
I want to show these frames in a window which has also some buttons.
In particular, as you can see in the attached image in this post, i want to create a window divided in two parts: the first one which display the frames captured from opencv camera and the second part (or area) which has some buttons (B1, B2, B3..) which the user can press in order to control the application behavior.
(At the moment, i use a switch/case in appA to trap the keyboard keys)
There is some example based on a template similar to what i'd like to do?
(like the jpg image i've told before: http://lnx.mangaitalia.net/window.jpg)
I propose that you just use the inbuilt GUI in OpenCV: highgui. It has keyboard/mouse IO, window control with a message loop, buttons, sliders etc. And there is no need to do any conversions of the cv images to show them.
Have a look at: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut3.html (It is written for old IplImage style CV, but the C++ interface is almost the same, use cv::imshow to draw images)
Also, here is the documentation for the C++ style interface.
There is also the possibility to convert your CV images to QImage in Qt and do it that way... you should be able to find solutions for that on Google.
There are some examples out there for implimenting this.
see http://larryo.org/work/information/wxopencv/index.html
Basically what you want to do is:
capture a frame from your camera
manipulate the image
use cvConvertImage to convert it into a format wxImage can read
draw this image on to a wxCanvas
For the GUI part of this, you would need to create a wxFrame or wxWindow, place some sizers and buttons at appropriate places.
So basically make a frame, put a sizer on the frame, then put a panel in the sizer.
next make a vertical sizer on the panel. First add a wxCanvas to the vertical sizer, then place a horizontal sizer in the vertical sizer. Now add 3 buttons to the horizontal sizer, and you have your panel.

Resources