Beispiel #1
0
        /*---------------------------------------------------------------------------------**//**
        * Create Grouped hole element.
        * @bsimethod                                                              Bentley Systems
        *  /*--------------+---------------+---------------+---------------+---------------+------*/
        public static Element CreateElement(DPoint3d start, DPoint3d opposite)
        {
            DgnModel model = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel();

            //Create Solid shape element from actual start and opposite points.
            ShapeElement solidShape = CreateShapeElement(model, start, opposite);

            //Get holes for grouped hole element.
            ElementAgenda holes;

            PopulateHolesAgenda(out holes, start, opposite, model);

            //Create actual grouped hole element with given solid and holes.
            GroupedHoleElement groupedHoleElement = new GroupedHoleElement(model, solidShape, holes);

            //Set line color.
            ElementPropertiesSetter pSetter = new ElementPropertiesSetter();

            pSetter.SetColor((uint)Bentley.MstnPlatformNET.Settings.GetActiveColor().Index);
            pSetter.Apply(groupedHoleElement);

            //Add fill color.
            if (PlaceGroupedHoleForm.GetAddFillColor())
            {
                groupedHoleElement.AddSolidFill((uint)Bentley.MstnPlatformNET.Settings.GetActiveFillColor().Index, false);
            }

            return(groupedHoleElement);
        }
        /*---------------------------------------------------------------------------------**//**
        * Actual modification on first data button if it lies on GroupedHole element.
        * @bsimethod                                                              Bentley Systems
        *  /*--------------+---------------+---------------+---------------+---------------+------*/
        protected override bool OnDataButton(Bentley.DgnPlatformNET.DgnButtonEvent ev)
        {
            //Locate an element.
            Bentley.DgnPlatformNET.HitPath hitPath = DoLocate(ev, true, 1);

            //If an element is located and the element is a grouped hole.
            //If element has a solid fill, remove it.
            //Else add a solid fill.
            if (null != hitPath)
            {
                int numHoles = PlaceGroupedHoleForm.GetNumberOfHoles();
                Bentley.DgnPlatformNET.Elements.Element element = hitPath.GetHeadElement();

                if (element is GroupedHoleElement)
                {
                    GroupedHoleElement groupedHoleElement = element as GroupedHoleElement;

                    uint fillColor;
                    bool alwaysFilled;
                    if (groupedHoleElement.GetSolidFill(out fillColor, out alwaysFilled))
                    {
                        groupedHoleElement.RemoveAreaFill();
                    }
                    else
                    {
                        groupedHoleElement.AddSolidFill((uint)Bentley.MstnPlatformNET.Settings.GetActiveFillColor().Index, false);
                    }

                    //Element must be replaced in model.
                    groupedHoleElement.ReplaceInModel(groupedHoleElement);
                }
            }

            return(true);
        }
Beispiel #3
0
 /*---------------------------------------------------------------------------------**//**
 * Exit tool.
 * @bsimethod                                                              Bentley Systems
 *  /*--------------+---------------+---------------+---------------+---------------+------*/
 protected override void ExitTool()
 {
     if (null != m_groupHoleForm)
     {
         m_groupHoleForm.Close();
         m_groupHoleForm = null;
     }
     base.ExitTool();
 }
Beispiel #4
0
        /*---------------------------------------------------------------------------------**//**
        * Calculates start and opposite points of holes and creates them.
        * @bsimethod                                                              Bentley Systems
        *  /*--------------+---------------+---------------+---------------+---------------+------*/
        private static void PopulateHolesAgenda(out ElementAgenda holes, DPoint3d start, DPoint3d opposite, DgnModel model)
        {
            holes = new ElementAgenda();

            //How many holes are required by the user. Possible options are only 1, 2 and 4.
            int numHoles = PlaceGroupedHoleForm.GetNumberOfHoles();

            System.Collections.Generic.List <DPoint3d> holeStarts = new List <DPoint3d>();
            System.Collections.Generic.List <DPoint3d> holeEnds   = new List <DPoint3d>();

            if (1 == numHoles)           //One hole in the middle of the shape.
            {
                double xFactor = (opposite.X - start.X) / 3;
                double yFactor = (start.Y - opposite.Y) / 3;

                holeStarts.Add(new DPoint3d(start.X + xFactor, start.Y - yFactor, start.Z));
                holeEnds.Add(new DPoint3d(opposite.X - xFactor, opposite.Y + yFactor, opposite.Z));
            }
            else if (2 == numHoles)      //Two holes.
            {
                double xFactor = (opposite.X - start.X) / 5;
                double yFactor = (start.Y - opposite.Y) / 5;

                holeStarts.Add(new DPoint3d(start.X + xFactor, start.Y - yFactor, start.Z));
                holeEnds.Add(new DPoint3d(start.X + (2 * xFactor), opposite.Y + yFactor, opposite.Z));

                holeStarts.Add(new DPoint3d(opposite.X - (2 * xFactor), start.Y - yFactor, start.Z));
                holeEnds.Add(new DPoint3d(opposite.X - xFactor, opposite.Y + yFactor, opposite.Z));
            }
            else //if(4 == numHoles)    Four holes.
            {
                double xFactor = (opposite.X - start.X) / 5;
                double yFactor = (start.Y - opposite.Y) / 5;

                holeStarts.Add(new DPoint3d(start.X + xFactor, start.Y - yFactor, start.Z));
                holeEnds.Add(new DPoint3d(start.X + (2 * xFactor), start.Y - (2 * yFactor), opposite.Z));

                holeStarts.Add(new DPoint3d(opposite.X - (2 * xFactor), start.Y - yFactor, start.Z));
                holeEnds.Add(new DPoint3d(opposite.X - xFactor, start.Y - (2 * yFactor), opposite.Z));

                holeStarts.Add(new DPoint3d(start.X + xFactor, opposite.Y + (2 * yFactor), start.Z));
                holeEnds.Add(new DPoint3d(start.X + (2 * xFactor), opposite.Y + yFactor, opposite.Z));

                holeStarts.Add(new DPoint3d(opposite.X - (2 * xFactor), opposite.Y + (2 * yFactor), start.Z));
                holeEnds.Add(new DPoint3d(opposite.X - xFactor, opposite.Y + yFactor, opposite.Z));
            }

            //Create hole elements and populate the agenda.
            for (int i = 0; i < numHoles; i++)
            {
                ShapeElement holeShape = CreateShapeElement(model, holeStarts[i], holeEnds[i]);
                holes.Insert(holeShape, true);
            }
        }
Beispiel #5
0
        /*---------------------------------------------------------------------------------**//**
        * Constructor.
        * @bsimethod                                                              Bentley Systems
        *  /*--------------+---------------+---------------+---------------+---------------+------*/
        public PlaceGroupedHoleTool(int toolId, int prompt) : base(toolId, prompt)
        {
            m_points = new List <DPoint3d>();

            //Load options form.
            if (null == m_groupHoleForm)
            {
                m_groupHoleForm = new PlaceGroupedHoleForm();
                m_groupHoleForm.Show();
            }
        }