Change a view’s “Annotation Crop” parameter value

Joe Ye

Question:Is a view’s ‘annotation crop" exposed via the API? I see the properties cropBox, cropBoxActive, and cropBoxVisible — but not similar properties for the annotation crop.

Solution

For easily access the view’s parameter value, Revit API exposes some properties for View class to get and set the parameter value. So developers can read and write parameters’ value in one line. However, not all the view’s parameters have a corresponding property under View class. In this situation, we can access directly access the target parameter, and change its value in the way of changing parameter value.

Here is the code fragment to change the Annotation Crop parameter value. it changes the current view’s Annotation Crop value.

    Parameter param = doc.ActiveView.get_Parameter(BuiltInParameter.VIEWER_ANNOTATION_CROP_ACTIVE);
            Transaction trans = new Transaction(doc);
            trans.Start("ChangeAnnotationCrop");
            param.Set(1);
            trans.Commit();

 

For other kind of element, developer can use the same way to change a parameter value if the representing class doesn’t provide the corresponding property.


Comments

2 responses to “Change a view’s “Annotation Crop” parameter value”

  1. Joe,
    I presume there’s no way to control the size of the annotation crop box?

  2. Great to learn about changing the crop annotation value, nyc article

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading