Esempio n. 1
0
        /// <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)
        {
            // Get names
            var names = new List <string>();

            if (!DA.GetDataList(0, names))
            {
                return;
            }

            // Get normals
            var vectors = new List <Vector3d>();

            if (!DA.GetDataList(1, vectors))
            {
                return;
            }

            // There should be the same number of names and normals
            if (names.Count != vectors.Count)
            {
                return;
            }

            // Create dictionary
            var dictionary = new Dictionary <string, HM.Triple>();

            for (int i = 0; i < names.Count; i++)
            {
                dictionary[names[i]] = HMGHUtil.VectorToTriple(vectors[i]);
            }
            DA.SetData(0, dictionary);
        }
        /// <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)
        {
            // 1. Declare placeholder variables and assign initial invalid data.
            //    This way, if the input parameters fail to supply valid data, we know when to abort.
            Line     line   = Line.Unset;
            Vector3d vector = Vector3d.Unset;
            string   name   = string.Empty;

            // 2. Retrieve input data.
            if (!DA.GetData(0, ref line))
            {
                return;
            }
            if (!DA.GetData(1, ref vector))
            {
                return;
            }
            if (!DA.GetData(2, ref name))
            {
                name = "<name>";
            }

            // 3. Abort on invalid inputs.
            if (!line.IsValid)
            {
                return;
            }
            if (!vector.IsValid)
            {
                return;
            }

            // 4. Build hMember.
            var mem = new HM.hMember(HMGHUtil.GHLineToHMLine(line), HMGHUtil.VectorToTriple(vector));

            mem.Name = name;

            // 9. Assign output.
            DA.SetData(0, mem);
        }