Ejemplo n.º 1
0
        private static void WriteAttributesToFile()
        {
            var folderPath = FileTools.TryOpenFolder("Select Source Directory");

            if (string.IsNullOrEmpty(folderPath))
            {
                return;
            }

            var meshesByAttribute = new Dictionary <string, List <string> >();


            foreach (var file in Directory.EnumerateFiles(folderPath, "*numshb", SearchOption.AllDirectories))
            {
                var node = new NUMSHB_Node(file);
                node.Open();

                UpdateMeshAttributes(folderPath, meshesByAttribute, file, node);
            }

            foreach (var pair in meshesByAttribute)
            {
                var outputText = new System.Text.StringBuilder();
                foreach (var value in pair.Value)
                {
                    outputText.AppendLine(value);
                }

                File.WriteAllText($"{pair.Key} Meshes.txt", outputText.ToString());
            }
        }
Ejemplo n.º 2
0
        private static void UpdateMeshAttributes(string folderPath, Dictionary <string, List <string> > meshesByAttribute, string file, NUMSHB_Node node)
        {
            foreach (var meshObject in node.mesh.Objects)
            {
                foreach (var attribute in meshObject.Attributes)
                {
                    if (!meshesByAttribute.ContainsKey(attribute.Name))
                    {
                        meshesByAttribute.Add(attribute.Name, new List <string>());
                    }

                    var text = $"{meshObject.Name} {file.Replace(folderPath, "")}";
                    if (!meshesByAttribute[attribute.Name].Contains(text))
                    {
                        meshesByAttribute[attribute.Name].Add(text);
                    }
                }
            }
        }