In Revit C#, crop region visibility

29 Views Asked by At

In Revit C#, I've looped through the view elements and grabbed the parameter VIEWER_CROP_REGION_VISIBLE, I want to turn the bool visibly on or off. I should be able to "Get", then "Set"

I've tried AsValueString, Yes, No, it didn't change the visibility

how do you turn the visibility on/off

1

There are 1 best solutions below

0
egeer On

This might be an easier way to tackle the issue, since CropBoxVisible is a setable property of the View class.

    [Transaction(TransactionMode.Manual)]
    internal class ToggleCropRegion : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            using (var t = new Transaction(commandData.Application.ActiveUIDocument.Document, "ToggleCropBox"))
            {
                t.Start();
                var currentView = commandData.View;
                currentView.CropBoxVisible = !currentView.CropBoxVisible;
                t.Commit();
            }


            return Result.Succeeded;
        }
    }