internal void clearAllData() { copy.Clear(); isTheSame = true; this.m_data.Clear(); this.m_data.Append(new GH_Boolean(isTheSame)); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Warning that this component is OBSOLETE AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This component is OBSOLETE and will be removed " + "in the future. Remove this component from your canvas and replace it by picking the new component " + "from the ribbon."); // Input variables GH_Controller controllerGoo = null; // Catch input data if (!DA.GetData(0, ref controllerGoo)) { return; } // Clear output variables _internalAxisValues.Clear(); _externalAxisValues.Clear(); // Data needed for making the datatree with axis values MechanicalUnitCollection mechanicalUnits = controllerGoo.Value.MotionSystem.MechanicalUnits; int internalAxisValuesPath = 0; int externalAxisValuesPath = 0; List <double> values; GH_Path path; // Make the output datatree with names with a branch for each mechanical unit for (int i = 0; i < mechanicalUnits.Count; i++) { // Get the ABB joint target of the mechanical unit MechanicalUnit mechanicalUnit = mechanicalUnits[i]; JointTarget jointTarget = mechanicalUnit.GetPosition(); // For internal axis values if (mechanicalUnit.Type == MechanicalUnitType.TcpRobot) { values = GetInternalAxisValuesAsList(jointTarget); path = new GH_Path(internalAxisValuesPath); _internalAxisValues.AppendRange(values.ConvertAll(val => new GH_Number(val)), path); internalAxisValuesPath += 1; } // For external axis values else { values = GetExternalAxisValuesAsList(jointTarget); path = new GH_Path(externalAxisValuesPath); _externalAxisValues.AppendRange(values.GetRange(0, mechanicalUnit.NumberOfAxes).ConvertAll(val => new GH_Number(val)), path); externalAxisValuesPath += 1; } } // Output DA.SetDataTree(0, _internalAxisValues); DA.SetDataTree(1, _externalAxisValues); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Input variables GH_Controller controllerGoo = null; // Catch input data if (!DA.GetData(0, ref controllerGoo)) { return; } // Clear output variables _robotJointPositions.Clear(); _externalAxisValues.Clear(); // Data needed for making the datatree with axis values MechanicalUnitCollection mechanicalUnits = controllerGoo.Value.MotionSystem.MechanicalUnits; int externalAxisValuesPath = 0; List <double> values; GH_Path path; // Make the output datatree with names with a branch for each mechanical unit for (int i = 0; i < mechanicalUnits.Count; i++) { // Get the ABB joint target of the mechanical unit MechanicalUnit mechanicalUnit = mechanicalUnits[i]; ABB.Robotics.Controllers.RapidDomain.JointTarget jointTarget = mechanicalUnit.GetPosition(); // For internal axis values if (mechanicalUnit.Type == MechanicalUnitType.TcpRobot) { values = GetInternalAxisValuesAsList(jointTarget); _robotJointPositions.Add(new RobotJointPosition(values)); } // For external axis values else { values = GetExternalAxisValuesAsList(jointTarget); path = new GH_Path(externalAxisValuesPath); _externalAxisValues.AppendRange(values.GetRange(0, mechanicalUnit.NumberOfAxes).ConvertAll(val => new GH_Number(val)), path); externalAxisValuesPath += 1; } } // Output DA.SetDataList(0, _robotJointPositions); DA.SetDataTree(1, _externalAxisValues); }
protected override void CollectVolatileData_FromSources() { base.CollectVolatileData_FromSources(); collectedData.Clear(); collectedData = m_data.Duplicate(); List <GH_ValueListItem> ghValueListItemList = new List <GH_ValueListItem>((IEnumerable <GH_ValueListItem>)m_userItems); m_userItems.Clear(); List <IGH_Goo> ghGooList = new List <IGH_Goo>((IEnumerable <IGH_Goo>)collectedData); for (int index = 0; index < ghGooList.Count; ++index) { IGH_Goo gooIn = ghGooList[index]; m_userItems.Add(new GH_ValueListItem(gooIn.ToString(), "\"" + gooIn.ToString() + "\"", gooIn)); if (index < ghValueListItemList.Count) { m_userItems[index].Selected = ghValueListItemList[index].Selected; } } CollectVolatileData_Custom(); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // =============================================================================================== // Read input parameters // =============================================================================================== bool reset = false; bool clear = true; GH_Structure <IGH_Goo> data; //get values from grasshopper DA.GetDataTree("Data", out data); DA.GetData("Reset", ref reset); DA.GetData("Clear", ref clear); // =============================================================================================== // Applying Values to Class // =============================================================================================== if (reset == true || clear == true) { tree.Clear(); } else { for (int i = 0; i < data.PathCount; i++) { var list = data.get_Branch(i); for (var j = 0; j < list.Count; j++) { var item = list[j]; tree.Append(item as IGH_Goo, new GH_Path(i, j)); } } } // =============================================================================================== // Exporting Data to Grasshopper // =============================================================================================== var a = tree; DA.SetDataTree(0, a); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Warning that this component is OBSOLETE AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This component is OBSOLETE and will be removed in the future."); // Variable for catchint the datatree GH_Structure <IGH_Goo> actions; // Clear the list with targets before catching new input data _targetGoos.Clear(); // Catch the input data if (!DA.GetDataTree(0, out actions)) { return; } if (!DA.GetData(1, ref _displayNames)) { return; } if (!DA.GetData(2, ref _displayPoints)) { return; } if (!DA.GetData(3, ref _displayDirections)) { return; } if (!DA.GetData(4, ref _color)) { return; } if (!DA.GetData(5, ref _textSize)) { return; } if (!DA.GetData(6, ref _pointSize)) { return; } // Get the paths of the datatree with actions var paths = actions.Paths; // Check and concert the input data to the right datatype (target) for (int i = 0; i < actions.Branches.Count; i++) { var branches = actions.Branches[i]; GH_Path iPath = paths[i]; for (int j = 0; j < branches.Count; j++) { // Get the target from the movement instance if the input data is a movement if (actions.Branches[i][j] is GH_Movement) { GH_Movement movementGoo = actions.Branches[i][j] as GH_Movement; GH_Target targetGoo = new GH_Target(movementGoo.Value.Target); _targetGoos.Append(targetGoo, iPath); } // Get the target data directly if the input data is a target else if (actions.Branches[i][j] is GH_Target) { GH_Target targetGoo = actions.Branches[i][j] as GH_Target; _targetGoos.Append(targetGoo, iPath); } // Make a target from the input plane if the input data is a plane else if (actions.Branches[i][j] is GH_Plane) { string targetName; if (actions.Branches.Count == 1) { targetName = "plane" + "_" + j; } else { targetName = "plane" + "_" + i + "_" + j; } GH_Plane planeGoo = actions.Branches[i][j] as GH_Plane; RobotTarget target = new RobotTarget(targetName, planeGoo.Value); GH_Target targetGoo = new GH_Target(target); _targetGoos.Append(targetGoo, iPath); } // Let all other data pass (raise no warning or error) else { // empty } } } }
public override void ClearData() { base.ClearData(); _plateName.Clear(); _platePos.Clear(); }
public override void ClearData() { base.ClearData(); _frameTags.Clear(); _tagPos.Clear(); }
public override void ClearData() { base.ClearData(); _frameName.Clear(); _framePos.Clear(); }
protected override void SolveInstance(IGH_DataAccess DA) { int indexs = 0; if (!DA.GetData(1, ref indexs)) { return; } #region GH_Structure <IGH_Goo> x = (GH_Structure <IGH_Goo>) this.Params.Input[0].VolatileData; List <GH_Structure <IGH_Goo> > last = new List <GH_Structure <IGH_Goo> >(); List <int> contains = new List <int>(); for (int i = 0; i < x.PathCount; i++) { if (contains.Contains(i)) { continue; //重复的index } GH_Structure <IGH_Goo> tree = new GH_Structure <IGH_Goo>(); GH_Path path = x.get_Path(i); tree.AppendRange(x.Branches[i], path); contains.Add(i); string testPath = System.Text.RegularExpressions.Regex.Replace(path.ToString(), @";\d+}", ""); for (int q = 0; q < x.PathCount; q++) { if (i == q || contains.Contains(q)) { continue; } GH_Path path2 = x.get_Path(q); string testPath2 = System.Text.RegularExpressions.Regex.Replace(path2.ToString(), @";\d+}", ""); if (testPath == testPath2) { tree.AppendRange(x.Branches[q], path2); contains.Add(q); } } last.Add(tree); } NewTreePath = last.Count;/////// #endregion DA.DisableGapLogic(); if (DA.Iteration <= 0 && (x != null) && !x.IsEmpty) { if (last.Count > this.Params.Output.Count - 1 && this.Params.Output.Count > 1) { int count = newTreePath - this.Params.Output.Count + 1; string warning = string.Format("还有{0}个单一路径树形数据未显示在输出端", count); this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, warning); } int num2 = this.Params.Output.Count; for (int i = 1; i < num2; i++)///从第二项开始 { GH_Structure <IGH_Goo> structure2 = (GH_Structure <IGH_Goo>) this.Params.Output[i].VolatileData; structure2.Clear(); if (i > last.Count) { this.Params.Output[i].NickName = "-"; this.Params.Output[i].Name = "空数据"; this.Params.Output[i].Description = "无数据输出"; } else { string newName = System.Text.RegularExpressions.Regex.Replace(last[i - 1].get_Path(0).ToString(), @"\d+}", ""); this.Params.Output[i].NickName = newName + "xx}"; string newName2 = System.Text.RegularExpressions.Regex.Replace(this.Params.Output[i].NickName, @"\d+}", ""); this.Params.Output[i].Description = string.Format("路径类型:{0}", newName2); this.Params.Output[i].Name = "树形数据"; DA.SetDataTree(i, last[i - 1]); } } } if ((x != null) && !x.IsEmpty) { DA.SetDataTree(0, last[indexs]); } }