/// <summary>
        /// Creates CompCurves from an intersection between two solids
        /// </summary>
        /// <param name="firstSolid">The first solid to intersect</param>
        /// <param name="secondSolid">The second solid to intersect</param>
        /// <returns>A list of the created CompCurves</returns>
        public List <PSCompCurve> CreateCompCurvesFromIntersectionOfTwoSolids(PSSolid firstSolid, PSSolid secondSolid)
        {
            // Create lists from individual surfaces
            List <PSEntity> firstSolidList  = new List <PSEntity>();
            List <PSEntity> secondSolidList = new List <PSEntity>();

            firstSolidList.Add(firstSolid);
            secondSolidList.Add(secondSolid);

            // Carry out operation
            return(CreateCompCurvesFromIntersectionOfTwoSetsOfEntities(firstSolidList, secondSolidList));
        }
        /// <summary>
        /// Converts a solid into surfaces.
        /// </summary>
        /// <param name="solidToConvert">The solid to be converted into surfaces.</param>
        /// <returns>The list of the surfaces created from the solid.</returns>
        public List <PSSurface> CreateSurfacesFromSolid(PSSolid solidToConvert)
        {
            _powerSHAPE.ActiveModel.ClearCreatedItems();

            // Add the surface to the selection
            solidToConvert.AddToSelection(true);

            // Convert to surfaces
            _powerSHAPE.DoCommand("CONVERT SOLID");

            // Get new surfaces
            List <PSSurface> newSurfaces = new List <PSSurface>();

            //_powerSHAPE.ActiveModel.SelectedItems.ForEach(Sub(x) If (x.GetType() Is GetType(PSSurface)) Then newSurfaces.Add(x))
            //_powerSHAPE.ActiveModel.CreatedItems.ForEach(Sub(x) If (x.GetType() Is GetType(PSSurface)) Then newSurfaces.Add(x))

            newSurfaces.AddRange(_powerSHAPE.ActiveModel
                                 .SelectedItems
                                 .Where(i => i.GetType() == typeof(PSSurface))
                                 .Cast <PSSurface>());

            newSurfaces.AddRange(_powerSHAPE.ActiveModel
                                 .CreatedItems.Where(x => x.GetType() == typeof(PSSurface))
                                 .Cast <PSSurface>());

            // Check that surfaces have been created
            if (newSurfaces.Count == 0)
            {
                throw new ApplicationException("Solid not converted to surfaces correctly");
            }

            foreach (PSSurface newSurface in newSurfaces)
            {
                Add(newSurface);
            }

            // Remove now converted solid from PowerSHAPE collection
            _powerSHAPE.ActiveModel.Solids.Remove(solidToConvert);

            // Return new surfaces
            return(newSurfaces);
        }
        /// <summary>
        /// Creates a new Mesh from a Solid
        /// </summary>
        /// <param name="solid">The Solid from which to create the mesh</param>
        /// <returns>Mesh created by operation</returns>
        public PSMesh CreateMeshFromSolid(PSSolid solid)
        {
            PSSolid newSolid = (PSSolid)solid.Duplicate();

            newSolid.AddToSelection(true);

            // Carry out operation
            _powerSHAPE.ActiveModel.ClearCreatedItems();
            _powerSHAPE.DoCommand("CONVERT MESH");

            // Add new Mesh to collection of Meshes
            PSMesh newMesh = (PSMesh)_powerSHAPE.ActiveModel.CreatedItems[0];

            _powerSHAPE.ActiveModel.Meshes.Add(newMesh);

            // Remove this Surface from the collection of surfaces
            newSolid.Delete();

            return(newMesh);
        }
        /// <summary>
        /// Creates instance solids based on a string identifying a solid's type in PowerSHAPE
        /// </summary>
        /// <param name="powerSHAPE">PowerSHAPE instance</param>
        /// <param name="id">ID of the new solid</param>
        /// <param name="name">Name of the new solid</param>
        /// <returns>Solid with type requested</returns>
        /// <remarks></remarks>
        public static object CreateSolid(PSAutomation powerSHAPE, int id, string name)
        {
            // Get solid attributes
            //Dim id As String = baseSolid.Id
            //Dim name As String = baseSolid.Name

            switch (PSSolid.GetSolidType(powerSHAPE, id))
            {
            case SolidTypes.Block:
                return(new PSSolidBlock(powerSHAPE, id, name));

            case SolidTypes.Cone:
                return(new PSSolidCone(powerSHAPE, id, name));

            case SolidTypes.Cylinder:
                return(new PSSolidCylinder(powerSHAPE, id, name));

            case SolidTypes.Extrusion:
                return(new PSSolidExtrusion(powerSHAPE, id, name));

            case SolidTypes.Plane:
                return(new PSSolidPlane(powerSHAPE, id, name));

            case SolidTypes.Revolution:
                return(new PSSolidRevolution(powerSHAPE, id, name));

            case SolidTypes.Sphere:
                return(new PSSolidSphere(powerSHAPE, id, name));

            case SolidTypes.Spring:
                return(new PSSolidSpring(powerSHAPE, id, name));

            case SolidTypes.Torus:
                return(new PSSolidTorus(powerSHAPE, id, name));
            }

            // Solid type is not known, so return solid that was passed in
            return(new PSSolid(powerSHAPE, id, name));
        }