Пример #1
0
        public virtual void GenerateScriptFiles()
        {
            // <local, remote>

            Dictionary <string, string> componentPaths = new Dictionary <string, string>();

            foreach (var item in cadDataContainer.CADManifestList)
            {
                try
                {
                    componentPaths.Add(item.Value.LocalFolderPath, item.Value.RemoteMETAProPath);
                }
                catch (ArgumentException)
                {
                    // A warning here is too excessive and is scares the user. This is part of the normal operation.
                    // Logger.Instance.AddLogMessage("Duplicate path in CADManifestlist: " + item.Value.LocalFolderPath + "=" + item.Value.RemoteMETAProPath, Severity.Warning);
                }
            }

            if (!MetaLink)
            {
                // cad manifest
                // META-2147: Workaround until VF + Adam implements the additional component in manifest.project.json to indicate the source of a component
                // empty cad manifest is generated for this workaround
                //cadDataContainer.GenerateCADManifest(this.OutputDirectory);
                CadManifestObjectList emptyCadManifest = new CadManifestObjectList();
                using (StreamWriter writer = new StreamWriter(Path.Combine(this.OutputDirectory, "cad.manifest.json")))
                {
                    string line = Newtonsoft.Json.JsonConvert.SerializeObject(emptyCadManifest,
                                                                              Newtonsoft.Json.Formatting.Indented);
                    writer.WriteLine(line);
                }

                // zip.py
                Template.zip_to_remote_py remotezip = new Template.zip_to_remote_py()
                {
                    CadFolders = componentPaths.Values.ToList()      //CadFolders = cadDataContainer.GetRemoteCadFolders()
                };
                using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "zip.py")))
                {
                    writer.WriteLine(remotezip.TransformText());
                }
            }
            string relativeAuxDir = "";
            // search_META.pro
            List <string> cad_search_paths = new List <string>();

            cad_search_paths.AddRange(componentPaths.Keys.ToList());       //cad_search_paths.AddRange(cadDataContainer.GetLocalCadFolders());
            if (CadAuxiliaryDirectory != "")
            {
                Uri uricad = new Uri(Path.GetFullPath(CadAuxiliaryDirectory));
                Uri uriout = new Uri(Path.Combine(OutputDirectory, "abc.xyz"));
                relativeAuxDir = Uri.UnescapeDataString(uriout.MakeRelativeUri(uricad).ToString().Replace('/', '\\'));
                cad_search_paths.Insert(0, relativeAuxDir);
            }

            // MOT-243 This adds orphan/unassembled components to the Creo paths in search_META.pro
            foreach (var item in cadDataContainer.orphans
                     .Where(c => !String.IsNullOrWhiteSpace(c.ModelURI)))
            {
                Uri    uricad      = new Uri(Path.Combine(Path.GetFullPath(item.CyPhyModelPath), item.ModelURI));
                Uri    uriout      = new Uri(Path.Combine(OutputDirectory, "abc.xyz"));
                String relativeDir = Uri.UnescapeDataString(uriout.MakeRelativeUri(uricad).ToString().Replace('/', '\\'));

                cad_search_paths.Add(relativeDir);
            }

            Template.search_meta_local searchmeta = new Template.search_meta_local()
            {
                CadFolders = cad_search_paths
            };
            using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "search_META.pro")))
            {
                writer.WriteLine(searchmeta.TransformText());
            }

            // META-3442
            if (this.CopySTL)
            {
                Template.copy_bat copystl = new Template.copy_bat()
                {
                    CadFolders = cad_search_paths
                };
                using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "Copy_STL.cmd")))
                {
                    writer.WriteLine(copystl.TransformText());
                }
            }

            // copy.bat
            // META-2147: Workaround            //if (CadAuxiliaryDirectory != "")
            {
                Template.copy_parts_full_py copybat = new Template.copy_parts_full_py()
                {
                    CadFolders = componentPaths,
                    AuxFolder  = relativeAuxDir
                };
                using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "Copy_Parts.py"))) //using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "Copy_Parts.bat")))
                {
                    writer.WriteLine(copybat.TransformText());
                }
            }
        }
Пример #2
0
        public virtual void GenerateScriptFiles()
        {
            // <local, remote>
            
            Dictionary<string, string> componentPaths = new Dictionary<string, string>();
            foreach (var item in cadDataContainer.CADManifestList)
            {
                try
                {
                    componentPaths.Add(item.Value.LocalFolderPath, item.Value.RemoteMETAProPath);
                }
                catch (ArgumentException)
                {
                    // A warning here is too excessive and is scares the user. This is part of the normal operation.
                    // Logger.Instance.AddLogMessage("Duplicate path in CADManifestlist: " + item.Value.LocalFolderPath + "=" + item.Value.RemoteMETAProPath, Severity.Warning);
                }
            }

            if (!MetaLink)
            {
                // cad manifest
                // META-2147: Workaround until VF + Adam implements the additional component in manifest.project.json to indicate the source of a component
                // empty cad manifest is generated for this workaround
                //cadDataContainer.GenerateCADManifest(this.OutputDirectory);
                CadManifestObjectList emptyCadManifest = new CadManifestObjectList();
                using (StreamWriter writer = new StreamWriter(Path.Combine(this.OutputDirectory, "cad.manifest.json")))
                {
                    string line = Newtonsoft.Json.JsonConvert.SerializeObject(emptyCadManifest,
                                                                              Newtonsoft.Json.Formatting.Indented);
                    writer.WriteLine(line);
                }

                // zip.py
                Template.zip_to_remote_py remotezip = new Template.zip_to_remote_py()
                {
                    CadFolders = componentPaths.Values.ToList()      //CadFolders = cadDataContainer.GetRemoteCadFolders()
                };
                using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "zip.py")))
                {
                    writer.WriteLine(remotezip.TransformText());
                }
            }
            string relativeAuxDir = "";
            // search_META.pro
            List<string> cad_search_paths = new List<string>();
            cad_search_paths.AddRange(componentPaths.Keys.ToList());       //cad_search_paths.AddRange(cadDataContainer.GetLocalCadFolders());
            if (CadAuxiliaryDirectory != "")
            {
                Uri uricad = new Uri(Path.GetFullPath(CadAuxiliaryDirectory));
                Uri uriout = new Uri(Path.Combine(OutputDirectory, "abc.xyz"));
                relativeAuxDir = Uri.UnescapeDataString(uriout.MakeRelativeUri(uricad).ToString().Replace('/', '\\'));
                cad_search_paths.Insert(0, relativeAuxDir);
            }

            Template.search_meta_local searchmeta = new Template.search_meta_local()
            {
                CadFolders = cad_search_paths
            };
            using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "search_META.pro")))
            {
                writer.WriteLine(searchmeta.TransformText());
            }

            // META-3442
            if (this.CopySTL)
            {
                Template.copy_bat copystl = new Template.copy_bat()
                {
                    CadFolders = cad_search_paths
                };
                using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "Copy_STL.cmd")))
                {
                    writer.WriteLine(copystl.TransformText());
                }
            }

            // copy.bat
            // META-2147: Workaround            //if (CadAuxiliaryDirectory != "")
            {
                Template.copy_parts_full_py copybat = new Template.copy_parts_full_py()
                {
                    CadFolders = componentPaths,
                    AuxFolder = relativeAuxDir
                };
                using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "Copy_Parts.py"))) //using (StreamWriter writer = new StreamWriter(Path.Combine(OutputDirectory, "Copy_Parts.bat")))
                {
                    writer.WriteLine(copybat.TransformText());
                }
            }
        }