Example #1
0
        public void ExportJSON()
        {
            string         filePath = path + "test_export.json";
            RigidNode_Base baseNode = CreateNodeWithChild();

            BXDJSkeletonJson.WriteSkeleton(filePath, baseNode);

            string result = File.ReadAllText(filePath);

            Assert.Greater(result.Length, 50);
        }
Example #2
0
        public void TestOdeza()
        {
            string odezaPath = @"C:\Users\Victo\AppData\Roaming\Autodesk\Synthesis\Robots\Odesza1\\skeleton.json";

            if (!File.Exists(odezaPath))
            {
                return;
            }

            RigidNode_Base loaded = BXDJSkeletonJson.ReadSkeleton(odezaPath);

            Assert.IsNotNull(loaded);
        }
Example #3
0
        /// <summary>
        /// Saves the robot to the directory it was loaded from or the default directory
        /// </summary>
        /// <returns></returns\>
        ///
        public bool ExportRobot()
        {
            try
            {
                WriteLimits(RobotBaseNode);          // write the limits from Inventor to the skeleton

                if (string.IsNullOrEmpty(RobotName)) // If robot has not been named, cancel
                {
                    return(false);
                }

                var robotFolderPath = RobotExporterAddInServer.Instance.AddInSettingsManager.ExportPath + "\\" + RobotName;
                Directory.CreateDirectory(robotFolderPath); // CreateDirectory checks if the folder already exists

                if (!LoadMeshes())                          // Re-export every time because we don't detect changes to the robot CAD
                {
                    return(false);
                }

                BXDJSkeleton.SetupFileNames(RobotBaseNode);
                BXDJSkeletonJson.WriteSkeleton(robotFolderPath + "\\skeleton.json", RobotBaseNode);

                for (var i = 0; i < RobotMeshes.Count; i++)
                {
                    RobotMeshes[i].WriteToFile(robotFolderPath + "\\node_" + i + ".bxda");
                }

                //MessageBox.Show("Your robot was successfully exported to " + robotFolderPath, "Export Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (!RobotExporterAddInServer.Instance.AddInSettingsManager.OpenSynthesis)
                {
                    new ExportSuccessfulForm(robotFolderPath).ShowDialog();
                }

                Settings.Default.ExportCount += 1;     // possibly track the number of exports a user has as another Google Analytics custom field?

                if (Settings.Default.ExportCount == 2) // once user passes 2 exports it will never display again
                {
                    new AnalyticsSurvey().ShowDialog();
                }

                return(true);
            }
            catch (Exception e)
            {
                //TODO: Create a form that displays a simple error message with an option to expand it and view the exception info
                MessageBox.Show("Unable to export robot: " + e.Message, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Example #4
0
        public static RigidNode_Base ReadSkeletonSafe(string path)
        {
            string         jsonPath = path + ".json";
            string         xmlPath  = path + ".bxdj";
            RigidNode_Base node     = null;

            if (File.Exists(jsonPath))
            {
                //Load JSON
                Debug.Log("Loading JSON robot: " + jsonPath);
                node = BXDJSkeletonJson.ReadSkeleton(jsonPath);
            }
            else
            {
                node = BXDJSkeleton.ReadSkeleton(xmlPath);
            }

            return(node);
        }
Example #5
0
        public void ReadJSON()
        {
            string         filePath = path + "test_export.json";
            RigidNode_Base toCreate = CreateNodeWithChild();

            BXDJSkeletonJson.WriteSkeleton(filePath, toCreate);


            RigidNode_Base created = BXDJSkeletonJson.ReadSkeleton(filePath);


            Assert.AreEqual(toCreate.GUID, created.GUID);
            Assert.AreEqual(toCreate.Children.Count, created.Children.Count);

            SkeletalJoint_Base firstJointtoCreate = toCreate.Children.Keys.First <SkeletalJoint_Base>();
            SkeletalJoint_Base firstJointCreated  = created.Children.Keys.First <SkeletalJoint_Base>();

            Assert.AreEqual(
                toCreate.Children[firstJointtoCreate].GetSkeletalJoint().GetJointType(),
                created.Children[firstJointCreated].GetSkeletalJoint().GetJointType()
                );
        }