/// <summary> /// The lightweight equivalent of the 'Add From Inventor' button in the <see cref="ExporterForm"/>. Used in <see cref="ExportMeshesLite(RigidNode_Base)"/> /// </summary> /// <param name="occurrences"></param> /// <returns></returns> public RigidNode_Base ExportSkeleteonLite(List <ComponentOccurrence> occurrences) { if (occurrences.Count == 0) { throw new ArgumentException("ERROR: 0 Occurrences passed to ExportSkeletonLite", "occurrences"); } #region CenterJoints int NumCentered = 0; SetProgressText(string.Format("Centering Joints {0} / {1}", NumCentered, occurrences.Count)); foreach (ComponentOccurrence component in occurrences) { Exporter.CenterAllJoints(component); NumCentered++; SetProgressText(string.Format("Centering Joints {0} / {1}", NumCentered, occurrences.Count)); } #endregion #region Build Models //Getting Rigid Body Info... SetProgressText("Getting Rigid Body Info...", ProgressTextType.ShortTaskBegin); NameValueMap RigidGetOptions = InventorManager.Instance.TransientObjects.CreateNameValueMap(); RigidGetOptions.Add("DoubleBearing", false); RigidBodyResults RawRigidResults = InventorManager.Instance.AssemblyDocument.ComponentDefinition.RigidBodyAnalysis(RigidGetOptions); //Getting Rigid Body Info...Done SetProgressText(null, ProgressTextType.ShortTaskEnd); CustomRigidResults RigidResults = new CustomRigidResults(RawRigidResults); //Building Model... SetProgressText("Building Model...", ProgressTextType.ShortTaskBegin); RigidBodyCleaner.CleanGroundedBodies(RigidResults); RigidNode baseNode = RigidBodyCleaner.BuildAndCleanDijkstra(RigidResults); //Building Model...Done SetProgressText(null, ProgressTextType.ShortTaskEnd); #endregion #region Cleaning Up //Cleaning Up... LiteExporterForm.Instance.SetProgressText("Cleaning Up...", ProgressTextType.ShortTaskBegin); List <RigidNode_Base> nodes = new List <RigidNode_Base>(); baseNode.ListAllNodes(nodes); foreach (RigidNode_Base node in nodes) { node.ModelFileName = ((RigidNode)node).group.ToString(); node.ModelFullID = node.GetModelID(); } //Cleaning Up...Done LiteExporterForm.Instance.SetProgressText(null, ProgressTextType.ShortTaskEnd); #endregion return(baseNode); }
public static RigidNode_Base ExportSkeleton(List <ComponentOccurrence> occurrences) { if (occurrences.Count == 0) { throw new Exception("No components selected!"); } SynthesisGUI.Instance.ExporterSetOverallText("Centering joints"); SynthesisGUI.Instance.ExporterReset(); SynthesisGUI.Instance.ExporterSetSubText("Centering 0 / 0"); SynthesisGUI.Instance.ExporterSetProgress(0); SynthesisGUI.Instance.ExporterSetMeshes(2); int numOccurrences = occurrences.Count; SynthesisGUI.Instance.ExporterStepOverall(); SynthesisGUI.Instance.ExporterSetOverallText("Getting rigid info"); Console.WriteLine("Get rigid info..."); //Group components into rigid bodies. NameValueMap options = InventorManager.Instance.TransientObjects.CreateNameValueMap(); options.Add("DoubleBearing", false); RigidBodyResults rigidResults = InventorManager.Instance.AssemblyDocument.ComponentDefinition.RigidBodyAnalysis(options); Console.WriteLine("Got rigid info..."); CustomRigidResults customRigid = new CustomRigidResults(rigidResults); Console.WriteLine("Build model..."); RigidBodyCleaner.CleanGroundedBodies(customRigid); //After this point, all grounded groups have been merged into one CustomRigidGroup, and their joints have been updated. RigidNode baseNode = RigidBodyCleaner.BuildAndCleanDijkstra(customRigid); Console.WriteLine("Built"); Console.WriteLine(baseNode.ToString()); SynthesisGUI.Instance.ExporterStepOverall(); List <RigidNode_Base> nodes = new List <RigidNode_Base>(); baseNode.ListAllNodes(nodes); foreach (RigidNode_Base node in nodes) { node.ModelFileName = ((RigidNode)node).group.ToString(); node.ModelFullID = node.GetModelID(); } return(baseNode); }
public static RigidNode_Base ExportSkeleton(IProgress <ProgressUpdate> progress) { // If no components if (RobotExporterAddInServer.Instance.OpenAssemblyDocument.ComponentDefinition.Occurrences.OfType <ComponentOccurrence>().ToList().Count == 0) { return(null); } //Getting Rigid Body Info... progress?.Report(new ProgressUpdate("Getting physics info...", 1, 4)); var rigidGetOptions = RobotExporterAddInServer.Instance.Application.TransientObjects.CreateNameValueMap(); rigidGetOptions.Add("DoubleBearing", false); var asmDocument = RobotExporterAddInServer.Instance.OpenAssemblyDocument; var rawRigidResults = asmDocument.ComponentDefinition.RigidBodyAnalysis(rigidGetOptions); var rigidResults = new CustomRigidResults(rawRigidResults); try { RigidBodyCleaner.CleanGroundedBodies(rigidResults); } catch (NoGroundException) { WinFormsUtils.ShowErrorDialog("Please ground a part in your assembly to export your robot.", "No Ground"); return(null); } //Building Model... progress?.Report(new ProgressUpdate("Building model...", 2, 4)); var skeletonBase = RigidBodyCleaner.BuildAndCleanDijkstra(rigidResults); //Cleaning Up... progress?.Report(new ProgressUpdate("Cleaning up...", 3, 4)); var nodes = new List <RigidNode_Base>(); skeletonBase.ListAllNodes(nodes); foreach (var node in nodes) { node.ModelFileName = ((RigidNode)node).group.ToString(); node.ModelFullID = node.GetModelID(); } progress?.Report(new ProgressUpdate("Done", 4, 4)); return(skeletonBase); }
/// <summary> /// The lightweight equivalent of the 'Add From Inventor' button in the <see cref="ExporterForm"/>. Used in <see cref="ExportMeshesLite(RigidNode_Base)"/> /// </summary> /// <param name="occurrences"></param> /// <returns></returns> public RigidNode_Base ExportSkeleton(List <ComponentOccurrence> occurrences) { if (occurrences.Count == 0) { throw new Exporter.EmptyAssemblyException(); } #region Build Models //Getting Rigid Body Info... SetProgress("Getting physics info...", occurrences.Count, occurrences.Count + 3); NameValueMap RigidGetOptions = InventorManager.Instance.TransientObjects.CreateNameValueMap(); RigidGetOptions.Add("DoubleBearing", false); RigidBodyResults RawRigidResults = InventorManager.Instance.AssemblyDocument.ComponentDefinition.RigidBodyAnalysis(RigidGetOptions); //Getting Rigid Body Info...Done CustomRigidResults RigidResults = new CustomRigidResults(RawRigidResults); //Building Model... SetProgress("Building model...", occurrences.Count + 1, occurrences.Count + 3); RigidBodyCleaner.CleanGroundedBodies(RigidResults); RigidNode baseNode = RigidBodyCleaner.BuildAndCleanDijkstra(RigidResults); //Building Model...Done #endregion #region Cleaning Up //Cleaning Up... SetProgress("Cleaning up...", occurrences.Count + 2, occurrences.Count + 3); List <RigidNode_Base> nodes = new List <RigidNode_Base>(); baseNode.ListAllNodes(nodes); foreach (RigidNode_Base node in nodes) { node.ModelFileName = ((RigidNode)node).group.ToString(); node.ModelFullID = node.GetModelID(); } //Cleaning Up...Done #endregion SetProgress("Done", occurrences.Count + 3, occurrences.Count + 3); return(baseNode); }