/*---------------------------------------------------------------------------------**//** * 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); }