public void TestSelectComponentsLink(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 = new List <Component2>(); AddLinkComponents(baseLink, componentsToSelect); HashSet <string> componentsToSelectNames = new HashSet <string>(componentsToSelect.Select(component => component.Name2)); CommonSwOperations.SelectComponents(doc, baseLink, true); SelectionMgr selManager = doc.SelectionManager; int numSelected = selManager.GetSelectedObjectCount2(-1); Assert.Equal(componentsToSelect.Count, numSelected); for (int i = 0; i < selManager.GetSelectedObjectCount2(-1); i++) { Component2 comp = selManager.GetSelectedObjectsComponent4(i, -1); Assert.Contains(comp.Name2, componentsToSelectNames); } SwApp.CloseAllDocuments(true); }
public void TestSelectComponentsList(string modelName) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; LinkNode baseNode = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool abortProcess); Assert.False(abortProcess); Link baseLink = baseNode.GetLink(); List <Component2> componentsToSelect = baseLink.SWComponents; HashSet <string> componentsToSelectNames = new HashSet <string>(componentsToSelect.Select(component => component.Name2)); Common.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); }
public void TestWriteRobotToCSV(string modelName, int expNumLines) { ModelDoc2 doc = OpenSWDocument(modelName); LinkNode baseNode = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool abortProcess); Assert.False(abortProcess); Link baseLink = baseNode.GetLink(); 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)); } } }
public void TestLocalizeAxis(string modelName, double[] axis, string coordSys, double[] expected) { ModelDoc2 doc = OpenSWDocument(modelName); ExportHelper helper = new ExportHelper(SwApp); Assert.Equal(expected, helper.LocalizeAxis(axis, coordSys)); Assert.True(SwApp.CloseAllDocuments(true)); }
public void TestGetRefAxes(string modelName, string[] expected) { ModelDoc2 doc = OpenSWDocument(modelName); ExportHelper helper = new ExportHelper(SwApp); Assert.Equal(new List <string>(expected), helper.GetRefAxes()); Assert.True(SwApp.CloseAllDocuments(true)); }
// TODO(SIMINT-164) pm.Show() crashes with drag drop //[Theory] //[InlineData("3_DOF_ARM")] public void TestPropertyManagerOpens(string modelName) { OpenSWDocument(modelName); SwAddin addin = new SwAddin(); addin.ConnectToSW(SwApp, 0); addin.SetupAssemblyExporter(); SwApp.CloseAllDocuments(true); }
public void TestFindHiddenComponens(string modelName, int expected) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; Assert.Equal(expected, Common.FindHiddenComponents(assyDoc.GetComponents(false)).Count); SwApp.CloseAllDocuments(true); }
public void TestShowAllComponents(string modelName) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; Common.ShowAllComponents(doc, new List <string>()); Assert.Equal(0, Common.FindHiddenComponents(assyDoc.GetComponents(false)).Count); SwApp.CloseAllDocuments(true); }
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); }
// TODO(SIMINT-164) pm.Show() crashes with drag drop //[Theory] //[InlineData("3_DOF_ARM")] public void TestPropertyManagerOpenCloseNotOk(string modelName) { OpenSWDocument(modelName); ExportPropertyManager pm = new ExportPropertyManager(SwApp); pm.Show(); pm.Close(false); SwApp.CloseAllDocuments(true); Xunit.Assert.True(true, "Property manager failed to open/close with cancel"); }
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); }
public void TestCreateRobotFromTreeView(string modelName) { ModelDoc2 doc = OpenSWDocument(modelName); ExportHelper helper = new ExportHelper(SwApp); LinkNode baseNode = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool error); Assert.False(error); helper.CreateRobotFromTreeView(baseNode); Assert.NotNull(helper.URDFRobot); Assert.True(SwApp.CloseAllDocuments(true)); }
public void TestSaveSWComponentsList(string modelName) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; object[] componentObjs = assyDoc.GetComponents(false); List <Component2> components = componentObjs.Cast <Component2>().ToList(); List <byte[]> pids = Common.SaveSWComponents(doc, components); Assert.Equal(pids.Count, components.Count); SwApp.CloseAllDocuments(true); }
public void TestRetrieveSWComponentPIDs(string modelName) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; LinkNode baseNode = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool abortProcess); Assert.False(abortProcess); Common.RetrieveSWComponentPIDs(doc, baseNode); Assert.Equal(baseNode.Link.SWComponents.Count, baseNode.Link.SWComponentPIDs.Count); 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); }
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 TestLoadSWComponent(string modelName, byte[] pid) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; LinkNode baseNode = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool abortProcess); Assert.False(abortProcess); baseNode.Link.SWMainComponentPID = baseNode.Link.SWComponentPIDs[0]; Component2 component = Common.LoadSWComponent(doc, baseNode.Link.SWMainComponentPID); Assert.NotNull(component); SwApp.CloseAllDocuments(true); }
public void TestGetCountLink(string modelName, int expected) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; LinkNode baseNode = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool abortProcess); Assert.False(abortProcess); Link baseLink = baseNode.GetLink(); Assert.Equal(expected, Common.GetCount(baseLink)); SwApp.CloseAllDocuments(true); }
public void TestGetJointNames(string modelName, int expNumJoints) { ModelDoc2 doc = OpenSWDocument(modelName); ExportHelper helper = new ExportHelper(SwApp); LinkNode baseNode = Serialization.LoadBaseNodeFromModel(SwApp, 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 TestHideComponents(string modelName) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; List <string> hiddenComponentNames = Common.FindHiddenComponents(assyDoc.GetComponents(false)); List <Component2> hiddenComponents = hiddenComponentNames.Select(name => assyDoc.GetComponentByName(name)).ToList(); Common.ShowAllComponents(doc, new List <string>()); Common.HideComponents(doc, hiddenComponents); List <string> hiddenComponentNames2 = Common.FindHiddenComponents(assyDoc.GetComponents(false)); Assert.Equal(hiddenComponentNames.Count, hiddenComponentNames2.Count); 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); }
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 = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool error); Assert.False(error); helper.CreateRobotFromTreeView(baseNode); helper.ExportRobot(true); Assert.NotNull(helper.URDFRobot); Assert.Equal(expNumLinks, Common.GetCount(helper.URDFRobot.BaseLink)); Assert.True(SwApp.CloseAllDocuments(true)); }
public void TestShowComponents(string modelName) { ModelDoc2 doc = OpenSWDocument(modelName); AssemblyDoc assyDoc = (AssemblyDoc)doc; // AssemblyDoc.GetComponentsByName only works on top level components. List <string> hiddenComponentNames = Common.FindHiddenComponents(assyDoc.GetComponents(true)); List <Component2> hiddenComponents = new List <Component2>(); foreach (string name in hiddenComponentNames) { Component2 hiddenComp = assyDoc.GetComponentByName(name); Assert.NotNull(hiddenComp); hiddenComponents.Add(hiddenComp); } Common.ShowComponents(doc, hiddenComponents); Assert.Equal(0, Common.FindHiddenComponents(assyDoc.GetComponents(true)).Count); 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 = Serialization.LoadBaseNodeFromModel(SwApp, doc, out bool abortProcess); Assert.False(abortProcess); Link baseLink = baseNode.GetLink(); List <Component2> componentsToSelect = baseLink.SWComponents; HashSet <string> componentsToSelectNames = new HashSet <string>(componentsToSelect.Select(component => component.Name2)); Common.SelectComponents(doc, componentsToSelect, true); List <Component2> selectedComponents = new List <Component2>(); Common.GetSelectedComponents(doc, selectedComponents); Assert.Equal(componentsToSelect.Count, selectedComponents.Count); SwApp.CloseAllDocuments(true); }
public void Dispose() { switch (SLDWorksDisposeOption) { case SLDWorksDisposeOption.CloseAllDocument: SwApp?.CloseAllDocuments(true); break; case SLDWorksDisposeOption.CloseAllDocumentAndExit: SwApp?.CloseAllDocuments(true); SwApp?.ExitApp(); break; case SLDWorksDisposeOption.NoAction: break; case SLDWorksDisposeOption.WithActionClose: CloseAction?.Invoke(SwApp); break; default: break; } }
public void Test_ModelDoc_Opens(string modelName) { OpenSWDocument(modelName); Assert.True(SwApp.CloseAllDocuments(true)); }