Revit secondary development knowledge sharing (7) Boolean operation of geometry

Only geometry-related Boolean operations are provided in revitAPI, which are the following methods (as shown in the figure)
Insert picture description here

The difference between adding ModifyingOriginalSolid to the method suffix is ​​that if it is not added, the geometry is operated, and a new geometry is generated after the operation, without changing anything to the original geometry. If it is added, it will directly operate on the original geometry.
Today is mainly to introduce the use of the ExecuteBooleanOperation method. First go to the operation and then explain Just Do It! ! !

Solid s = BooleanOperationsUtils.ExecuteBooleanOperation(solid0, solid1, BooleanOperationsType.Intersect);

Insert picture description here
There are three parameters in this method, among which BooleanOperationsType is an enumeration value that controls the cutting method, which contains three parameters (as shown in the figure below), namely union, difference, and intersection.
Insert picture description here

It should be noted here that when using the union and intersection, there is no specific order of addition. However, when you want to take the difference set, use solid1 to subtract from solid0, and keep the solid0 part.
Sharing is here, hope this method can help you

Guess you like

Origin blog.csdn.net/Oneal5354/article/details/108681588