Failed to perform the Boolean operation

Failed to perform the Boolean operation

MiguelGT17
Advocate Advocate
374 Views
1 Reply
Message 1 of 2

Failed to perform the Boolean operation

MiguelGT17
Advocate
Advocate

Hope everyone is doing well, the operation I need to execute is a intersection between the room solid space and a solid extrusion from wall faces. In my las post I solved a similar issue by placing a single wall and editing the profile:

 

MiguelGT17_1-1666220877809.png

 

 

MiguelGT17_0-1666220837133.png

 

Unfortunately, in this next scenario I have a completely different kitchen layout and the problem comes up with the dining room:

 

MiguelGT17_3-1666221057614.png

 

this is a small piece of code:

 

			//Set BoundarySegments Options
			SpatialElementBoundaryOptions  sebOptions = new SpatialElementBoundaryOptions{
				SpatialElementBoundaryLocation= SpatialElementBoundaryLocation.Finish
			};
			
			
			//Eliminate or ignore null room location
			List<SpatialElement> allRoomsInModel = new FilteredElementCollector(doc).OfClass(typeof(SpatialElement)).WhereElementIsNotElementType().Cast<SpatialElement>().Where(x => x.Category.Name == "Rooms" && x.Location != null).ToList();
			if (allRoomsInModel.Any()) {
				foreach (SpatialElement element in allRoomsInModel) {
					
					Room room = element as Room;
					double roomWallFinishArea = 0;
					
					if (room != null ) {
						
						if (room.Name != "DINING 99") {
							continue;
						}
						
						
						SpatialElementGeometryResults results2 = cal.CalculateSpatialElementGeometry(room);
						Solid roomSolid2 = results2.GetGeometry(); //GetSolid from spatial geometry
						
						List<double> areas = new List<double>();
						
						#region 2.3) Wall Finish
						foreach (Face roomFace in roomSolid2.Faces) {
							// Filter spatial room Face by same wall Id from wall retrieved from bounding segment, instead of doing FaceNormal.Z != 1 ...etc.
							IList<SpatialElementBoundarySubface> boundaryGeometryInfoList = results2.GetBoundaryFaceInfo(roomFace);//it will retrieve INFO for geometry boundary that define this specific spatial roomFace
							foreach (SpatialElementBoundarySubface boundaryGeometryInfo in boundaryGeometryInfoList)//for each wall Info get Face info
							{
								if (boundaryGeometryInfo.SubfaceType == SubfaceType.Side) //Work with boundary geometry info that is a side face type
								{
									//get element that gave rise to this geometry face <> wall face
									Wall wall = doc.GetElement(boundaryGeometryInfo.SpatialBoundaryElement.HostElementId) as Wall;
									if (wall != null) {
										
										
										
										//Face of the bounding wall ()
										Face wallFace = boundaryGeometryInfo.GetBoundingElementFace();
										if (wallFace is PlanarFace) {
											//planarFace of the bounding wall
											PlanarFace planarWallFc = wallFace as PlanarFace;
											if (!areas.Contains(wallFace.Area)) {
												//tailorBird.tessellateFace(wallFace,doc);
												
												#region 2.3.1). Create Solid from opening inserts in each boundary wall
												IList<ElementId> wallInserts = wall.FindInserts(true,false,true,true);
												Solid overallOpeningSolid = null;
												if (wallInserts.Any()) {
													foreach (ElementId idinsert in wallInserts) {
														Element insert = doc.GetElement(idinsert);
														FamilyInstance famIns = insert as FamilyInstance;
														XYZ pCutDir = XYZ.Zero;
														CurveLoop curveLoop = ExporterIFCUtils.GetInstanceCutoutFromWall(doc,wall,famIns,out pCutDir);
														/// ExporterIFCUtils.ComputeAreaOfCurveLoops( loops )
														
														
														IList<CurveLoop> profileLoops = new List<CurveLoop>();
														profileLoops.Add(curveLoop);
														if (overallOpeningSolid == null) {
															Solid negExt = GeometryCreationUtilities.CreateExtrusionGeometry(profileLoops,-pCutDir,1);
															Solid posExtr = GeometryCreationUtilities.CreateExtrusionGeometry(profileLoops,pCutDir,1);
															overallOpeningSolid =  BooleanOperationsUtils.ExecuteBooleanOperation(negExt,posExtr,BooleanOperationsType.Union);
														
														}
														else if (overallOpeningSolid != null) {
															Solid negExt = GeometryCreationUtilities.CreateExtrusionGeometry(profileLoops,-pCutDir,1);
															Solid posExtr = GeometryCreationUtilities.CreateExtrusionGeometry(profileLoops,pCutDir,1);
															Solid openingSolid = BooleanOperationsUtils.ExecuteBooleanOperation(negExt,posExtr,BooleanOperationsType.Union);
															overallOpeningSolid = BooleanOperationsUtils.ExecuteBooleanOperation(overallOpeningSolid,openingSolid,BooleanOperationsType.Union);
														}
													}
												}
												#endregion
												
												#region 2.3.2). Create solid from bondary wall face
												Solid wallFaceExtrus = GeometryCreationUtilities.CreateExtrusionGeometry(planarWallFc.GetEdgesAsCurveLoops(),planarWallFc.FaceNormal,0.1);
												//make sure the wallFaceExtruded it's surrounding the room (roomSolid is produced by wall faces, so they have same height, although width is variable that's why we intersect both solids)
												TaskDialog.Show("de",wall.Id.ToString());
												wallFaceExtrus = BooleanOperationsUtils.ExecuteBooleanOperation(roomSolid2,wallFaceExtrus,BooleanOperationsType.Intersect);
													
												#endregion
												
												
												areas.Add(wallFace.Area);
											}
										}
									}
								}
							}
						}
						#endregion
						
					}
				}
			}
			

 

 

I'm attaching the revit project:

MiguelGT17_4-1666222505134.png

 

Help with this one please, thanks you in advance

 

Miguel G.

 

0 Likes
375 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni

Dear Miguel,

  

I see your pictures and your code, but they do not tell me what the problem is.

  

Can you be more specific? Otherwise, I have to reverse engineer your code, try to guess what you are trying to achieve, and try to guess what the problem might be. That is a rather laborious and error-prone approach to the issue.  🙂

  

Thank you.

  

That said, I did find a rather obscure suggestion to address that particular error under certain circumstances back in 2015:

  

https://thebuildingcoder.typepad.com/blog/2015/05/cloning-a-solid-angelhack-3d-web-fest-and-dubai.ht...

  

Maybe not so relevant for your current situation, but who knows?

  

Cheers

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes