Esempio n. 1
0
        private void OnJobInformationRecieved(bool jobInformationSuccess, JobInformationResponse response)
        {
            if (!jobInformationSuccess)
            {
                return;
            }
            octoPiInfo.ProgressBar.value = response.progress.completion * octoPiInfo.ProgressBar.maxValue;
            if (octoPiInfo.PrintedObject != null && octoPiInfo.FileNameText.text.Equals(response.job.file.name))
            {
                return;
            }
            octoPiInfo.FileNameText.text = response.job.file.name;
            string fileName = response.job.file.path ?? response.job.file.name;
            int    lastDot  = fileName.LastIndexOf('.');

            if (lastDot < 0)
            {
                return;
            }
            string stlFileName = fileName.Substring(0, lastDot) + ".stl";
            string objFileName = fileName.Substring(0, lastDot) + ".obj";

            OctoPiClient.GetFileInformation(domain, "local", stlFileName, (fileInformationSuccess, fileInfo) =>
            {
                if (fileInformationSuccess)
                {
                    OctoPiClient.GetFile(fileInfo.refs.download, (getAndStoreSuccess, text) =>
                    {
                        if (!getAndStoreSuccess)
                        {
                            return;
                        }
                        string objText = StlConverter.Converter.ConvertStlText(text, maxNumberOfTriangles);
                        if (objText == null)
                        {
                            return;
                        }
                        Mesh holderMesh     = new Mesh();
                        ObjImporter newMesh = new ObjImporter();
                        holderMesh          = newMesh.ImportFileFromText(objFileName, objText);
                        octoPiInfo.UpdateObjectPrinted(holderMesh);
                    });
                }
            });
        }