Hello, I can’t understand the result I’m getting:
I thought I’d found a solution to obtain an internal mean line for the cubic bounding volume, the geometry of the wall.
My logic:
- Take the outer face, find the points defining it.
- Take the inner face, find the points defining it, then move them to the outer face.
- Define an outline to have only the extreme points.
- Rebalance them toward the middle of the wall and lower them to the mean line.
When the wall is in two quadrants (q2, q4), I don’t get the correct line.
Could one of you try under 2023 or 2025 to see if you get the same result?
import sys
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import Element,Wall,HostObjectUtils,ShellLayerType,XYZ,Outline,Line
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
w=UnwrapElement(IN[0])
ep=w.Width
orientation=w.Orientation
lc=w.Location.Curve
direc=XYZ(lc.GetEndPoint(1).X - lc.GetEndPoint(0).X,lc.GetEndPoint(1).Y - lc.GetEndPoint(0).Y,lc.GetEndPoint(1).Z - lc.GetEndPoint(0).Z).Normalize()
def findpts(f):
lpts=[]
clt=f.GetEdgesAsCurveLoops()
for cl in clt:
for c in cl:
lpts.append(c.GetEndPoint(0))
return lpts
refext=HostObjectUtils.GetSideFaces(w,ShellLayerType.Exterior)
refint=HostObjectUtils.GetSideFaces(w,ShellLayerType.Interior)
faceext=w.GetGeometryObjectFromReference(refext[0])
faceint=w.GetGeometryObjectFromReference(refint[0])
lptsext=findpts(faceext)
lptsint=findpts(faceint)
for p in lptsint:
lptsext.append(p.Add(orientation.Multiply(ep)))
ol=Outline(lptsext[0],lptsext[1])
for i in range(2,len(lptsext)):
ol.AddPoint(lptsext[i])
pstartloc=lc.GetEndPoint(0)
pstarttransit=ol.MinimumPoint.Add(orientation.Multiply(-ep/2))
pstart=XYZ(pstarttransit.X,pstarttransit.Y,pstartloc.Z)
pendtransit=ol.MaximumPoint.Add(orientation.Multiply(-ep/2))
pend=XYZ(pendtransit.X,pendtransit.Y,pstartloc.Z)
lineht=Line.CreateBound(pstart,pend).ToProtoType()
OUT=[p.ToPoint() for p in lptsext],lptsext,lineht
Thank you in advance.
Sincerely,
christian.stan