Call Saved Project using in .NET

Forum Forums Visual Components 4.0 .NET Addon Programming Call Saved Project using in .NET

This topic contains 3 replies, has 3 voices, and was last updated by TSy TSy 6 days, 19 hours ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14288
    Avatar
    jaisantosh.d
    Participant

    Hello guys,

     

    I am trying to call the saved project (in .vcmx file format) in .NET and run that file using .NET command. But currently I am not able to understand how to call the .vcmx file in class library. If anyone have any solution (with example) then kindly reply me so that I can apply it to my work.

    #14290
    zesty
    zesty
    Moderator

    I don’t have access to the API atm, but you can execute a file using System.Diagnostics.Process.Start(filePath). This will open the file in its default program, e.g. mylayout.vcmx in VC 4.1.1.

    Here are some examples from Web -> https://www.dotnetperls.com/process

    If you want to open the saved project using .NET API, I believe there are already examples of this on the forum. If not, take a look at IApplication and ISimWorld. Also, check ICommandRegistry for a .NET command that can be called to open a layout.

    #14295
    Avatar
    jaisantosh.d
    Participant

    Hello Zesty,

    Thanks for reply.

    I have tried the same but getting error ‘IoC is not itialized’.

    Below is my code. check and let me know what I am doing wrong.

    class Program
    {
    static void Main(string[] args)
    {
    System.Diagnostics.Process.Start(@”F:\WORK\May_2019\FoodPackagingProcess_03052019.vcmx”);
    Myplugin myplugin = new Myplugin();
    myplugin.StartRecording();

    }
    }

    public class Myplugin : IPlugin
    {
    public void Exit()
    {

    }

    public void Initialize()
    {

    }
    public IVideoRecorder videoRecorder = null;
    public void StartRecording()
    {
    //Reset simulation to stop recording
    var app = IoC.Get<IApplication>();
    app.Simulation.SimulationReset += OnSimulationReset;

    //Set and Start Video recording
    videoRecorder = IoC.Get<IVideoRecordExporter>();
    videoRecorder.Start();

    //start simulation
    var runtime = IoC.Get<ISimulationSettingViewModel>().SimulationRunTime;
    IoC.Get<ISimulationService>().SwitchRunState(runtime, 0);

    }

    public void OnSimulationReset(Object sender, EventArgs e)
    {
    //Stop video Recording
    string pathtosave = @”F:\WORK\video.avi”;
    videoRecorder.Stop(IoC.Get<IUrlHelper>().LocalPathToUrl(pathtosave, false));
    }

    }

     

    #14357
    TSy
    TSy
    Participant

    The Visual Components’ .NET API is only usable within plugins that are loaded into the Visual Components application at runtime. You can’t use the API from another process.

    If you need such functionality, you need to create a plugin that implements some kind of specialized cross-process interface (what kind of interface is up to you), which your other applications can then call.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.