BoundingBox.ByElements Clockwork

I am trying to get a version of BoundingBox.ByElements for dynamo 2.0. I found one for clockwork for an older version but not having any luck getting it to 2.0.

Any ideas?

I have no idea how to create nodes or anything so be kind hahaha

Do it by your own:

import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

elements = UnwrapElement(IN[0])
points =[]

for e in elements:
bb = e.get_BoundingBox(None)
if not bb is None:
    centre = bb.Min+(bb.Max-bb.Min)/2
    points.append(centre.ToPoint())

OUT = points

#Points
#BoundingBox
import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

   elements = UnwrapElement(IN[0])
   boxes =[]

for e in elements:
    bb = e.get_BoundingBox(None)
    boxes.append(bb.ToProtoType())

OUT = boxes

Thanks a bunch. Is there somewhere that would guide me through your code? Mostly a copy paste ninja but starting to slowly pick up the code.

1 Like

its Python , you should be able to place a python node and paste his code into it (2 codes shown so two nodes)(Split at #Points) both will have one input and output options. Code one takes a list of elements input and outputs a list of the bounding box center points. The other takes a list of Elements and outputs a list of the bounding boxes. (from my quick skim read of it)

Yeah I am copy paste ninja so I know how to get it into the python script node but still threw an error so I worked around again to create the bounding box using dynamo similar to the code. So i got dynamo “seeing” the bounding box of annotations and drawing them for graphic representation. Now to figure out how to move them around so that they don’t overlap.
MoveGenericAnnoInCurrentView.dyn (63.0 KB)

I was more asking about a guide to read the code in english type of thing

Ah okay, i miss understood your post

1 Like

No problem. Appreciate the reply any help is good help :slight_smile:

The easiest way to get this level of knowledge is to start at line 1 and append a comment on the end of the code yoruself (append a # and then type out what the code does). When you get lost as you go you can check the Revit API docs site for Revit specific stuff, the Dynamo forum for similar lines of code, and Python documentation for Python bits. Googling can also help quite a bit.

The Dynamo Python Primer can also help - specifically with some of the things around imports and the like. Take Dynamo Further 🚀 - Dynamo Python Primer

2 Likes

Thanks Jacob. Appreciate the response on twitter! I am filling in this other thread about my adventures, thought I might get away from using refinery but just realized I probably still will haha.

Take a look if you like