示例#1
0
        /// <summary>
        /// Creates a new Workplane relative to an entity and adds it to the collection.
        /// </summary>
        /// <param name="entity">The entity on which to create the new Workplane.</param>
        /// <param name="positionAtEntity">The position on the entity at which to create the workplane: Centre, Top, Bottom.</param>
        /// <returns>The created workplane.</returns>
        public PSWorkplane CreateWorkplaneAtEntity(PSEntity entity, NewWorkplaneInEntityPositions positionAtEntity)
        {
            PSWorkplane newWorkplane = new PSWorkplane(_powerSHAPE, entity, positionAtEntity);

            Add(newWorkplane);
            return(newWorkplane);
        }
示例#2
0
        /// <summary>
        /// Creates a workplane that doesn't need an origin
        /// </summary>
        internal PSWorkplane(
            PSAutomation powerSHAPE,
            PSEntity entity,
            NewWorkplaneInEntityPositions workplanePosition) : base(powerSHAPE)
        {
            // Select the entity
            entity.AddToSelection(true);

            // Create the workplane
            string position = "";

            switch (workplanePosition)
            {
            case NewWorkplaneInEntityPositions.Centre:
                position = "SELECTIONCENTRE";
                break;

            case NewWorkplaneInEntityPositions.Bottom:
                position = "SELECTIONBOTTOM";
                break;

            case NewWorkplaneInEntityPositions.Top:
                position = "SELECTIONTOP";
                break;
            }
            _powerSHAPE.DoCommand("CREATE WORKPLANE " + position);

            // Try to get workplane details
            try
            {
                PSWorkplane newWorkplane = (PSWorkplane)_powerSHAPE.ActiveModel.CreatedItems[0];
                _name = newWorkplane.Name;
                _id   = newWorkplane.Id;
            }
            catch
            {
                throw new ApplicationException("Failed to create Workplane");
            }
        }