Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            String currentFolder = Directory.GetCurrentDirectory(); //The folder in which Program.cs exists

            //Don't forget to add the REALvisionApiLib to this App's reference
            REALvisionApiLib.RealvisionApi realvisionInstance = new REALvisionApiLib.RealvisionApi(currentFolder);

            // ********************************************************************************//
            //  To call https://realvisiononline.azure-api.net/GetActivationStatus
            // ********************************************************************************//

            var activationStatus = realvisionInstance.getActivationStatus();

            // ********************************************************************************//
            //  To call https://realvisiononline.azure-api.net/ProvideFile
            // ********************************************************************************//


            ////Specify the name of the file you want to slice with it's extension.
            realvisionInstance.FileToSlice = "cubetest.rvwj";

            //Specify where the file is stored
            //If it's stored in the Assets folder, use the Assets folder property
            //If not use the FileFolder property and specify the link to the file folder

            realvisionInstance.AssetsFolder = currentFolder + @"\Assets\";
            //realvisionInstance.FileFolder = currentFolder + @"\Assets\";

            //Specify where you want the downloaded FCode file to be stored.
            //If you don't specify it, the downloaded file will be stored in the same folder as the file you provided to slice

            realvisionInstance.DownloadsFolder = currentFolder + @"\Downloads\";

            //Specify the slicing configs
            realvisionInstance.SupportType      = "n";
            realvisionInstance.PrinterModel     = "IdeaWerk-Speed";
            realvisionInstance.ConfigPresetName = "Recommended";

            String TaskId = realvisionInstance.ProvideFile();

            // ********************************************************************************//
            //  To call https://realvisiononline.azure-api.net/GetProgress
            // ********************************************************************************//

            String progress = realvisionInstance.GetProgress(TaskId);

            // ********************************************************************************//
            //  To call https://realvisiononline.azure-api.net/GetPrintingInformation
            // ********************************************************************************//

            String printingInfos = realvisionInstance.GetPrintingInformation(TaskId);

            // ********************************************************************************//
            //  To call https://realvisiononline.azure-api.net/DownloadFile
            // ********************************************************************************//

            //Note: DownloadFile will first check the progress of the slicing process before downloading the file
            //      which is why you'll notice in the Console that GetProgress is executed a few times before DownloadFile is executed
            realvisionInstance.Downloadfile(TaskId);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // ********************************************************************************//
            //  Initializing the configurations
            // ********************************************************************************//

            string rootFolder = Directory.GetCurrentDirectory();

            if (rootFolder.Contains("bin"))
            {
                rootFolder = Path.Combine(Directory.GetCurrentDirectory() + "../../../../");
            }
            string downloadsFolder = Path.Combine(rootFolder, "downloads");
            string assetsFolder    = Path.Combine(rootFolder, "assets");
            //Initializing a REALvision API instance using the library
            RealvisionApi rv = new REALvisionApiLib.RealvisionApi(rootFolder, downloadsFolder);
            //Getting the list of the STL files to be sliced whose information are stored in the "filesToSlice.json"
            List <NoConfigApiRequest> stlFilesList = rv.GetFilesToSlice(rootFolder + @"/filesToSlice.json");

            // ********************************************************************************//
            //  This is where we execute the whole slicing flow:
            // ********************************************************************************//

            //Execute the slicing flow for every file in the stlFilesList
            foreach (NoConfigApiRequest stlFile in stlFilesList)
            {
                ExecuteSlicingFlow(stlFile);
            }

            // ********************************************************************************//
            //  The whole slicing flow represented by a function "ExecuteSlicingFlow" that takes in the information of the file to slice
            //  in the form of a NoConfigApiRequest class.
            // ********************************************************************************//

            void ExecuteSlicingFlow(NoConfigApiRequest stlFileToSlice)
            {
                Console.WriteLine("=====================================================================================================================");
                Console.WriteLine("Slicing first file : " + stlFileToSlice.FileName);
                Console.WriteLine("=====================================================================================================================");
                Console.WriteLine();
                Console.WriteLine();

                // ********************************************************************************//
                //  To call https://realvisiononline.azure-api.net/GetActivationStatus
                // ********************************************************************************//
                string activationStatus = rv.getActivationStatus();


                if (activationStatus == "true")
                {
                    // ********************************************************************************//
                    //  To call https://realvisiononline.azure-api.net/UploadFile
                    // ********************************************************************************//

                    string fileId = rv.UploadFile(stlFileToSlice.FileName, assetsFolder);

                    // ********************************************************************************//
                    //  To call https://realvisiononline.azure-api.net/StartSlicingTask
                    // ********************************************************************************//

                    string taskId = rv.StartSlicingTask(stlFileToSlice, fileId);

                    // ********************************************************************************//
                    //  To call https://realvisiononline.azure-api.net/GetProgress
                    // ********************************************************************************//

                    double progress = 0;

                    while (progress < 1 && progress != -1)
                    {
                        progress = rv.GetProgress(taskId);
                        Thread.Sleep(TimeSpan.FromSeconds(rv.CheckProgressInterval));
                    }

                    //// ********************************************************************************//
                    ////  To call https://realvisiononline.azure-api.net/GetPrintingInformation
                    //// ********************************************************************************//

                    rv.GetPrintingInformation(taskId);

                    //// ********************************************************************************//
                    ////  To call https://realvisiononline.azure-api.net/DownloadFile
                    //// ********************************************************************************//

                    ////Note: DownloadFile will first check the progress of the slicing process before downloading the file
                    ////      which is why you'll notice in the Console that GetProgress is executed a few times before DownloadFile is executed

                    rv.Downloadfile(taskId, downloadsFolder);
                }
                else
                {
                    Console.WriteLine("The server needs to be activated for you to be able to slice files. Please contact the API administrators for further information.");
                }
            }
        }