예제 #1
0
        /// <summary>
        /// Creates a new curve through the specified points
        /// </summary>
        internal PSCurve(PSAutomation powerSHAPE, CurveTypes curveType, Geometry.Point[] points) : base(powerSHAPE)
        {
            // Clear created list
            _powerSHAPE.ActiveModel.ClearCreatedItems();

            // Create the curve
            switch (curveType)
            {
            case CurveTypes.Bezier:
                _powerSHAPE.DoCommand("CREATE CURVE THROUGH");
                break;

            case CurveTypes.bSpline:
            case CurveTypes.g2:
                _powerSHAPE.DoCommand("CREATE CURVE " + curveType);
                break;
            }

            foreach (Geometry.Point point in points)
            {
                var _with1 = point;
                _powerSHAPE.DoCommand("ABS " + _with1.X.ToString() + " " + _with1.Y.ToString() + " " + _with1.Z.ToString());
            }
            _powerSHAPE.DoCommand("QUIT");

            // Get the id of the Curve
            PSCurve curve = (PSCurve)_powerSHAPE.ActiveModel.SelectedItems[0];

            _name = curve.Name;
            _id   = curve.Id;
        }
        /// <summary>
        /// Creates a new compcurve through the specified points
        /// </summary>
        /// <param name="curveType">CurveTypes enum value for curev type</param>
        /// <param name="points">Optional array of points or singular point for curve to go through</param>
        /// <returns>A curve created by the operation</returns>
        public PSCompCurve CreateCompCurveThroughPoints(CurveTypes curveType, Geometry.Point[] points)
        {
            PSCurve     curve     = _powerSHAPE.ActiveModel.Curves.CreateCurveThroughPoints(curveType, points);
            PSCompCurve compCurve = CreateCompCurveFromWireframe(new PSWireframe[] { curve });

            curve.Delete();
            return(compCurve);
        }
예제 #3
0
        /// <summary>
        /// Creates a new Curve from a CompCurve
        /// </summary>
        internal PSCurve(PSAutomation powerSHAPE, PSCompCurve compCurveToConvert) : base(powerSHAPE)
        {
            // Selects the CompCurve
            compCurveToConvert.AddToSelection(true);

            // Converts CompCurve into a curve
            _powerSHAPE.DoCommand("CONVERT WIREFRAME");
            compCurveToConvert.Delete();

            // Get the id of the Curve
            PSCurve curve = (PSCurve)_powerSHAPE.ActiveModel.UpdatedItems[0];

            _name = curve.Name;
            _id   = curve.Id;
        }
예제 #4
0
        /// <summary>
        /// Scales an arc within PowerSHAPE, returning a curve.  This deletes the current arc.
        /// </summary>
        /// <param name="offsetX">Scale value in X</param>
        /// <param name="offsetY">Scale value in Y</param>
        /// <param name="offsetZ">Scale value in Z</param>
        /// <param name="scaleOrigin">Scale origin, workplane origin if none specified</param>
        /// <returns>Created arc</returns>
        public PSCurve ScaleToCurve(double offsetX, double offsetY, double offsetZ, Point scaleOrigin = null)
        {
            // Open dialog
            _powerSHAPE.DoCommand("EDIT SCALE");
            _powerSHAPE.DoCommand("NOKEEP");

            // If a different scale origin has been defined, set it within PowerSHAPE
            if (scaleOrigin != null)
            {
                _powerSHAPE.DoCommand("SCALEORIGIN");
                _powerSHAPE.DoCommand(scaleOrigin.X.ToString() + " " + scaleOrigin.Y.ToString() + " " + scaleOrigin.Z.ToString());
            }

            // Set the scaling to be non-uniform, so allowing each component to be edited individually
            _powerSHAPE.DoCommand("NONUNIFORM");

            // Ensure arcs will not be removed from the selection
            _powerSHAPE.DoCommand("REMOVEARCS NO");

            // Unlock all axes
            _powerSHAPE.DoCommand("LOCK X OFF");
            _powerSHAPE.DoCommand("LOCK Y OFF");
            _powerSHAPE.DoCommand("LOCK Z OFF");

            // Enter scaling values
            _powerSHAPE.DoCommand("X " + offsetX);
            _powerSHAPE.DoCommand("Y " + offsetY);
            _powerSHAPE.DoCommand("Z " + offsetZ);

            if (_powerSHAPE.Version.Major > 11)
            {
                _powerSHAPE.DoCommand("APPLY");
                _powerSHAPE.DoCommand("DISMISS");
            }
            else
            {
                _powerSHAPE.DoCommand("ACCEPT");
                _powerSHAPE.DoCommand("CANCEL");
            }

            // Check that one curve is selected
            if (_powerSHAPE.Version >= new Version("13.2"))
            {
                if ((_powerSHAPE.ActiveModel.SelectedItems.Count == 0) | Exists)
                {
                    throw new ApplicationException("Scaling operation not completed correctly");
                }
            }
            else
            {
                if ((_powerSHAPE.ActiveModel.CreatedItems.Count == 0) | Exists)
                {
                    throw new ApplicationException("Scaling operation not completed correctly");
                }
            }

            // Delete the current arc
            Delete();

            // Add the created curve
            PSCurve createdCurve = null;

            if (_powerSHAPE.Version >= new Version("13.2"))
            {
                createdCurve = (PSCurve)_powerSHAPE.ActiveModel.SelectedItems[0];
            }
            else
            {
                createdCurve = (PSCurve)_powerSHAPE.ActiveModel.CreatedItems[0];
            }

            _powerSHAPE.ActiveModel.Curves.Add(createdCurve);

            // Return created curve
            return(createdCurve);
        }