Running Post-BatchRender MEL Command - maya

I'm looking for a way to run a MEL script at the conclusion of a batch render. Is this possible? I'm aware of the 'Pre render MEL' and 'Post render MEL' render options, but am looking to run a script at the conclusion of a batch render.
This code specifically fires as expected following 'Render View' initiated renders but fails to fire following any type of batch render:
setAttr -type "string" defaultRenderGlobals.postMel "promptDialog -message \"done: postMel\"";
setAttr -type "string" defaultRenderGlobals.postRenderMel "promptDialog -message \"done: postRenderMel\"";
Is there perhaps a buried setting that suppresses these callbacks for batch renders?
System Info
Maya Ver: 2009 x64
OS: Win 8.1

There are several different Pre/Post MEL options:
Pre render MEL (preMel):
This is run before the first frame renders
Post render MEL (postMel):
This is run after the last frame renders
Pre render layer MEL (preRenderLayerMel):
This is run before starting the first frame of a batch in a certain render layer
Post render layer MEL (postRenderLayerMel):
This is run after the last frame of a batch in a certain render layer, before switching to the next layer
Pre render frame MEL (preRenderMel):
Originally these were the only two options. This runs before every single frame of rendering
Post render frame MEL (postRenderMel):
Originally these were the only two options. This runs after every single frame of rendering
These do run in batch. In our pipeline they provide a callback to verify and update values at the beginning (preMel), update our render queue system with progress (preRenderMel and postRenderMel), and final reports at the end (postMel).

The reason this does not work is not so much the event but rather what you do. The code:
promptDialog -message "done: postMel"
Will not work in batch render! This is because batch mode is a separate process (separate program running in parallel to Maya). The batch mode has no GUI so it does not have any way to react to GUI calls.
So you must do something else.

Please correct me if I am wrong. Are you launching the batch render from the UI session of Maya and want a mel to get executed in the UI session once the batch render finishes?
The postRenderMel code will work only in the batch session and will not connect back to the UI session of Maya. The only connection Maya Ui session makes to the Maya batch is the Stdout. So if you want a mail sent on finishing the render that is totally possible. But if Maya UI session needs to load a UI that will not work with a postRenderMel.
I tried searching but I could find any event associated with batch render completion. The way I would probably try would be to wrap the batch render with custom code may be using Python Subprocess and call the Maya batch to render followed by the command that's needs to execute on completion.
You can do this in a separate thread that way it doesn't block the current Maya session.

Related

How to make delphi VCL application run from the command line

I've got a VCL application in Delphi 10.2.
User should choose a few settings and then press the "Run" button.
Now I want this app to run automatically once a day (using Task Scheduler in Windows) with the settings that the user set up already in the app. So I need a solution to run the "Run" button routine from the command line.
How can I make this app not to open the main form, but to run behind the scenes, using the chosen settings?
As far as I understand, I'm supposed to make another unit that would run some scripts from the main VCL App, would get the settings and would pass them as parameters to a function which will call the "Run" button routine.
But here I cannot figure out how can I run this unit instead of the main form when Task Scheduler is running the app and not the user.
Or maybe there is a different solution?
Can anyone help please?
You can use a command-line parameter for the exe and run the application accordingly.
To read the command line parameter use the function ParamStr (when you only use one command line parameter, you can use ParamStr(1) to read the first and only parameter).
When you need to have more command line parameters, then use ParamCount to iterate through all the available parameters.
Depending on the way you want to run your ‘Run’ code and have your config form shown, you can edit the projects .dpr file to show/create the main form when you run the app in ‘config’ mode and in the other case execute the ‘run’ code.
program MyProgram;
uses
Vcl.Forms,
ConfigFormUnit in 'ConfigFormUnit.pas' {ConfigForm},
RunCodeUnit in 'RunCodeUnit.pas';
{$R *.res}
begin
Application.Initialize;
if ParamStr(1) = 'run' then
ExecuteRunCode
else begin
Application.MainFormOnTaskbar := True;
Application.CreateForm(TConfigForm, ConfigForm);
end;
Application.Run;
end.
The routine ExecuteRunCode is a public routine in one of the units, which contains the code you want to run in 'Run' mode. (in the example the unit RunCodeUnit.pas).
unit RunCodeUnit;
interface
procedure ExecuteRunCode;
implementation
procedure ExecuteRunCode;
begin
// Code to run
end;
end.
Of course, you can create two separate programs, each having its own specific code, but this way you can use a single application if you want/need.
Probably you want to create a command line only version of your application. This is named "console mode" application in Delphi terminology (File / new / console application).
You can access command line parameters using ParamStr and ParamCount.
If you need both command line and GUI application, put all not GUI code into one unit, encapsulating it in a class or as standard function. The you can use that unit from the GUI application and from the console mode application.
By the way, it is a good design to always separate user interface from business code. You have a good example of that need here: you either use the code from a GUI application or from a command line application and you could as well use it from a service application or inside a DLL.

Why explicit wait is waiting for entire wait time even though element is visible/clickable before the wait time is over

I have given a wait time for 60 sec, and i am using wait until element to be clickable/visible but script is waiting for whole 30 secs even though the element is visible on UI and also clickable?
I tried using latest selenium version, tried using different waits also using different locators. but it did not work
The reasons could be in:
The element belongs to iframe so you need to switch to the iframe prior to attempting locating anything inside it
The element belongs to Shadow DOM so you need to locate ShadowRoot object, cast it to the WebElement and find the sub-element you want to click
Your locator is not correct, try getting the page source and saving it to a file. Once done use your favourite browser developer tools to locate the elemen
The syntax of your Explicit Wait is not correct. Check out Explicit Waits and How to use Selenium to test web applications using AJAX technology for code examples
Going forward consider adding page source and your code to your question as the chance you will get the comprehensive answer will be much higher, otherwise we have to go for "blind shots"

Xcode Time Profiler's detail panel shows that "main" is the reason for app's sluggishness, without showing separate method calls inside it.

I have created a demo app that applies multiple filters to an image (it is inside the project) and shows buttons in a UIScrollView with that images set as a background image. So, all the logic happens in a method that is called right from viewDidLoad. I'm not using any threading mechanism, so all the work is happening on the main thread.
I'm using Instruments, specifically Time Profiler to find out why the app launches so slow (it is obvious, but I would like to see it in Time Profiler).
When I run it I get the following result in the detail panel (in the root):
And when I press the arrow to see the actual code I get the following:
And this is for every filter operation.
Shouldn't the panel show the actual method inside of which I do filtering?
The main function is not the cause of your app being slow. In your screenshot the listing for main says you spent 0 seconds in main.
The Time Profiler instrument records the call stack 1000 times per second. The main function is the starting point for your app. That means main is going to be on the call stack most of the time your app is running, even though your app is not in main most of that time. The main function being on the call stack is the reason for the 649 ms and 95.5% listings in your screenshot.
Do not worry about the listing for the main function. You have no control over main.
If you want to find your functions in the call tree, select the Invert Call Tree and Hide System Libraries checkboxes. Selecting those checkboxes makes it easier to find your code in the call tree.

executeOfflineCommand skips a command while executing from storage on Android

I have to execute "Start" and "Finish" Commands in the Sequential Order in my program and synchronize everything at the end. So I'm inserting the Offline commands in the order first and assuming they will execute in the same order. I'm using "List" with "Iterator" for this.
Problem here is: Finish Command will be missed execution in some strange scenarios in the middle and "start" commands will execute next to each other and sending all wrong data and mapped it in a wrong way.
As action will get ID when command executes at the server, I'm keeping tempory id's to map the offline commands in storage(localID). Instaead of List if I use anyother collection will this gets any better? It is hard to reproducing this on simulator. Please review both scenarios and advise where can this approaches go wrong. Thanks
I will add the OfflineCommands into the List and save in the Storage. After that user can perform delete delete operation in the App so that I will retrieve the list and remove the commands which got deleted from storage so now I have filtered list.
Don't synchronize.
That's nearly always a mistake in Codename One. Your code deals with the UI so it should be on the EDT and Display.getInstance().isEDT() should be true.
My guess is that one of the commands in the middle uses one of the following invokeAndBlock() derivatives:
addToQueueAndWait
Modal dialogs
Which triggers a second round of synchronization to run.
You can trace that by reproducing the issue and checking which command in the list is specifically there at each time. Then fix that command so it doesn't block in this way.
Another approach to fixing it is to remove the list immediately when you start processing which will prevent a duplicate execution of commands.

Runnig N times the simulation in anylogic

In my anylogic Project, I want to terminate my execution and run the simulation for N times. in each of the simulation I store my output in an excel file which depends on the run count.
Instead of stopping and running by my click, I want to do it automatically. How can I do that?
I try to use an event and write by while loop (myparm<=N) and in loop I wrote getEngine().run, but it didn't work!
if it is possible please help me.
Thanks
Below is an overview of a methodology of how you can do it using the existing simulation framework used by AnyLogic
You need to make use of the simulation setup in order to run multiple runs of the model and save the output. My suggested setup will be the following:
Have a button on your Simulation Experiment page (The first page you see when running the model) that you will use to start off the multiple model runs. In here you set the engine to not run in real time mode by using
getEngine().setRealTimeMode(false);
you might also want to set the initial seed and some other model parameters that you might also want to change and perhaps save after model execution. When you have setup the model the way you want use run() to start running the model.
Now under the Simulation Experiment setup page under the 'Java actions' section you need to specify what the model must do after it finished running the model. In the 'After simulation run' section write some code to save the data from the model into your Excel files. To access variables and objects from the model use root, e.g.
saveSomeData(root.myDataset);
where saveSomeData is a function on the Simulation page to save my data set found on the model, called myDataset, to an Excel file. It would be great to also save the seed and the specific parameters, if you changed any, to the Excel file for future reference.
Once you have saved the data output from the model you can specify a new seed and perhaps change parameters again and then call the run() again to run the model for another iteration. When the model has finished running it will again call the 'After simulation run' code here, so do put a stop condition otherwise it will just continue running one iteration after the other. You can access the number of model runs by using
getEngine().getRunCount()
Also, your model needs to have some stop condition, otherwise once it starts running it will never stop. You can specify this in the Simulation Experiment page under the 'Model time' section or programatically in your model using
finishSimulation();
In order to run the model cyclically, please use the following code in the Action field of a timeout triggered event or On destroy field of the top-level agent:
new Thread(){
public void run(){
// stops the model
getExperiment().stop();
try {
// delay
this.sleep(1000);
} catch(Exception e) {};
// runs it again
((Simulation) getExperiment()).button.action();
}
}.start();
The model results should be written to the Excel file before executing this code.
As Jaco-Ben suggested, you can specify getEngine().getRunCount() as condition of restarting the Simulation experiment.

Resources