I want to intersect a Wall Face (got that as PlanarFace) and a Solid with the DoesIntersect method.
But this method doesn´t work with the planarface. Can I convert that to a face/surface somehow?
Tried to GetSurface but that gives me a Plane
You’ll need to convert the Revit face to a DesignScript (Dynamo) surface first, which you should be able to do with the ToProtoType() method. Something along the lines of this:
dynamoFace = x.ToProtoType()
dynamoSolid = y.ToProtoType()
z = dynamoFace.DoesIntersect(DynamoSolid)
Note that it’s likely there is a better way to do what you’re after by staying in the Revit API enitrely, but we don’t have enough context to help just yet.
I found a method and now have wonderful 5mm solids from the faces
lines = UnwrapElement(IN[0])
normal = UnwrapElement(IN[1])
loop = CurveLoop.Create(lines)
z= GeometryCreationUtilities.CreateExtrusionGeometry(List[CurveLoop]([loop]),normal,0.005)
OUT = z
lineslist = UnwrapElement(IN[0])
normalslist = UnwrapElement(IN[1])
for lines, normals in zip(lineslist,normalslist):
for line, normal in zip(lines, normals):
loop = CurveLoop.Create(line)
z= GeometryCreationUtilities.CreateExtrusionGeometry(List[CurveLoop]([loop]),normal,0.005)
OUT = z
Next idea is to use UV method to get min and max points and build a whole face on my own.
But I have no luck again, here is what i get for UV 0,0 and UV 1,1:
for floor, wall in zip(floors,walls):
outlist=[]
for w in wall:
x=BooleanOperationsUtils.ExecuteBooleanOperation(floor, w, BooleanOperationsType.Intersect).Volume
outlist.append(x)
outlist2.append(outlist)
OUT = outlist2
for walls,floor in zip(wallslist,floors):
outlist2=[]
for wall in walls:
outlist=[]
for w in wall:
x= w.Project(floor).Distance
outlist.append(x)
outlist2.append(outlist)
outlist3.append(outlist2)
OUT = outlist3
Hello Jacob, thats in fact the method I´m starting with, but there is so much else to do
At this moment i got nearly everything working with Revit.DB, had a hard time and would be very interrested in your thoughts about my methods. Questionable workarounds with question marks.
Scale Floor Solid with SolidUtils.CreateTransformed(scaledSolid, transform)
Get Walls with ElementIntersectsSolidFilter(s)
Get wall solid with w.get_Geometry(opt)
Intersect with BooleanOperationsUtils.ExecuteBooleanOperation(floor, w, * BooleanOperationsType.Intersect).Volume to drop walls that are intersecting too little
Get floor centroid with s.ComputeCentroid()
Get 2 largest wall faces by s.Faces and sort by area
Get nearest wall face for every wall by w.Project(floor).Distance
Get vertical floor faces with s.FaceNormal.Z ==0
Filter floor faces by edges that have length=floor hight
Now it gets interresting at finding the wall face for every floor face.
Get all Face normal vectors by x=f.FaceNormal
Match parallel wall and floor faces
Get floor faces center by x=face.GetEdgesAsCurveLoops(), y=z.GetPlane(), center= y.Origin???
Pull floor face centerpoints on wall faces by wall.Project(point).Distance and use distance to match a floor face to every wall face
Get lines from floor faces by w.GetEdgesAsCurveLoops() and y=u.ToProtoType()
Switch to Dynamo geometry, lines to Polycurve, surface by patch, use U/V parameter 0/0.5 and 1/0.5 to get centerline on floor face.??? , thats where the family will be placed
Back to Revit Geometry, pull start/endpoint of line on wall face by w.Project(p).XYZPoint
finally place family by doc.Create.NewFamilyInstance(f,p,v,family)
There is for sure potential to make some things better, for example, can i get the distance between 2 faces?
This seems pretty close to spot on. it may be that the 3% of conditions returning an error could be resolved by modifying the call methods, but it’d require you post the full python to confirm.
So I´m now using the Signed distance and the dotproduct, it works now for all the walls that didnt work befor, but now the others don´t work anymore Hope to find the mistake tomorrow. And then i also will post the code you mentioned, maybe you will find out why my project method fails.
current status:
for w,p in zip(wall,point):
a = w.GetEdgesAsCurveLoops()
for i in a:
k=i.GetPlane()
v=p-k.Origin
x=k.Normal.DotProduct(v)
o=p-x*k.Normal
p=o.ToPoint()
wallslist = UnwrapElement(IN[0])
floors = UnwrapElement(IN[1])
outlist3=[]
for walls,floor in zip(wallslist,floors):
outlist2=[]
for wall in walls:
outlist=[]
for w in wall:
x= w.Project(floor)#.Distance
outlist.append(x)
outlist2.append(outlist)
outlist3.append(outlist2)
OUT = outlist3
faces = UnwrapElement(IN[0])
points = UnwrapElement(IN[1])
outlist2=[]
for face, point in zip(faces, points):
outlist=[]
for f,p in zip(face,point):
loops = f.GetEdgesAsCurveLoops()
for loop in loops:
plane = loop.GetPlane()
diff = p-plane.Origin
normal = plane.Normal
skalar = normal.DotProduct(diff)
pointOnPlane=p-skalar*normal
dynPoint=pointOnPlane.ToPoint()
outlist.append(dynPoint)
outlist2.append(outlist)
OUT = outlist2
Still interrested in finding out why the Project-Method doesn´t work, going to isolate a failing element…
So this planar faces are so strange, they always behave as they would have no boundaries, as if they were planes. So they can not be used for face intersection etc…
BUT if you want them to behave one single time like a plane, they don´t and won´t let you project if there is a hole.
So the method with the curveloops/plane seems to be the better option for my purposes.
It is definitely the cutout, i now remember that i had the exact same problem with the dynamo geometry version, thats why I also there used pull onto plane instead of pull onto face.