Example #1
0
        public RevitDB.OverrideGraphicSettings ToOverrideGraphicSettings()
        {
            RevitDB.OverrideGraphicSettings ogs = new RevitDB.OverrideGraphicSettings();

            ogs.SetProjectionFillPatternVisible(this.IsProjectionFillPaternVisible);
            ogs.SetProjectionFillColor(this.ProjectionFillColor.ToColor());
            ogs.SetProjectionFillPatternId(this.ProjectionFillPatternId.ToElementId());
            ogs.SetProjectionLineColor(this.ProjectionLineColor.ToColor());
            ogs.SetProjectionLinePatternId(this.ProjectionFillPatternId.ToElementId());
            ogs.SetProjectionLineWeight(this.ProjectionLineWeight);

            ogs.SetCutFillPatternVisible(this.IsCutFillPaternVisible);
            ogs.SetCutFillColor(this.CutFillColor.ToColor());
            ogs.SetCutFillPatternId(this.CutFillPatternId.ToElementId());
            ogs.SetCutLineColor(this.CutLineColor.ToColor());
            ogs.SetCutLinePatternId(this.CutLinePatternId.ToElementId());
            ogs.SetCutLineWeight(this.CutLineWeight);

            ogs.SetSurfaceTransparency(this.Transparency);
            ogs.SetHalftone(this.Halftone);
            ogs.SetDetailLevel((RevitDB.ViewDetailLevel) this.DetailLevel.ToEnum());

            return(ogs);
        }
Example #2
0
        /// <summary>
        /// Create a OverrideGraphicSettings Element.
        /// </summary>
        /// <param name="cutFillColor">Fill color</param>
        /// <param name="projectionFillColor">Projection color</param>
        /// <param name="cutLineColor">Cut line color</param>
        /// <param name="projectionLineColor">Projection line color</param>
        /// <param name="cutLineWeight">Cut line weight</param>
        /// <param name="projectionLineWeight">Projection line weight</param>
        /// <param name="cutFillPattern">Cut fill pattern</param>
        /// <param name="projectionFillPattern">Projection fill pattern</param>
        /// <param name="cutLinePattern">Cut line pattern</param>
        /// <param name="projectionLinePattern">Projection line pattern</param>
        /// <param name="transparency">Transparency as integer between 1-100.</param>
        /// <param name="detailLevel">Detail Level setting, ex: Coarse, Fine etc.</param>
        /// <param name="halftone">Halftone. True = halftone.</param>
        /// <returns name="overrides">Override Graphic Settings</returns>
        public static OverrideGraphicSettings ByProperties(
            [DefaultArgumentAttribute("null")] DSCore.Color cutFillColor,
            [DefaultArgumentAttribute("null")] DSCore.Color projectionFillColor,
            [DefaultArgumentAttribute("null")] DSCore.Color cutLineColor,
            [DefaultArgumentAttribute("null")] DSCore.Color projectionLineColor,
            [DefaultArgumentAttribute("null")] Revit.Elements.FillPatternElement cutFillPattern,
            [DefaultArgumentAttribute("null")] Revit.Elements.FillPatternElement projectionFillPattern,
            [DefaultArgumentAttribute("null")] Revit.Elements.LinePatternElement cutLinePattern,
            [DefaultArgumentAttribute("null")] Revit.Elements.LinePatternElement projectionLinePattern,
            int cutLineWeight        = -1,
            int projectionLineWeight = -1,
            int transparency         = -1,
            string detailLevel       = "Undefined",
            bool halftone            = false
            )
        {
            Autodesk.Revit.DB.OverrideGraphicSettings filterSettings = new Autodesk.Revit.DB.OverrideGraphicSettings();

            // the old functions SetCutFillColor, SetCutFillPatternId,
            // SetProjectionFillColor and SetProjectionFillPatternId,
            // are obsoleted and suggested by the documentation that will be removed and
            // replaced by SetCutForegroundPatternColor, SetCutForegroundPatternId,
            // SetSurfaceForegroundPatternColor, SetSurfaceForegroundPatternId.

            // Apply Colors
            if (cutFillColor != null)
            {
                filterSettings.SetCutForegroundPatternColor(ToRevitColor(cutFillColor));
            }
            if (projectionFillColor != null)
            {
                filterSettings.SetSurfaceForegroundPatternColor(ToRevitColor(projectionFillColor));
            }
            if (cutLineColor != null)
            {
                filterSettings.SetCutLineColor(ToRevitColor(cutLineColor));
            }
            if (projectionLineColor != null)
            {
                filterSettings.SetProjectionLineColor(ToRevitColor(projectionLineColor));
            }

            // Apply Lineweight
            if (cutLineWeight != -1)
            {
                filterSettings.SetCutLineWeight(cutLineWeight);
            }
            if (projectionLineWeight != -1)
            {
                filterSettings.SetProjectionLineWeight(projectionLineWeight);
            }

            // Apply Patterns
            if (cutFillPattern != null)
            {
                filterSettings.SetCutForegroundPatternId(cutFillPattern.InternalElement.Id);
            }
            if (projectionFillPattern != null)
            {
                filterSettings.SetSurfaceForegroundPatternId(projectionFillPattern.InternalElement.Id);
            }
            if (cutLinePattern != null)
            {
                filterSettings.SetCutLinePatternId(cutLinePattern.InternalElement.Id);
            }
            if (projectionLinePattern != null)
            {
                filterSettings.SetProjectionLinePatternId(projectionLinePattern.InternalElement.Id);
            }

            // Apply transparency, detail level and halftone
            if (transparency != -1)
            {
                filterSettings.SetSurfaceTransparency(transparency);
            }
            if (halftone)
            {
                filterSettings.SetHalftone(halftone);
            }
            filterSettings.SetDetailLevel((Autodesk.Revit.DB.ViewDetailLevel)System.Enum.Parse(typeof(Autodesk.Revit.DB.ViewDetailLevel), detailLevel));

            return(new OverrideGraphicSettings(filterSettings));
        }
Example #3
0
        /// <summary>
        /// Create a OverrideGraphicSettings element
        /// </summary>
        /// <param name="cutFillColor">Fill color</param>
        /// <param name="projectionFillColor">Projection color</param>
        /// <param name="cutLineColor">Cut line color</param>
        /// <param name="projectionLineColor">Projection line color</param>
        /// <param name="cutLineWeight">Cut line weight</param>
        /// <param name="projectionLineWeight">Projection line weight</param>
        /// <param name="cutFillPattern">Cut fill pattern</param>
        /// <param name="projectionFillPattern">Projection fill pattern</param>
        /// <param name="cutLinePattern">Cut line pattern</param>
        /// <param name="projectionLinePattern">Projection line pattern</param>
        /// <returns>OverrideGraphicSettings</returns>
        public static OverrideGraphicSettings ByProperties(
            [DefaultArgumentAttribute("null")] DSCore.Color cutFillColor,
            [DefaultArgumentAttribute("null")] DSCore.Color projectionFillColor,
            [DefaultArgumentAttribute("null")] DSCore.Color cutLineColor,
            [DefaultArgumentAttribute("null")] DSCore.Color projectionLineColor,
            [DefaultArgumentAttribute("null")] FillPatternElement cutFillPattern,
            [DefaultArgumentAttribute("null")] FillPatternElement projectionFillPattern,
            [DefaultArgumentAttribute("null")] LinePatternElement cutLinePattern,
            [DefaultArgumentAttribute("null")] LinePatternElement projectionLinePattern,
            int cutLineWeight        = -1,
            int projectionLineWeight = -1
            )
        {
            Autodesk.Revit.DB.OverrideGraphicSettings filterSettings = new Autodesk.Revit.DB.OverrideGraphicSettings();

            // Apply Colors
            if (cutFillColor != null)
            {
                filterSettings.SetCutFillColor(ToRevitColor(cutFillColor));
            }
            if (projectionFillColor != null)
            {
                filterSettings.SetProjectionFillColor(ToRevitColor(projectionFillColor));
            }
            if (cutLineColor != null)
            {
                filterSettings.SetCutLineColor(ToRevitColor(cutLineColor));
            }
            if (projectionLineColor != null)
            {
                filterSettings.SetProjectionLineColor(ToRevitColor(projectionLineColor));
            }

            // Apply Lineweight
            if (cutLineWeight != -1)
            {
                filterSettings.SetCutLineWeight(cutLineWeight);
            }
            if (projectionLineWeight != -1)
            {
                filterSettings.SetProjectionLineWeight(projectionLineWeight);
            }

            // Apply Patterns
            if (cutFillPattern != null)
            {
                filterSettings.SetCutFillPatternId(cutFillPattern.Id);
            }
            if (projectionFillPattern != null)
            {
                filterSettings.SetProjectionFillPatternId(projectionFillPattern.Id);
            }
            if (cutLinePattern != null)
            {
                filterSettings.SetCutLinePatternId(cutLinePattern.Id);
            }
            if (projectionLinePattern != null)
            {
                filterSettings.SetProjectionLinePatternId(projectionLinePattern.Id);
            }

            return(new OverrideGraphicSettings(filterSettings));
        }