/// <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
            ExternalLinearAxis externalLinearAxis = null;

            // Catch the input data
            if (!DA.GetData(0, ref externalLinearAxis))
            {
                return;
            }

            // Check if the object is valid
            if (!externalLinearAxis.IsValid)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The External Linear Axis is not valid");
            }

            // Output
            DA.SetData(0, externalLinearAxis.Name);
            DA.SetData(1, externalLinearAxis.AttachmentPlane);
            DA.SetData(2, externalLinearAxis.AxisPlane.ZAxis);
            DA.SetData(3, externalLinearAxis.AxisLimits);
            DA.SetData(4, externalLinearAxis.BaseMesh);
            DA.SetData(5, externalLinearAxis.LinkMesh);
            DA.SetData(6, externalLinearAxis.AxisLogic);
            DA.SetData(7, externalLinearAxis.MovesRobot);
        }
        /// <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. Remove this component from your canvas and replace it by picking the new component " +
                              "from the ribbon.");

            // Input variables
            Plane       attachmentPlane = Plane.WorldXY;
            Vector3d    axis            = new Vector3d(0, 0, 0);
            Interval    limits          = new Interval(0, 0);
            List <Mesh> baseMeshes      = new List <Mesh>();
            List <Mesh> linkMeshes      = new List <Mesh>();

            // Catch the input data
            if (!DA.GetData(0, ref attachmentPlane))
            {
                return;
            }
            if (!DA.GetData(1, ref axis))
            {
                return;
            }
            if (!DA.GetData(2, ref limits))
            {
                return;
            }
            if (!DA.GetDataList(3, baseMeshes))
            {
            }
            if (!DA.GetDataList(4, linkMeshes))
            {
            }

            // Make variables needed to join the base and link to one mesh
            Mesh baseMesh = new Mesh();
            Mesh linkMesh = new Mesh();

            // Join the base meshes to one mesh
            for (int i = 0; i < baseMeshes.Count; i++)
            {
                baseMesh.Append(baseMeshes[i]);
            }

            // Join the link meshes to one mesh
            for (int i = 0; i < linkMeshes.Count; i++)
            {
                linkMesh.Append(linkMeshes[i]);
            }

            // Create the external linear axis
            ExternalLinearAxis externalLinearAxis = new ExternalLinearAxis(attachmentPlane, axis, limits, baseMesh, linkMesh);

            // Output
            DA.SetData(0, externalLinearAxis);
        }
Beispiel #3
0
        /// <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)
        {
            // Input variables
            string      name            = "";
            Plane       attachmentPlane = Plane.WorldXY;
            Vector3d    axis            = new Vector3d(0, 0, 0);
            Interval    limits          = new Interval(0, 0);
            List <Mesh> baseMeshes      = new List <Mesh>();
            List <Mesh> linkMeshes      = new List <Mesh>();
            string      axisLogic       = "-1";
            bool        movesRobot      = true;

            // Catch the input data
            if (!DA.GetData(0, ref name))
            {
                return;
            }
            if (!DA.GetData(1, ref attachmentPlane))
            {
                return;
            }
            if (!DA.GetData(2, ref axis))
            {
                return;
            }
            if (!DA.GetData(3, ref limits))
            {
                return;
            }
            if (!DA.GetDataList(4, baseMeshes))
            {
                baseMeshes = new List <Mesh>()
                {
                    new Mesh()
                };
            }
            if (!DA.GetDataList(5, linkMeshes))
            {
                linkMeshes = new List <Mesh>()
                {
                    new Mesh()
                };
            }

            // Catch the input data from the variable parameteres
            if (Params.Input.Any(x => x.Name == variableInputParameters[0].Name))
            {
                if (!DA.GetData(variableInputParameters[0].Name, ref axisLogic))
                {
                    axisLogic = "-1";
                }
            }
            if (Params.Input.Any(x => x.Name == variableInputParameters[1].Name))
            {
                if (!DA.GetData(variableInputParameters[1].Name, ref movesRobot))
                {
                    movesRobot = true;
                }
            }

            // Create the external linear axis
            _externalLinearAxis = new ExternalLinearAxis(name, attachmentPlane, axis, limits, baseMeshes, linkMeshes, axisLogic, movesRobot);

            // Output
            DA.SetData(0, _externalLinearAxis);

            #region Object manager
            // Gets ObjectManager of this document
            _objectManager = DocumentManager.GetDocumentObjectManager(this.OnPingDocument());

            // Clears ExternalAxisNames
            _objectManager.ExternalAxisNames.Remove(_axisName);
            _axisName = String.Empty;

            // Removes lastName from ExternalAxisNames List
            if (_objectManager.ExternalAxisNames.Contains(_lastName))
            {
                _objectManager.ExternalAxisNames.Remove(_lastName);
            }

            // Adds Component to ExternalLinarAxesByGuid Dictionary
            if (!_objectManager.ExternalLinearAxesByGuid.ContainsKey(this.InstanceGuid))
            {
                _objectManager.ExternalLinearAxesByGuid.Add(this.InstanceGuid, this);
            }

            // Checks if axis name is already in use and counts duplicates
            #region Check name in object manager
            if (_objectManager.ExternalAxisNames.Contains(_externalLinearAxis.Name))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "External Axis Name already in use.");
                _nameUnique = false;
                _lastName   = "";
            }
            else
            {
                // Adds Robot Axis Name to list
                _axisName = _externalLinearAxis.Name;
                _objectManager.ExternalAxisNames.Add(_externalLinearAxis.Name);

                // Run SolveInstance on other External Axes with no unique Name to check if their name is now available
                _objectManager.UpdateExternalAxis();

                _lastName   = _externalLinearAxis.Name;
                _nameUnique = true;
            }
            #endregion

            // Recognizes if Component is Deleted and removes it from Object Managers axis and name list
            GH_Document doc = this.OnPingDocument();
            if (doc != null)
            {
                doc.ObjectsDeleted += DocumentObjectsDeleted;
            }
            #endregion
        }