Hi, I’m looking for advice and opinions.
I’m trying to obtain a low average line (sort of like the Location line adjusted to the solid geometry).
I found a solution that I’m presenting here. Do you have any other ideas? (I may have overlooked an obvious solution.)
Thank you in advance.
edit: I found a second track
Python script
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
pts=IN[0]
pord=sorted(pts,key=lambda p:(p.X,p.Y))
l=Line.ByStartPointEndPoint(pord[0],pord[len(pord)-1])
OUT = l
Sincerely,
christian.stan
Could you translate the location line by the base offset?
Note you can get the last item in a python list with mylist[-1]
2 Likes
Hi, thanks for the reminder about the lists. The offset would be 0 here in x,y,z.
I’m extending the location line on both sides.
I’m trying to get the outer solid envelope free of all voids in order to create a solid line cut.
I don’t know if this is very clear.
Sincerely,
Christian.stan
You could use a BoundingBox.ByMinimumVolume node and work from there
1 Like
Hi,
Thank you, I’ll follow up on this idea (I think it will be the most direct).
edit:
Sincerely,
christian.stan
Hi, I tried using a pseudo-bounding box by minimum volume via the API.
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])
[ol.AddPoint(lptsext[i]) for i in range(2,len(lptsext))]
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=lineht
Sincerely,
Christian.stan
1 Like