コード例 #1
0
        /// <summary>
        /// Creates an extruded solid from wireframe.
        /// </summary>
        /// <param name="wireframe">The wireframe from which an extruded solid will be created.</param>
        /// <param name="length">The length of the extruded solid.</param>
        /// <param name="negLength">The negative length of the extruded solid.</param>
        /// <returns>The created solid.</returns>
        public PSSolidExtrusion CreateSolidExtrusionFromWireframe(PSWireframe wireframe, MM length, MM negLength)
        {
            // Add wireframe to selection
            _powerSHAPE.ActiveModel.ClearCreatedItems();
            wireframe.AddToSelection(true);

            // Extrude to make solid
            _powerSHAPE.DoCommand("CREATE SOLID EXTRUSION");

            // Get created solid
            PSSolidExtrusion createdSolid = null;

            try
            {
                createdSolid = (PSSolidExtrusion)_powerSHAPE.ActiveModel.CreatedItems[0];
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to create solid extrusion");
            }

            // Edit length/negative length to be as required
            createdSolid.NegativeLength = negLength;
            createdSolid.Length         = length;

            // Return created solid
            Add(createdSolid);
            return(createdSolid);
        }
コード例 #2
0
        internal PSSolidExtrusion(
            PSAutomation powershape,
            Planes principalPlane,
            PSWireframe[] wireframeToExtrude) : base(powershape)
        {
            // Clear CreatedItems
            _powerSHAPE.ActiveModel.ClearCreatedItems();

            // Add the wireframe to the selection
            _powerSHAPE.ActiveModel.ClearSelectedItems();
            foreach (PSWireframe wireframe in wireframeToExtrude)
            {
                wireframe.AddToSelection(false);
            }

            // Create an extrusion using the principal plane and wireframe specified
            _powerSHAPE.SetActivePlane(principalPlane);
            _powerSHAPE.DoCommand("CREATE SOLID EXTRUSION", "ACCEPT");

            // Get created plane id
            PSSolidExtrusion newExtrusion = (PSSolidExtrusion)_powerSHAPE.ActiveModel.CreatedItems[0];

            _id = newExtrusion.Id;
        }