def boundingboxLine(elem): # Location Line of Wall line = elem.Location.Curve # Everything is a Curve, in Revit p1 = line.GetEndPoint(0) p2 = line.GetEndPoint(1) v = p2 - p1 # vector width = v.GetLength() # sqrt(x*x + y*y + z*s) height = 4 / 0.3048 # 4m height calculation 1 ft = 0.3048 m ; 1m = 1/0.3048 ft ≈ 3.28.. offset = 0.5 / 0.3048 # #Set 2pt Min & Max to define BoundaryBox of Section minpt = XYZ( -width/2.0, -offset , 0) #from midpoint of wall. X = wall-length /2 maxpt = XYZ( width/2.0, height + offset , offset) midpoint = p1 + 0.5 * v # midpoint of whole wall startpt.X + 0.5 * v.X walldir = v.Normalize() # X/ Length, Y/ Length , Z/ Length updir = XYZ.BasisZ # Basisvektor in Z Richtung (0,0,1) viewdir = walldir.CrossProduct( updir ) # #set transform of SectionBox trans = DB.Transform.Identity # .Identity has to be called to trans.Origin = midpoint trans.BasisX = walldir trans.BasisY = updir trans.BasisZ = viewdir # create SectionBox sectionBox = DB.BoundingBoxXYZ() # instantiate sectionBox.Transform = trans sectionBox.Min = minpt sectionBox.Max = maxpt return sectionBox
def boundingboxWall(elem): # Location Line of Wall line = elem.Location.Curve # Everything is a Curve, in Revit p1 = line.GetEndPoint(0) p2 = line.GetEndPoint(1) v = p2 - p1 # vector # BoundingBox Wall bbwall = elem.get_BoundingBox(None) minZ = bbwall.Min.Z maxZ = bbwall.Max.Z # print "MIN= ", bbwall.Min # print "MAX= ", bbwall.Max # print p1 # print p2 width = v.GetLength() # sqrt(x*x + y*y + z*s) height = maxZ - minZ # height calculation depth = elem.Width offset = 0.2 / 0.3048 # # Set 2pt Min & Max to define BoundaryBox of Section minpt = XYZ(-width / 2.0, minZ - offset, -depth / 2.0) #from midpoint of wall. X = wall-length /2 maxpt = XYZ(width / 2.0, maxZ + offset, depth + offset) midpoint = p1 + 0.5 * v # midpoint of whole wall startpt.X + 0.5 * v.X walldir = v.Normalize() # X/ Length, Y/ Length , Z/ Length updir = XYZ.BasisZ # Basisvektor in Z Richtung (0,0,1) viewdir = walldir.CrossProduct(updir) # XYZ(0, 1, 0) # set transform of SectionBox trans = DB.Transform.Identity # .Identity has to be called to trans.Origin = midpoint trans.BasisX = walldir trans.BasisY = updir trans.BasisZ = viewdir # create SectionBox sectionBox = DB.BoundingBoxXYZ() # instantiate sectionBox.Transform = trans sectionBox.Min = minpt sectionBox.Max = maxpt return sectionBox
def boundingboxLine(elem): # Location Line of Wall line = elem.Location.Curve # Every 2D line geometrie is a Curve, in Revit p1old = line.GetEndPoint(0) p1 = XYZ(p1old.X, p1old.Y, 0) p2old = line.GetEndPoint(1) p2 = XYZ(p2old.X, p2old.Y, 0) v = p2 - p1 # vector # define Section Box length = v.GetLength() # sqrt(x*x + y*y + z*z) height = 4 / 0.3048 # 4m height calculation 1 ft = 0.3048 m ; 1m = 1/0.3048 ft ≈ 3.28.. offset = 0.5 / 0.3048 # minZ = min(p1old.Z, p2old.Z) #Set 2pts, to define BoundaryBox of Section: Min (lower-left-back)& Max (upper-right-front), minpt = XYZ(-length / 2.0, minZ - offset, 0) #from midpoint of wall. X = wall-length /2 maxpt = XYZ(length / 2.0, height + offset, offset) midpoint = p1 + 0.5 * v # midpoint of Line startpt.X + 0.5 * v.X walldir = v.Normalize() # X/ Length, Y/ Length , Z/ Length updir = XYZ.BasisZ # Basisvektor in Z Richtung (0,0,1) viewdir = walldir.CrossProduct(updir) # !!!!------------------------ #set transform of SectionBox trans = DB.Transform.Identity #Identity has to be called to trans.Origin = midpoint trans.BasisX = walldir trans.BasisY = updir trans.BasisZ = viewdir # create SectionBox sectionBox = DB.BoundingBoxXYZ() # instantiate sectionBox.Transform = trans sectionBox.Min = minpt sectionBox.Max = maxpt return sectionBox