public void TestSelectComponentsList(string modelName)
        {
            ModelDoc2   doc      = OpenSWDocument(modelName);
            AssemblyDoc assyDoc  = (AssemblyDoc)doc;
            LinkNode    baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);

            Link baseLink = baseNode.RebuildLink();
            List <Component2> componentsToSelect      = baseLink.SWComponents;
            HashSet <string>  componentsToSelectNames =
                new HashSet <string>(componentsToSelect.Select(component => component.Name2));

            CommonSwOperations.SelectComponents(doc, componentsToSelect, true);
            SelectionMgr selManager = doc.SelectionManager;

            // -1 is the Mark, set to negative one if it's not being used.
            int numSelected = selManager.GetSelectedObjectCount2(-1);

            Assert.Equal(componentsToSelect.Count, numSelected);

            for (int i = 0; i < selManager.GetSelectedObjectCount2(-1); i++)
            {
                // -1 is the Mark, set to negative one if it's not being used.
                Component2 comp = selManager.GetSelectedObjectsComponent4(i, -1);
                Assert.Contains(comp.Name2, componentsToSelectNames);
            }

            SwApp.CloseAllDocuments(true);
        }
Пример #2
0
        public void TestWriteRobotToCSV(string modelName, int expNumLines)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);
            Link  baseLink = baseNode.RebuildLink();
            Robot robot    = new Robot();

            robot.SetBaseLink(baseLink);

            string tempFile = Path.GetTempFileName();

            try
            {
                ImportExport.WriteRobotToCSV(robot, tempFile);
                Assert.True(File.Exists(tempFile));

                string[] text = File.ReadAllLines(tempFile);
                Assert.Equal(expNumLines, text.Length);
            }
            catch (Exception e)
            {
                Assert.True(false, "Failed to write robot to CSV " + e.Message);
            }
            finally
            {
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                    Assert.True(SwApp.CloseAllDocuments(true));
                }
            }
        }
Пример #3
0
        public void TestLoadBaseNodeFromModel(string modelName, int expNumLinks)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool error);

            Xunit.Assert.False(error);
            Xunit.Assert.NotNull(baseNode);
            Xunit.Assert.Equal(expNumLinks, CommonSwOperations.GetCount(baseNode.RebuildLink()));
        }
        public void TestGetCountNodeCollection(string modelName, int expected)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);

            Assert.Equal(expected, CommonSwOperations.GetCount(baseNode.Nodes));

            SwApp.CloseAllDocuments(true);
        }
        public void TestLoadSWComponentsList(string modelName)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);
            List <Component2> components = CommonSwOperations.LoadSWComponents(doc, baseNode.Link.SWComponentPIDs);

            Assert.Equal(baseNode.Link.SWComponentPIDs.Count, components.Count);

            SwApp.CloseAllDocuments(true);
        }
Пример #6
0
        public void TestCreateRobotFromTreeView(string modelName)
        {
            ModelDoc2    doc      = OpenSWDocument(modelName);
            ExportHelper helper   = new ExportHelper(SwApp);
            LinkNode     baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool error);

            Assert.False(error);

            helper.CreateRobotFromTreeView(baseNode);
            Assert.NotNull(helper.URDFRobot);
            Assert.True(SwApp.CloseAllDocuments(true));
        }
        public void TestLoadSWComponent(string modelName)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);
            baseNode.Link.SWMainComponentPID = baseNode.Link.SWComponentPIDs[0];
            Component2 component = CommonSwOperations.LoadSWComponent(doc, baseNode.Link.SWMainComponentPID);

            Assert.NotNull(component);

            SwApp.CloseAllDocuments(true);
        }
        public void TestLoadSWComponentsLinkNode(string modelName)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);
            List <string> problemLinks = new List <string>();

            CommonSwOperations.LoadSWComponents(doc, baseNode, problemLinks);
            Assert.Empty(problemLinks);

            SwApp.CloseAllDocuments(true);
        }
Пример #9
0
        public void TestSerializeToString(string modelName)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool error);

            Xunit.Assert.False(error);

            PrivateType serialization = new PrivateType(typeof(ConfigurationSerialization));
            string      newData       = (string)serialization.InvokeStatic(
                "SerializeToString", new object[] { baseNode });

            Xunit.Assert.NotNull(newData);
            Xunit.Assert.NotEmpty(newData);
        }
Пример #10
0
        public void TestGetJointNames(string modelName, int expNumJoints)
        {
            ModelDoc2    doc      = OpenSWDocument(modelName);
            ExportHelper helper   = new ExportHelper(SwApp);
            LinkNode     baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool error);

            Assert.False(error);
            helper.CreateRobotFromTreeView(baseNode);
            helper.ExportRobot(true);
            List <string> jointNames = helper.GetJointNames();

            Assert.NotNull(jointNames);
            Assert.Equal(jointNames.Count, expNumJoints);
            Assert.True(SwApp.CloseAllDocuments(true));
        }
        public void TestSaveSWComponent(string modelName, string componentName, byte[] expected)
        {
            ModelDoc2   doc       = OpenSWDocument(modelName);
            AssemblyDoc assyDoc   = (AssemblyDoc)doc;
            Component2  component = assyDoc.GetComponentByName(componentName);

            Assert.NotNull(component);
            LinkNode baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);
            baseNode.Link.SWMainComponent = component;
            byte[] pid = CommonSwOperations.SaveSWComponent(doc, baseNode.Link.SWMainComponent);
            Assert.NotNull(pid);
            Assert.Equal(expected.Length, pid.Length);
            SwApp.CloseAllDocuments(true);
        }
Пример #12
0
        public void TestExportRobotSkipVisual(string modelName, int expNumLinks)
        {
            ModelDoc2    doc    = OpenSWDocument(modelName);
            ExportHelper helper = new ExportHelper(SwApp);

            helper.SetComputeInertial(true);
            helper.SetComputeJointKinematics(true);
            helper.SetComputeJointLimits(true);
            helper.SetComputeVisualCollision(false);
            LinkNode baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool error);

            Assert.False(error);
            helper.CreateRobotFromTreeView(baseNode);
            helper.ExportRobot(true);
            Assert.NotNull(helper.URDFRobot);
            Assert.Equal(expNumLinks, CommonSwOperations.GetCount(helper.URDFRobot.BaseLink));
            Assert.True(SwApp.CloseAllDocuments(true));
        }
        public void TestSaveSWComponentsLink(string modelName)
        {
            ModelDoc2 doc      = OpenSWDocument(modelName);
            LinkNode  baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);

            List <string> problemLinks = new List <string>();

            CommonSwOperations.LoadSWComponents(doc, baseNode, problemLinks);
            Assert.Empty(problemLinks);

            Link baseLink = baseNode.RebuildLink();

            baseLink.SWMainComponent = baseLink.SWComponents[0];
            CommonSwOperations.SaveSWComponents(doc, baseLink);
            Assert.Equal(baseLink.SWComponents.Count, baseLink.SWComponentPIDs.Count);
            Assert.NotNull(baseLink.SWMainComponentPID);

            SwApp.CloseAllDocuments(true);
        }
        public void TestGetSelectedComponents(string modelName)
        {
            ModelDoc2   doc      = OpenSWDocument(modelName);
            AssemblyDoc assyDoc  = (AssemblyDoc)doc;
            LinkNode    baseNode = ConfigurationSerialization.LoadBaseNodeFromModel(doc, out bool abortProcess);

            Assert.False(abortProcess);

            Link baseLink = baseNode.RebuildLink();
            List <Component2> componentsToSelect      = baseLink.SWComponents;
            HashSet <string>  componentsToSelectNames =
                new HashSet <string>(componentsToSelect.Select(component => component.Name2));

            CommonSwOperations.SelectComponents(doc, componentsToSelect, true);
            List <Component2> selectedComponents = new List <Component2>();

            CommonSwOperations.GetSelectedComponents(doc, selectedComponents);
            Assert.Equal(componentsToSelect.Count, selectedComponents.Count);

            SwApp.CloseAllDocuments(true);
        }