Corner points rotated scope box

Dear Specialists,

I have an rotated scope box, see picture below.
image

I would like to receive the corner points of the scope box.
But the transform failed in my script. Could anyone help me?
My knowledge about the RevitAPI methodes/attributes in scope boxes/boundingboxes/transform is low. So extra explanation is helpfull!

Thanks in advance!!

import clr
# Add references to the Revit, Revit Services and TransactionManager
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

from datetime import datetime

#receive Revit Document
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

#get 
scope_box = UnwrapElement([IN[0]])
elem_ref = UnwrapElement([IN[1]])

#receive orientation object
elem_loc = [a.Location.Curve for a in elem_ref]
begin = [a.GetEndPoint(0) for a in elem_loc]
end = [a.GetEndPoint(1) for a in elem_loc]

points = []
for a in range(len(scope_box)):
    bbox = scope_box[a].get_BoundingBox(None)
    transform = bbox.get_Transform()
    
    min_pt = bbox.Min
    max_pt = bbox.Max
    
    corner1 = XYZ(min_pt.X, min_pt.Y, min_pt.Z)
    corner2 = XYZ(max_pt.X, min_pt.Y, min_pt.Z)
    corner3 = XYZ(max_pt.X, max_pt.Y, min_pt.Z)
    corner4 = XYZ(min_pt.X, max_pt.Y, min_pt.Z)
    
    corner1_transformed = transform.OfPoint(corner1).ToPoint()
    corner2_transformed = transform.OfPoint(corner2).ToPoint()
    corner3_transformed = transform.OfPoint(corner3).ToPoint()
    corner4_transformed = transform.OfPoint(corner4).ToPoint()
    
    points.append([corner1_transformed, corner2_transformed, corner3_transformed, corner4_transformed])

TransactionManager.Instance.TransactionTaskDone()

OUT = points

Hi @rlandkroon not sure is it something here ?

Tnx! I am working with Python. I would like to not use packages.
Do you have ideas in Python? I can also look in the node you sent!

that node is from spring and made in design script :wink:

Yes, but I would like to receive it pure Revit API

What have you tried so far?

I have a copple of questions:

  • I am working with get_Geometry, but this is old API of Revit. Is this a problem?
  • Is there a newer way to receive Geometry information?
  • Does this methode work for every geometry element in Revit?
points = []
for a in range(len(scope_box)):
    geometry = scope_box[a].get_Geometry(Options())
    #points.append(geometry)
    for geom in geometry:
        if isinstance(geom, Line):
            begin = geom.GetEndPoint(0)
            end = geom.GetEndPoint(1)
            points.append(begin)

Arhhh OK you can try as here in 24…but guess it will work in older as well

forum Home.dyn (4.3 KB)

1 Like