Crop Region Size Parameter Edit by view

i`m trying to edit the parameters so as to make all the views with 3 mm annotation crop for example !!
is there any way ?

1 Like

Hi @Ahmed_Salah1

There is a node from @T_Pover MepOver package called View.SetCropBoxCurves you could use that to set.

1 Like

@Kulkul the crop region i dont want to change im controlling it through scope box i want to change all the annotation crop offset only to be for example 3 mm !

@Ahmed_Salah1 Sorry i thought your looking to set view crop boundary. You need to access revit api
http://www.revitapidocs.com/2017/d815093f-0331-76c9-7607-67e62f9f2c9b.htm


@Kulkul Thanks but i dont think i can write a code yet im still learning , so i will wait someone to help me but Thank you to provide half of the solution .

Hi Ahmed,

You can use this code to set the annotation crop size:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import clr
clr.AddReference('RevitAPI')
import Autodesk.Revit.DB

import clr
clr.AddReference("RevitNodes")
import Revit

clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

#The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[0], list):
	views = UnwrapElement(IN[0])
else:
	views = [UnwrapElement(IN[0])]
size = IN[1]
	
listout = []
for view in views:
	regionMan = view.GetCropRegionShapeManager()
	TransactionManager.Instance.EnsureInTransaction(doc)
	try:
		regionMan.BottomAnnotationCropOffset = size
		regionMan.LeftAnnotationCropOffset = size
		regionMan.RightAnnotationCropOffset = size
		regionMan.TopAnnotationCropOffset = size
		listout.append(view)
	except:
		listout.append("failed")
	
	TransactionManager.Instance.TransactionTaskDone()


#Assign your output to the OUT variable.
OUT = listout

The size must be supplied in feet, so if you’re a metric guy (like me) then divide by 304.8 like in this example:

13 Likes

@T_Pover you helped me twice this morning , Thanks

1 Like

Thank you T_Pover, for this piece of code

1 Like

This just saved me several hours worth of work. Thank you!

Hi, I’m new to writing code, what language should I use? C#, Python? Should I copy and paste this? :frowning:

I’m not sure where else to post this but it is related to the annotation crop so I will ask you here since you seem to have figured some of this stuff out (and also developed the View.GetCropBoxCurves node for your MEPover package). Would you know how to extract the curves for the annotation crop shape via python? It is available via the api per https://www.revitapidocs.com/2019/4e698377-7527-c562-21bc-379c68efda5d.htm but I have 0 understanding of python and how to do it. I mention the View.GetCropBoxCurves node because it seems similar approach could be taken but I may be wrong since my understanding of python is not great.

1 Like

Thank you!

Sure, here is a slightly modified version of the node GetCropboxCurves to get the annotation crop:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import clr

clr.AddReference("RevitNodes")
import Revit

# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

#The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[0], list):
	view = UnwrapElement(IN[0])
	toggle = 0
else:
	view = [UnwrapElement(IN[0])]
	toggle = 1
	
listout = []
for x in view:
	region = x.GetCropRegionShapeManager().GetAnnotationCropShape()
	if region != None:
		lines = [y.ToProtoType() for y in region]
		listout.append(lines)
	else:
		listout.append([])



#Assign your output to the OUT variable.
if toggle == 0:
	OUT = listout
else:
	OUT = lines
2 Likes

Thanks. I tried to do it myself and totally broke it. I got lost at the if and else statements for region.

Dude! God Bless Your Soul!

w Love
UNITY

1 Like

*Hi, am struggling to add the size In(1) can somebody give me examples for the sizes related?

Thank you very much for your question and your help.

Hi,

I have a question:
Is it possible to set the annotion crop by buildings like this:

I have edited the crop view but the annotion is still the same as the viewport

Nope!

If it can’t be done manually then not possible via API.

1 Like