Exemple #1
0
        /// <summary>
        /// This operation creates a new Workplane from a Geometry.Workplane and adds it to the collection.
        /// </summary>
        /// <param name="workplane">The workplane from which to create a workplane in PowerSHAPE.</param>
        /// <returns>The created Workplane in PowerSHAPE.</returns>
        public PSWorkplane CreateWorkplane(Geometry.Workplane workplane)
        {
            PSWorkplane newWorkplane = new PSWorkplane(_powerSHAPE, workplane);

            Add(newWorkplane);
            return(newWorkplane);
        }
Exemple #2
0
        /// <summary>
        /// Initialises the Workplane using the properties of a
        /// Autodesk.Geometry workplane
        /// </summary>
        internal PSWorkplane(PSAutomation powerSHAPE, Geometry.Workplane inputWorkplane) : base(powerSHAPE)
        {
            // If there is an active workplane then this will need to be active when the new workplanes
            // axes are being configured
            PSWorkplane previousWorkplane = _powerSHAPE.ActiveModel.ActiveWorkplane;

            _powerSHAPE.DoCommand("CREATE WORKPLANE SINGLE " + inputWorkplane.Origin);

            // Get the new workplane
            PSWorkplane newWorkplane = (PSWorkplane)_powerSHAPE.ActiveModel.CreatedItems[0];

            // Activate the previous workplane
            _powerSHAPE.ActiveModel.ActiveWorkplane = previousWorkplane;

            // Set the axes values
            newWorkplane.XAxis = inputWorkplane.XAxis;
            newWorkplane.YAxis = inputWorkplane.YAxis;
            newWorkplane.ZAxis = inputWorkplane.ZAxis;

            // Get the id of the new workplane
            _name = newWorkplane.Name;
            _id   = newWorkplane.Id;

            // Activate the new workplane
            _powerSHAPE.ActiveModel.ActiveWorkplane = newWorkplane;
        }
Exemple #3
0
        /// <summary>
        /// Creates a Workplane in PowerMILL based on the specified workplane.
        /// </summary>
        /// <param name="workplaneToCreate">The workplane to create in PowerMILL.</param>
        public PMWorkplane CreateWorkplane(Geometry.Workplane workplaneToCreate)
        {
            PMWorkplane newWorkplane = null;

            if (workplaneToCreate != null)
            {
                Geometry.Point xPoint = workplaneToCreate.Origin + workplaneToCreate.XAxis;
                Geometry.Point yPoint = workplaneToCreate.Origin + workplaneToCreate.YAxis;
                _powerMILL.DoCommand("MODE WORKPLANE_CREATE ; INTERACTIVE THREE_POINTS",
                                     "MODE WORKPLANE_CREATE THREE_POINTS DEFINE ORIGIN",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD X \"" + workplaneToCreate.Origin.X + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD Y \"" + workplaneToCreate.Origin.Y + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD Z \"" + workplaneToCreate.Origin.Z + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS DEFINE X_AXIS",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD X \"" + xPoint.X + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD Y \"" + xPoint.Y + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD Z \"" + xPoint.Z + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS DEFINE XY_PLANE",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD X \"" + yPoint.X + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD Y \"" + yPoint.Y + "\"",
                                     "MODE WORKPLANE_CREATE THREE_POINTS COORD Z \"" + yPoint.Z + "\"",
                                     "WPFROM3PTS ACCEPT");

                // Get the name PowerMILL gave to the last workplane
                //Initialise()
                Type            type   = typeof(PMWorkplane);
                List <PMEntity> wplist = _powerMILL.ActiveProject.CreatedItems(type);
                if (wplist == null || wplist.Count < 1)
                {
                    newWorkplane = null;
                }
                else
                {
                    foreach (PMWorkplane wp in wplist)
                    {
                        if (wp != null)
                        {
                            Add(wp);
                        }
                    }
                    newWorkplane = LastItem();
                }
            }
            return(newWorkplane);
        }