/// <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)
        {
            Plane               positionPlane = Plane.WorldXY;
            RobotTool           tool          = null;
            List <ExternalAxis> externalAxis  = new List <ExternalAxis>();

            if (!DA.GetData(0, ref positionPlane))
            {
                return;
            }
            if (!DA.GetData(1, ref tool))
            {
                tool = new RobotTool();
            }
            if (!DA.GetDataList(2, externalAxis))
            {
                externalAxis = new List <ExternalAxis>()
                {
                };
            }

            Robot robot = new Robot();

            if (_robotPreset == RobotPreset.EMPTY | _fromMenu)
            {
                _robotPreset = GetRobotPreset();
            }

            try
            {
                robot = Robot.GetRobotPreset(_robotPreset, positionPlane, tool, externalAxis);

                int position = robot.Name.IndexOf("-");

                if (position < 0)
                {
                    this.Message = robot.Name;
                }
                else
                {
                    this.Message = robot.Name.Substring(0, position);
                }

                this.ExpirePreview(true);
            }
            catch (Exception ex)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, ex.Message);
            }

            DA.SetData(0, robot);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the Robot preset name.
        /// </summary>
        /// <param name="preset"> The Robot preset. </param>
        /// <returns> The name of the Robot preset. </returns>
        private static string GetRobotPresetName(RobotPreset preset)
        {
            string name = Enum.GetName(typeof(RobotPreset), preset);

            name = name.ReplaceFirst("_", "-");
            name = name.ReplaceFirst("_", "/");
            name = name.ReplaceFirst("/0", "/0.");
            name = name.ReplaceFirst("/1", "/1.");
            name = name.ReplaceFirst("/2", "/2.");
            name = name.ReplaceFirst("/3", "/3.");
            name = name.ReplaceFirst("/4", "/4.");

            return(name);
        }
 /// <summary>
 /// Read our own fields. Needed for (de)serialization of the variable input parameters.
 /// </summary>
 /// <param name="reader"> Provides access to a subset of GH_Chunk methods used for reading archives. </param>
 /// <returns> True on success, false on failure. </returns>
 public override bool Read(GH_IReader reader)
 {
     byte[] array = reader.GetByteArray("Robot Preset");
     _robotPreset = (RobotPreset)RobotComponents.Utils.HelperMethods.ByteArrayToObject(array);
     return(base.Read(reader));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a predefined ABB Robot preset.
        /// </summary>
        /// <param name="preset"> The Robot preset type. </param>
        /// <param name="positionPlane"> The position and orientation of the Robot in world coordinate space. </param>
        /// <param name="tool"> The Robot Tool. </param>
        /// <param name="externalAxes"> The external axes attached to the Robot. </param>
        /// <returns></returns>
        public static Robot GetRobotPreset(RobotPreset preset, Plane positionPlane, RobotTool tool, List <ExternalAxis> externalAxes = null)
        {
            // Check Robot Tool data
            if (tool == null)
            {
                tool = new RobotTool();
            }

            // Check External Axes
            if (externalAxes == null)
            {
                externalAxes = new List <ExternalAxis>()
                {
                };
            }

            else if (preset == RobotPreset.EMPTY)
            {
                return(new Robot());
            }
            if (preset == RobotPreset.IRB1100_4_0475)
            {
                return(IRB1100_4_0475.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1100_4_058)
            {
                return(IRB1100_4_058.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB120_3_058)
            {
                return(IRB120_3_058.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1200_5_090)
            {
                return(IRB1200_5_090.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1200_7_070)
            {
                return(IRB1200_7_070.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1300_10_115)
            {
                return(IRB1300_10_115.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1300_11_090)
            {
                return(IRB1300_11_090.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1300_7_140)
            {
                return(IRB1300_7_140.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB140_6_081)
            {
                return(IRB140_6_081.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1600_X_120)
            {
                return(IRB1600_X_120.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1600_X_145)
            {
                return(IRB1600_X_145.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB1660ID_X_155)
            {
                return(IRB1660ID_X_155.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB2600_12_185)
            {
                return(IRB2600_12_185.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB2600_X_165)
            {
                return(IRB2600_X_165.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB2600ID_15_185)
            {
                return(IRB2600ID_15_185.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB2600ID_8_200)
            {
                return(IRB2600ID_8_200.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB4600_20_250)
            {
                return(IRB4600_20_250.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB4600_40_255)
            {
                return(IRB4600_40_255.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB4600_X_205)
            {
                return(IRB4600_X_205.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6620_150_220)
            {
                return(IRB6620_150_220.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6640_235_255)
            {
                return(IRB6640_235_255.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6650_125_320)
            {
                return(IRB6650_125_320.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6650_200_275)
            {
                return(IRB6650_200_275.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6650S_125_350)
            {
                return(IRB6650S_125_350.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6650S_200_300)
            {
                return(IRB6650S_200_300.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6650S_90_390)
            {
                return(IRB6650S_90_390.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_150_320)
            {
                return(IRB6700_150_320.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_155_285)
            {
                return(IRB6700_155_285.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_175_305)
            {
                return(IRB6700_175_305.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_200_260)
            {
                return(IRB6700_200_260.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_205_280)
            {
                return(IRB6700_205_280.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_235_265)
            {
                return(IRB6700_235_265.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_245_300)
            {
                return(IRB6700_245_300.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6700_300_270)
            {
                return(IRB6700_300_270.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6790_205_280)
            {
                return(IRB6790_205_280.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB6790_235_265)
            {
                return(IRB6790_235_265.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB7600_150_350)
            {
                return(IRB7600_150_350.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB7600_325_310)
            {
                return(IRB7600_325_310.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB7600_340_280)
            {
                return(IRB7600_340_280.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB7600_400_255)
            {
                return(IRB7600_400_255.GetRobot(positionPlane, tool, externalAxes));
            }
            else if (preset == RobotPreset.IRB7600_500_255)
            {
                return(IRB7600_500_255.GetRobot(positionPlane, tool, externalAxes));
            }
            else
            {
                throw new Exception("Could not find the data of the defined Robot preset type.");
            }
        }