A subway station spatial collision detection optimization method based on Revit secondary development technology

Through Revit secondary development technology, a component family library was created and the API was used to detect collision types, which enabled automated optimization of hard collisions, soft collisions, and interval collisions in subway stations. This solved the problems of insufficient detection and optimization in existing technologies and improved construction efficiency and design accuracy.

CN119939916BActive Publication Date: 2025-09-23EAST CHINA JIAOTONG UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510008375.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-03
Publication Date
2025-09-23
Estimated Expiration
2045-01-03

AI Technical Summary

Technical Problem

Existing technologies are unable to effectively detect and optimize hard collisions, soft collisions, and interval collisions in subway station design, resulting in low construction efficiency and unreasonable design that cannot meet the actual needs of the project.

Method used

Through Revit secondary development technology, a component family library is created, and the API filtering method is used to detect collision types. The collision points are automatically adjusted through parametric modeling and optimization procedures to achieve accurate detection and optimization of hard collisions, soft collisions and interval collisions.

Benefits of technology

It improves the accuracy of collision detection and construction efficiency, reduces rework and modification, and meets the automation and intelligent requirements of subway station design.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119939916B_ABST
    Figure CN119939916B_ABST
Patent Text Reader

Abstract

The present invention discloses a detection and optimization method for three different collision forms of subway stations: hard collision, soft collision, and interval collision. The method also develops a plug-in for automatically constructing, detecting, and optimizing subway station models based on Revit secondary development technology, belonging to the field of spatial collision detection and optimization for subway stations. The method comprises: step S1. creating a component family, expanding the functions of Revit software, and building a BIM model family library suitable for subway stations; step S2. parametrically creating a subway station BIM model; establishing Excel program interfaces between CAD and Revit respectively, using Excel tables as a bridge, importing modeling information and the created component family into the Revit modeling software, and completing the creation of the subway station BIM model using Revit secondary development parametric modeling; step S3. implementing hard collision, soft collision, and interval collision functions; and step S4. automatically adjusting and optimizing collision point results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a subway station space collision detection optimization method based on Revit secondary development technology, and belongs to the field of engineering design. Background Art

[0002] In order to better solve the problem that the positions of internal components of subway stations intersect or overlap due to insufficient design or design position deviation by relevant designers, which leads to collisions between different components in three-dimensional models and actual engineering projects, thus affecting normal construction and normal use of component functions. Based on the creation of the BIM model of the subway station, the present invention will start from the collision detection and optimization problems involving BIM technology, develop component collision detection functions within and between different engineering fields of the BIM model of the subway station, and study methods for automatic optimization and adjustment of the results of unreasonable collisions that have occurred. Improving the accuracy of design and improving the efficiency of design and construction have certain theoretical value and practical significance for further promoting the automation, intelligence and wisdom of the subway station design process.

[0003] In complex projects, clash checking often requires inspection after the engineering drawings are delivered and the information model is built. This includes checks between different disciplines and within the same discipline. Unreasonable clashes discovered during inspection require rework and redesign. Traditional inspections typically involve importing the model into an external Navisworks software, which wastes significant time and resources. This system only performs hard clash checks and fails to detect soft clashes and intermediate clashes that may arise during the design phase and may not meet operational and maintenance requirements. Furthermore, if any unreasonably large areas are discovered, they must be corrected in Revit and then re-inspected in the external software, resulting in unnecessary time and money losses. Furthermore, adjustments to design irregularities, such as collision points, require manual work, which is time-consuming and labor-intensive. Furthermore, the modified structure may clash with other design elements, leading to new construction irregularities. While existing research has reduced workload and improved efficiency to some extent, there is still significant room for improvement in terms of convenience and practicality. Different optimization and adjustment plug-ins are being developed to enhance the flexibility, efficiency, and specificity of optimization and adjustment. Summary of the Invention

[0004] Purpose of the Invention: To overcome the shortcomings of the existing technology, this invention provides a method for optimizing spatial collision detection in subway stations based on Revit secondary development technology. This method improves the accuracy of soft collision detection results, making this function more practical and applicable to engineering practice, and enabling a wider range of applications.

[0005] Technical solution: To solve the above technical problems, the present invention provides a subway station space collision detection optimization method based on Revit secondary development technology, which is characterized by comprising the following steps:

[0006] S1: Create component families and build a BIM model family library suitable for subway stations: Based on the current subway station structure, component characteristics, and the geometric and logical relationships of each component, select appropriate family templates, create each component family, and manage the component families by building a family library management system through secondary development of Revit. Classify and archive the Revit families according to component type;

[0007] S2: Parametric creation of subway station BIM model: Establish Excel program interfaces between CAD and Revit, import modeling information and created component families into Revit modeling software, and use Revit secondary development parametric modeling to complete the creation of subway station BIM model;

[0008] S3: Use the filtering method provided by the API to traverse all component elements, classify all elements, extract the elements that need to collide, and form a collision element set;

[0009] S4: For each collision point in the collision element set, determine the collision type, which includes hard collision, soft collision, and interval collision;

[0010] S5: Determine the optimization start and end points;

[0011] S6: According to the collision point, the corresponding optimization program is called to adjust and optimize;

[0012] S7: Modify the engineering design based on the collision check results to obtain the final design plan.

[0013] Preferably, the specific steps of step S3 are:

[0014] S31: Build the development environment, reference related assemblies and implement the interface of the IExternalCommand method;

[0015] S32: Use UIDocument and Document to obtain interface interaction and actual content;

[0016] S33: Create a filter to filter all components of a certain profession that require collision detection. Determine the filtering method for the category and family type of the profession by checking the Built-in category and family type in Lookup. Use the ElementCategoryFilter method and the ElementClassFilter method to filter. Use the "and" filter LogicalAndFilter in the logical filter to connect the category filter and the family type filter.

[0017] S34: Create a collector: Use the FilteredElementCollector method to create an element collector, and connect the filter connected in S33 to the collector using the WherePasses method;

[0018] S35: Create a highlight prompt function: In the element collector that has been filtered out and meets the conditions, use the foreach method to traverse the collector and add the highlight function to all the elements in it;

[0019] S36: Use the foreach method to parse all the elements in the collector created above, and use the primitive intersection filter to create a collision element filter and collector;

[0020] S37: Define the auxiliary collision professional type for collision detection, use the WherePasses method to connect the collision element filter with the OfClass method, which is the definition method of the auxiliary collision element family type, so that the elements in the collector will only collide with the specific family type after typeof through the collision element filter and obtain the collision result. Connect the collision element collector with the collision element filter to receive the final collision result, and use the List method to output it in the form of a list.

[0021] Preferably, step S6 comprises the following steps:

[0022] S61, interrupting the collision component at the optimization start and end points;

[0023] S62. Using a projection method to obtain the center point of the component cross section corresponding to the optimized position;

[0024] S63. Create a Line for avoiding components;

[0025] S64, set the avoidance distance;

[0026] S65: Achieve avoidance and obtain the final optimized map.

[0027] As a preference, the method specifically comprises the following steps:

[0028] 1) Use locationCurve to get the location of the pipeline and the locations of the first and last endpoints of the pipeline;

[0029] 2) Get the pipeline endpoint closest to the optimization adjustment start and end points clicked by the designer on the pipeline. Create a method using GetNearXYZ. In this method, pass in three X, Y, and Z variables in a manually sorted order (assuming they are variables 1, 2, and 3). In this method, use the if statement to make a judgment: if the distance from variable 2 to variable 1 is greater than the distance from variable 3 to variable 1, then return variable 3; otherwise, return variable 2.

[0030] 3) Pass the GetNearXYZ method created in 2) into the original class and match the optimized start point of the pipeline and the two endpoints of the component with variables 1, 2, and 3. Also, match the optimized end point of the pipeline and the two endpoints of the component with variables 1, 2, and 3. Note that the order in which the overloads are placed in the method must be flexibly determined based on the different sorting in 2) to ensure that the component breakpoints are correct.

[0031] (5) Project the point clicked by the designer on the pipe onto the center point of the component cross section. Whether in three-dimensional space or on a two-dimensional plane, since the user clicks a point on the component as the starting and ending point of the optimization adjustment, the point clicked is a point on the outer surface of the pipe. This will cause the direction of the optimized pipe to change from the original direction of the line connecting the center points of the two end cross sections to the direction of the line connecting the center point of the end cross section and the click point on the outer surface of the pipe, which will cause directional deviations. Therefore, it is necessary to map it. Use the Project method, which can project the incoming point onto a given line, project the point on the pipe surface onto the center line of the component, and finally obtain the projected point. The specific code is as follows:

[0032] varPosTouYing=locationCurve.Curve.Project(NearXYZ).XYZPoint;

[0033] (6) Use the List list to receive the Line, adjust the number of pipes that the optimized pipeline consists of, that is, the number of copies of the Line, and create a new pipeline based on the line segment. Use the GenerateLines method to pass in the X, Y, and Z of the two endpoints of the pipeline, the X, Y, and Z of the optimized start and end points, and the offset of the avoidance distance. Cut the codes in (4) and (5) into the List collection, set the variable to use the CreateBound method to create a line between the two points of the optimized start and end points, and replace the variable with locationCurve.Curve. Create a new Line collection in the list, pass the optimized start and end points into the collection, and create a Line for the avoidance pipeline.

[0034] (7) Set the avoidance distance, add the coordinates of the optimized start and end points to the offset coordinates set by offset, and obtain the coordinates of the pipeline after avoidance. Then, use the same method to create a line from the optimized start and end point to the pipeline position after avoidance, as well as a line between the two avoidance points. Finally, return the values ​​of the lines in (6) and (7);

[0035] (8) Open a transaction outside the List list and name it. Use the foreach method in the transaction to loop through the Line created in (6), obtain the pipeline ID, force it to become a Pipe and create the pipeline. Finally, close the transaction and run it to achieve automatic avoidance of the pipeline.

[0036] (9) Since the direction of the pipeline changes after automatic avoidance, according to the actual project, it is also necessary to create a pipe elbow at the avoidance point to connect the pipeline. First, loop the pipeline, obtain all connectors and put them into the same collection, then use the foreach method to traverse the connector collection, and use the if and IsAlmostEqualTo methods to make a judgment. If there are other connectors with the same value in the collection of the traversed connector, it means that the connector is where the pipeline changes direction, that is, where the optimization adjustment is made, and the connector is selected. In addition, since traversal is used, the connector itself will be selected in the collection, so it is also necessary to use Owner to make a judgment, and select the connectors with different IDs based on the previous condition and return them. Finally, open the transaction, create an elbow at the obtained connector, and close the transaction to run.

[0037] Preferably, step S6 comprises the following steps:

[0038] 1) Create a new class and add relevant references to build a development environment;

[0039] 2) Use the filter to obtain all the ducts, and use the primitive intersection filter to define the type of collision result with the duct as pipe;

[0040] 3) Get the collision point. First, get the location of the two colliding components. Since Curve cannot obtain the relevant coordinates, it is necessary to convert them into Line.

[0041] Create a new method, pass in the pipe and duct Lines, obtain the X, Y, and Z coordinates of the collision point, adjust the Z coordinate of one component's location to match that of the other, and use the CreateBound method to create a line that follows the same path as the original component. At this point, the centerlines of the two components become two intersecting lines on the same plane. Obtain the intersection of the two lines, which is the point at which the new Line collides with the original Line.

[0042] Move this intersection point on the cross section of one component in the direction of the other component's direction to the edge of the component's outer surface. Here, the component's direction is obtained using Curve, the opposite direction is obtained using the Negate method, and the cross-sectional parameters of the pipe and duct are obtained using the Parameter method. By combining this directional information with the cross-sectional parameters and moving the intersection point in both the positive and negative directions of the component's direction to the component's outer surface, the collision point on the component's outer surface is obtained, which is the starting and ending point of the optimization.

[0043] 4) Finally, write the optimization code for manually adjusting the collision optimization function, delete the manual click function, and convert the manually clicked points into the collision points on the outer surface of the component obtained in 3), so as to realize the function of automatic optimization adjustment at the collision points on the outer surface of the component.

[0044] Preferably, step S6 comprises the following steps:

[0045] For situations where the adjustable space around the component is small or there are special requirements for the optimization method of the component, only the collision point can be optimized and adjusted

[0046] (1) Set the global variables for optimized width and optimized height in the optimization program. The meanings of the variables are shown in the figure.

[0047] (2) Delete the click function in the manual optimization program, use filters and collectors to filter and collect the components that need to be optimized, and use the foreach method to parse the collector and obtain the components that need to be optimized;

[0048] (3) Replace the avoidance distance offset with the global variable of the optimized height. Obtain the collision point of the component and the distance between the collision points. Use the if method to make a judgment. When the optimized width input by the designer is less than the distance between the collision points, the optimized width is too small and the optimized component will still collide with the original component again, so the output optimization is unreasonable. On the contrary, it means that the optimized width is sufficient and the optimization can be successfully performed. Execute the optimization program, obtain the collision point position, and automatically avoid the component at the collision point.

[0049] In the present invention, the specific steps for pipelines with circular and square cross-sections are:

[0050] S41: Create a new project in Visual Studio and add a new class, reference the relevant assembly, directly use the IExternalEventHandler method to implement the interface, and obtain the interface interaction and actual content;

[0051] S42: Setting global variables: There are four global variables to be set, namely: the ID of the detection component, the ID of the auxiliary detection component, the allowable spacing value between the detection components, and the angle value of the copy direction;

[0052] S43: Set four local variables that match the global variables, and connect the global variables and local variables with equal signs. Note that the spacing value in the global variables, which involves length and distance, needs to be divided by 0.3048 for unit conversion;

[0053] S44: Use the new method to create an instantiation of ElementId, add an arbitrary initial element ID to it, and assign the ID value of the detected element to the initial ID value of the copy function (CopyElement);

[0054] S45: Use filters and collectors to filter and collect the professions to which the components that require soft collision detection belong, so that the collector can collect elements of all components of the profession;

[0055] S46: Create a List list, use the foreach method to parse the collector, use the string.Compare method and the if language to determine its component ID, assign the component ID that needs to be detected in the collector, that is, the value of the global variable and local variable set in steps S42) and S43) to the initial ID value set in step S44), and add the component element to the created List list;

[0056] S47: Start a "transaction" and set its name: the sine and cosine trigonometric functions will be used for the conversion. Set local variables for sine and cosine again. For easier identification, simply add the sine and cosine function representations to the angle values ​​of the copy direction set in steps S42) and 3) as new local variables. Use the Math method, utilizing C#'s built-in Sin and Cos methods, to convert the angle values ​​into trigonometric function values ​​and assign them to the newly set local variables.

[0057] S48: Set the copy distance. Since this article uses the CopyElement copy method, this method has three overloads, namely doc, component ID, and the distance copied in the XYZ directions. Because in actual engineering, the relative positions between components are not necessarily exactly in these three positive directions, so the spacing between components needs to be decomposed into the distance in the positive direction, so that the decomposed distance in the positive direction can be loaded into the copy method as an overload value. The CopyElement method uses the Pythagorean theorem to synthesize the distance in the positive direction into the copy distance based on the overload value, creates a local distance variable for the copy distance in the positive direction of the section plane, and converts the spacing value with it using trigonometric functions to obtain the correct copy distance in the positive direction. The specific copy code is as follows:

[0058] vardistance1=jianju*cosjiaodu;

[0059] vardistance2=jianju*sinjiaodu;

[0060] Here, distance1 and distance2 are local distance variables, representing the left and right and up and down replication distances of the detection component within the quadrant plane where its cross section is located (perpendicular to the component's spatial orientation). jianju is a global variable. Since pipelines are system families, the replication start and end points are the center of the component's cross section. Therefore, the spacing is the straight-line distance between the line connecting the centers of the two component cross sections and the intersection of the two component's outer surfaces. jiaodu is a global variable. Adding a trigonometric function to it becomes the local variable set in 7).

[0061] S49: Copy the component. Create a new list and name it. Use the CopyElement method in the list to copy the element with the given component ID in the global variable. Since the direction of the copy distance in the XYZ override in the CopyElement method can only be set directly or through variable assignment and cannot be automatically changed, when writing the XYZ override, you must first determine the component's direction. Based on the component's direction, set distance1 and distance2 to the quadrant coordinates corresponding to the plane where the component's cross section lies. For example, if the component's direction is X, place the override in YZ. Finally, close the transaction to copy it. If the copy direction matches the component's direction, it will be equivalent to extending the component in its direction, defeating the purpose of detecting collisions with the auxiliary collision detection component. Therefore, you only need to set the selection in subsequent interface development. Designers can determine the component's direction and run different detection functions based on different directions.

[0062] S410: Perform collision detection and output the results. Use the foreach method to traverse the new list created in step S49, use the primitive intersection filter and collector, and after determining the specialty of the single component to be used for auxiliary collision detection, specify the family type for auxiliary collision detection in the program.

[0063] S411: Output the results of the components that have soft-collided with the component with the given ID. When outputting the list of collision results, use an if statement to determine whether the component in the list has the ID of the auxiliary detection component input in the global variable. If so, it means that a soft collision has occurred, and the result is output; if the auxiliary detection component ID in the global variable is not in the list, it means that no soft collision has occurred, and no result is output;

[0064] S412: Delete the copied elements: Delete them to ensure that the model is not changed, start a new transaction, delete the copied elements in the list created in the copy component of step S49, and finally close the transaction. This step needs to be placed at the last step of the detection process to restore the model to its original state.

[0065] In the present invention, when the cross-sections of the two components undergoing soft collision detection are one circular and the other square, the specified spacing between the two components cannot be directly equated with the replicated distance when performing soft collision detection on the two components. This is primarily because when the two components have the same cross-section, the replicated distance equals the spacing, and the two components are tangent, resulting in no collision. However, when the cross-sections of the two components differ, the relationship between them may intersect when the replicated distance equals the spacing. In this case, a soft collision may occur when the replicated distance equals the spacing, resulting in biased detection results and misleading designers. Furthermore, when the components have different cross-sections, to ensure detection accuracy, the detection result should be no collision when the actual distance between the components is greater than the specified spacing. However, when the spacing equals the replicated distance, a collision has already occurred. Even if the actual distance is slightly greater than the spacing, the two components will still intersect in cross-section, resulting in a collision. In this case, even if the actual distance is slightly greater than the spacing, which meets the relevant regulations, as long as the replicated detection component and the auxiliary detection component are not tangent, the program will still display a soft collision, leading to inaccurate results.

[0066] In the present invention, when the cross-sections of the components are different, the copy distance needs to be adjusted. Through geometric relationships, the copy distance adjusted according to the spacing between the two components makes the two components in a tangent state, and they are copied to the same height as the auxiliary detection component in the longitudinal direction, so that the outer surfaces of the two components are tangent, and finally when the actual distance is equal to the spacing, there will be no collision. In addition, when the actual distance is slightly larger than the spacing, the lateral copy distance of the component remains unchanged, so that the position of the component after vector synthesis will not intersect with the auxiliary detection component to produce a collision; on the contrary, when the actual distance is less than the spacing, the lateral copy distance of the component remains unchanged, so that the copied component will intersect with the auxiliary detection component to produce a collision, which better conforms to engineering practice and solves the problem that the accuracy of the above-mentioned detection is affected by the cross-section of the component.

[0067] In the present invention, in step S48, as the relative angle θ between the auxiliary collision component and the detection component changes, the method for calculating the distance from the intersection of the line connecting the two components and the outer surface of the square cross section to the center of the square also changes. In addition, the positive and negative changes in the trigonometric function caused by the change in θ will also affect the change in the direction of the copy, so it is necessary to distinguish them, as follows:

[0068] When 0°<θ<45°, d1=[d+r+a / (2cosθ)]cosθ-ra / 2, d2=(d+r+a / (2cosθ)sinθ;

[0069] When 45°<θ<90°, d1=[d+r+a / (2sinθ)]cosθ-ra / 2, d2=(d+r+a / (2sinθ)sinθ;

[0070] When 90°<θ<135°, d1=[d+ra / (2tanθ)]cosθ+r+a / 2, d2=(d+ra / (2tanθ)sinθ;

[0071] When 135°<θ<180°, d1=[d+ra / (2cosθ)]cosθ+r+a / 2, d2=(d+ra / (2cosθ)sinθ;

[0072] When 180°<θ<225°, d1=[d+r+a / (2cosθ)]cosθ-ra / 2, d2=(d+r+a / (2cosθ)sinθ;

[0073] When 225°<θ<270°, d1=[d+r+a / (2sinθ)]cosθ-ra / 2, d2=(d+r+a / (2sinθ)sinθ);

[0074] When 270°<θ<315°, d1=[d+ra / (2tanθ)]cosθ+r+a / 2, d2=(d+ra / (2tanθ)sinθ;

[0075] When 315°<θ<360°, d1=[d+ra / (2cosθ)]cosθ+r+a / 2, d2=(d+ra / (2cosθ)sinθ;

[0076] d1 and d2 refer to the horizontal and vertical copy distances respectively.

[0077] Furthermore, it should be noted that regardless of whether the detection component is circular or square, and the auxiliary detection component is a different square or circular shape, the above-mentioned conversion method and formula for the replication distance remain the same. Therefore, it is only necessary to determine whether the components have the same cross-section; there is no need to determine the relationship between the detection and auxiliary detection components based on their cross-sectional shapes.

[0078] In the present invention, when the cross-sectional shape of the detection component is circular, the development process is as follows:

[0079] 1) Create a new class and add relevant references, and use the IExternalEventHandler method to implement the interface.

[0080] 2) Set global variables for the IDs of the detection component and auxiliary detection component, the radius of the circular cross section, the number of copies of the detection component (n) determined by the spacing, and the relative angle between the two components. Also set corresponding local variables.

[0081] 3) Assign the ID value of the detected element to the initial ID value, and use the filter and collector to filter and collect the detected components.

[0082] 4) Create a List list, use the foreach method to parse the collector, and add the component elements to the created List list.

[0083] 5) Create and start a transaction, use the Sin and Cos methods to convert the angle value into a trigonometric function value, and assign it to the local variable of the component angle.

[0084] 6) Set the copy distance. The schematic diagram of circular section interval collision detection is shown in the figure.

[0085] According to the geometric relationship shown in the figure, when the value of n is given, a local distance variable is created for the copy distance in the positive direction of the plane where the section is located, and the copy distance in the positive direction of the detection component is obtained. The details are as follows:

[0086] vardistance1=(n*2*banjing)*cosjiaodu;

[0087] vardistance2=(n*2*banjing)*sinjiaodu;

[0088] 7) Copy the component. Create a list and, after determining the component's specific direction, enter distance1 and distance2 into the correct overload position in the CopyElement method to copy the component. The component's copy direction here is similar to soft collision detection. The positive and negative values ​​of the trigonometric function caused by the different angles can be accurately matched to the copy direction.

[0089] 8) Output of results. In the output results list, an if statement is used to determine whether the ID of the component element in the list matches the ID of the auxiliary detection component. If the IDs are different, the results are output; otherwise, no results are output, indicating that there are no unreasonable components. The TaskDialog method is still used to output the IDs of unreasonable components in the middle area to help designers identify their specific information.

[0090] 9) Delete the copied components for testing and close the transaction. Generate a .dll file and load it into Revit to run it.

[0091] Preferably, when the cross-section of the detection component is circular, the development process is as follows: When the cross-section of the detection component is square, the function development steps are similar to the above steps. The difference is that since the copied component needs to be tangent to the previous and next copied components, the copy distance of the square cross-section needs to be adjusted accordingly according to the angle. The side length of the square is d, and the angle between the two components is θ. The details are as follows:

[0092] When 0°<θ<45°,

[0093] d1=d

[0094] d2=dtanθ

[0095] When θ=45°,

[0096] d1=d

[0097] d2=d

[0098] When 45°<θ<90°,

[0099] d1=d / tanθ

[0100] d2=d

[0101] The specific schematic diagram is shown in the figure.

[0102] When the angle is 90°<θ<360°, the formula and schematic diagram are similar to those above and are not described in detail.

[0103] After adjusting the copy distance, develop the spacing collision function for square sections, similar to the steps for circular sections. In the variable settings, change the radius of the circular section to the side length of the square section. Furthermore, when setting the copy distance, use an if statement to check the angle, so that different angles correspond to different copy distances. Finally, run the program to create a .dll file. Load it into Revit and run it to obtain the spacing collision results between components.

[0104] After completing the optimization and adjustment function of the collision component, we developed a corresponding UI operation interface to aggregate various optimization functions and centrally place the parameter input function required for optimization, thus realizing unified operation of different types of component optimization on one operation interface. The main steps are as follows:

[0105] (1) Set the global variables of component ID, optimized width, and optimized height in the optimization program. And set the Label and TextBox controls respectively.

[0106] (2) The design inputs the ID of the component that needs to be avoided. When performing manual optimization, the designer manually selects the specific component, but collision point optimization and parameter optimization are different. Since it can only obtain all components of the component type in the subway station BIM model after filtering, and all components are optimized, but in actual projects, the same type of components have different optimization directions and optimized widths and heights. Therefore, it is necessary to develop an optimization method for a specific single component so that it can be avoided and adjusted through different optimization directions, heights, and widths.

[0107] (3) Set up Label controls for different optimization directions, develop different optimization directions separately, set up different Button controls, make them correspond to the Label controls one by one, and link them with the optimization program. The designer determines the appropriate optimization direction of the component based on the actual project situation and the surrounding environment of the component, and enters the parameters in the parameter input box corresponding to the optimization direction for optimization.

[0108] Based on this development approach, optimized adjustment interfaces were developed for different disciplines within the subway station BIM model, such as duct avoidance for pipes and hose avoidance for conduits. This allows designers to select different optimized operation interfaces based on the discipline of the collision component. Furthermore, designers can select different operation interfaces based on specific testing requirements, thus meeting the need for quick and accurate collision avoidance adjustments.

[0109] Since the detection scenarios of soft collision and interval collision in actual engineering are similar, they are often used together, and the methods of development and use are also similar. The detection conditions that designers need to input during detection are also similar. Therefore, this patent will merge the operation interfaces of soft collision and interval collision into one interface, and use WPF application to develop them in a unified way. Although both soft collision and interval collision use the replication method for collision detection, the factors actually considered by the two are different. Soft collision mainly considers the actual shape of the structure, the relative angle between the two detection components, and the direction of the detection structure, while interval collision has higher requirements for the range of the detection area. It is necessary to detect all ranges within the detection area between the two components. It is not possible to perform a single copy of the detection component. The cross-section of the component and the spacing between the components must be considered, and the maximum number N of copies of the component that can be made must be determined and displayed based on the spacing in the area that needs to be detected. Therefore, the difficulty in integrating the two lies mainly in the differences in some global variables. This technical solution mainly targets the global variables required for the two collision forms. It sets the detection component ID, the auxiliary detection component ID, the allowable spacing between detection components, the relative angle between the two components, the radius of the circular section, the side length of the square section, and the Label and TextBox controls for the input box of the "interval multiple" n value. The two controls are matched in the interface. For the function of displaying the maximum number of copies N, the TryParse method is mainly used to pass in the spacing and the radius of the circular section or the side length of the square section, divide them and take the quotient, and then round the result N for output. The above method makes the two detection methods compatible, thus realizing the integration of the operation interface.

[0110] Researching the implementation method of soft collision is the key to the development of the soft collision function. Since soft collision itself detects whether the distance between two components meets the requirements, in reality, there is no spatial intersection between the two components. Therefore, simply using the primitive intersection filter cannot produce a collision result, and the output of the result cannot be achieved. Therefore, how to detect the intersection of primitives when there is a distance between the two components is the key to implementing soft collision detection in this patent. The method adopted is to copy the components at a specified distance in the direction of soft collision detection. The copy function eliminates the distance between the component to be soft-collision-checked and the auxiliary collision detection component, thereby converting the soft collision detection into a hard collision detection. The primitive intersection filter is then used to detect whether the two components intersect. That is, when the copy distance matches the specified distance, if the components produce a hard collision, the soft collision detection fails, otherwise it passes. This method can not only meet the detection requirements of the specified distance between the two components, but also output the results of whether the two components collide or not.

[0111] Since the detection scenarios of soft collision and interval collision in actual engineering are similar, they are often used together, and the methods of development and use are also similar. The detection conditions that designers need to input during detection are also similar. Therefore, this patent will merge the operation interfaces of soft collision and interval collision into one interface, and use WPF application to develop them in a unified way. Although both soft collision and interval collision use the replication method for collision detection, the factors actually considered by the two are different. Soft collision mainly considers the actual shape of the structure, the relative angle between the two detection components, and the direction of the detection structure, while interval collision has higher requirements for the range of the detection area. It is necessary to detect all ranges within the detection area between the two components. It is not possible to perform a single copy of the detection component. The cross-section of the component and the spacing between the components must be considered, and the maximum number N of copies of the component that can be made must be determined and displayed based on the spacing in the area that needs to be detected. Therefore, the difficulty in integrating the two lies mainly in the differences in some global variables. This technical solution mainly targets the global variables required for the two collision forms. It sets the detection component ID, the auxiliary detection component ID, the allowable spacing between detection components, the relative angle between the two components, the radius of the circular section, the side length of the square section, and the Label and TextBox controls for the input box of the "interval multiple" n value. The two controls are matched in the interface. For the function of displaying the maximum number of copies N, the TryParse method is mainly used to pass in the spacing and the radius of the circular section or the side length of the square section, divide them and take the quotient, and then round the result N for output. The above method makes the two detection methods compatible, thus realizing the integration of the operation interface.

[0112] After completing the optimization and adjustment function of the collision component, we developed a corresponding UI operation interface to aggregate various optimization functions and centrally place the parameter input function required for optimization, thus realizing unified operation of different types of component optimization on one operation interface. The main steps are as follows:

[0113] (1) Set the global variables of component ID, optimized width, and optimized height in the optimization program. And set the Label and TextBox controls respectively.

[0114] (2) The design inputs the ID of the component that needs to be avoided. When performing manual optimization, the designer manually selects the specific component, but collision point optimization and parameter optimization are different. Since it can only obtain all components of the component type in the subway station BIM model after filtering, and all components are optimized, but in actual projects, the same type of components have different optimization directions and optimized widths and heights. Therefore, it is necessary to develop an optimization method for a specific single component so that it can be avoided and adjusted through different optimization directions, heights, and widths.

[0115] (3) Set up Label controls for different optimization directions, develop different optimization directions separately, set up different Button controls, make them correspond to the Label controls one by one, and link them with the optimization program. The designer determines the appropriate optimization direction of the component based on the actual project situation and the surrounding environment of the component, and enters the parameters in the parameter input box corresponding to the optimization direction for optimization.

[0116] Based on this development approach, optimized adjustment interfaces were developed for different disciplines within the subway station BIM model, such as duct avoidance for pipes and hose avoidance for conduits. This allows designers to select different optimized operation interfaces based on the discipline of the collision component. Furthermore, designers can select different operation interfaces based on specific testing requirements, thus meeting the need for quick and accurate collision avoidance adjustments.

[0117] Beneficial effects: The subway station space collision detection optimization method based on Revit secondary development technology of the present invention has the following advantages:

[0118] 1. This invention develops a hard collision detection function within and between different sections of a subway station, displaying detailed information such as the name and location of the colliding components. Furthermore, it develops a hard collision detection and display function for specific components. Furthermore, a user interface (UI) is created to make all functions operational.

[0119] 2. This invention develops a soft collision detection function for a single component in a subway station. Based on actual engineering practices, this function is developed separately for components in different situations in actual projects. This improves the accuracy of soft collision detection results, making the function more applicable to actual projects and enabling wider application.

[0120] 3. This invention proposes a new detection method and uses it to develop a spaced collision detection function for single components in subway stations. Similar to soft collision detection, this method considers the different conditions of components in actual engineering projects and develops a spaced collision detection function for components in different situations, enabling better practical application. Furthermore, the soft collision and spaced collision functions are integrated into a unified operating interface for both functions, allowing relevant personnel to perform detection operations conveniently, quickly, and clearly.

[0121] 4. Based on the collision results detected by different methods, this invention has developed a function that can quickly and easily optimize and adjust the collision components in various ways at the collision site, meeting the demand for fast and accurate avoidance adjustment of collision components. This avoids repeated rework and improves efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0122] Figure 1 This is a flow chart of a detection method for three different collision types, namely hard collision, soft collision and interval collision, in a subway station according to the present invention.

[0123] Figure 2 This is the component family creation process in Example 1 of the present invention.

[0124] Figure 3 This is the overall design idea of ​​the family library in Example 1 of the present invention.

[0125] Figure 4 This is the subway station BIM model constructed using Revit in Example 2 of the present invention.

[0126] Figure 5 This is a structural diagram of a subway station project in Example 2 of the present invention.

[0127] Figure 6 This is the data extraction process for Excel and Revit secondary development in Example 2 of the present invention.

[0128] Figure 7 This is the subway station automatic modeling plug-in interface in Example 2 of the present invention.

[0129] Figure 8 This is the idea for developing the collision detection plug-in in Example 3 of the present invention.

[0130] Figure 9 This is the air duct hard collision detection operation interface in Example 3 of the present invention.

[0131] Figure 10 This is the display of the soft collision result in Example 3 of the present invention.

[0132] Figure 11 This is the soft collision and interval collision operation interface in Example 3 of the present invention.

[0133] Figure 12 This is a flow chart of the soft collision and interval collision operation interface detection in Example 3 of the present invention.

[0134] Figure 13 This is a comparison diagram before and after manual collision optimization in Example 4 of the present invention.

[0135] Figure 14 This is a comparison diagram before and after automatic optimization of the collision point in Example 4 of the present invention.

[0136] Figure 15 This is a comparison chart before and after optimization of the custom parameters in Example 4 of the present invention.

[0137] Figure 16This is the pipe avoidance air duct operation interface in Example 4 of the present invention. DETAILED DESCRIPTION

[0138] The present invention will be further described below with reference to the accompanying drawings.

[0139] like Figure 1 As shown, the present invention provides a subway station space collision detection optimization method based on Revit secondary development technology, comprising the following steps:

[0140] S1: Create component families and build a BIM model family library suitable for subway stations: Based on the current subway station structure, component characteristics, and the geometric and logical relationships of each component, select appropriate family templates, create each component family, and manage the component families by building a family library management system through secondary development of Revit. Classify and archive the Revit families according to component type;

[0141] S2: Parametric creation of subway station BIM model: Establish Excel program interfaces between CAD and Revit, import modeling information and created component families into Revit modeling software, and use Revit secondary development parametric modeling to complete the creation of subway station BIM model;

[0142] S3: Use the filtering method provided by the API to traverse all component elements, classify all elements, extract the elements that need to collide, and form a collision element set. The specific steps are as follows:

[0143] S31: Build the development environment, reference related assemblies and implement the interface of the IExternalCommand method;

[0144] S32: Use UIDocument and Document to obtain interface interaction and actual content;

[0145] S33: Create a filter to filter all components of a certain profession that require collision detection. Determine the filtering method for the category and family type of the profession by checking the Built-in category and family type in Lookup. Use the ElementCategoryFilter method and the ElementClassFilter method to filter. Use the "and" filter LogicalAndFilter in the logical filter to connect the category filter and the family type filter.

[0146] S34: Create a collector: Use the FilteredElementCollector method to create an element collector, and connect the filter connected in S33 to the collector using the WherePasses method;

[0147] S35: Create a highlight prompt function: In the element collector that has been filtered out and meets the conditions, use the foreach method to traverse the collector and add the highlight function to all the elements in it;

[0148] S36: Use the foreach method to parse all the elements in the collector created above, and use the primitive intersection filter to create a collision element filter and collector;

[0149] S37: Define the auxiliary collision professional type for collision detection, use the WherePasses method to connect the collision element filter with the OfClass method, which is the definition method of the auxiliary collision element family type, so that the elements in the collector will only collide with the specific family type after typeof through the collision element filter and obtain the collision result. Connect the collision element collector with the collision element filter to receive the final collision result, and use the List method to output it in the form of a list.

[0150] S4: For each collision point in the collision element set, determine the collision type, which includes hard collision, soft collision, and interval collision;

[0151] S5: Determine the optimization start and end points;

[0152] S6: Based on the collision point, the corresponding optimization program is called to perform adjustment and optimization, which includes the following steps:

[0153] S61) using locationCurve to obtain the location of the pipeline and the locations of the first and last endpoints of the pipeline;

[0154] S62) Obtain the pipeline endpoint closest to the optimization adjustment start and end points clicked by the designer on the pipeline, create a method using GetNearXYZ, and pass in three X, Y, and Z variables in order according to manual order, assuming they are variables 1, 2, and 3. In this method, use the if statement to make a judgment: if the distance from variable 2 to variable 1 is greater than the distance from variable 3 to variable 1, then return variable 3; otherwise, return variable 2;

[0155] S63) passing the GetNearXYZ method created in S62) into the original class, matching the starting point of the optimized adjustment on the pipeline and the two endpoints of the component with variables 1, 2, and 3, and matching the end point of the optimized adjustment on the pipeline and the two endpoints of the component with variables 1, 2, and 3;

[0156] S65) Project the point clicked by the designer on the pipe onto the center point of the component cross section, use the Project method to project the input point onto the given line, project the point on the pipe surface onto the center line of the component, and finally obtain the projected point;

[0157] S66) Using a List list to receive Lines, adjusting the number of pipes that make up the optimized pipeline, i.e., the number of copies of Lines that need to be made, and creating a new pipeline based on the line segment, using the GenerateLines method, passing in the X, Y, and Z values ​​of the two endpoints of the pipeline, the X, Y, and Z values ​​of the optimized start and end points, and the offset distance, setting a variable to create a line between the optimized start and end points using the CreateBound method, and replacing the variable with locationCurve.Curve, creating a new Line collection in the list, passing the optimized start and end points into the collection, and creating a Line that avoids the pipeline;

[0158] S67) Set the avoidance distance, add the coordinates of the optimized start and end points to the offset coordinates set by offset, and obtain the coordinates of the pipeline after avoidance. Then, create a Line from the optimized start and end points to the pipeline position after avoidance, and a Line between the two avoidance points using the same method. Finally, return the values ​​of the Lines in (S66) and (S67);

[0159] S68) Open a transaction outside the List list and name it. Use the foreach method in the transaction to loop through the Line created in (S66), obtain the pipeline ID, force it to become a Pipe and create a pipeline. Finally, close the transaction and run it to achieve automatic avoidance of the pipeline.

[0160] S7: Modify the engineering design based on the collision check results to obtain the final design plan.

[0161] In this invention, component families are created, the functions of Revit software are expanded, and a BIM model family library suitable for subway stations is built. Based on the current subway station structure, component characteristics, and the geometric and logical relationships of each component, appropriate family templates are selected to create each component family. Furthermore, through secondary development of Revit and the establishment of a family library management system, component families are managed. A large number of Revit families are classified and archived according to component type, making it convenient to quickly and accurately load component families and improve modeling efficiency.

[0162] In the present invention, a BIM model of a subway station is created parametrically: Excel program interfaces are established between CAD and Revit respectively, and the Excel table is used as a bridge to import the modeling information and the created component family into the Revit modeling software, and the parametric modeling is developed by secondary development of Revit to complete the creation of the BIM model of the subway station.

[0163] In the present invention, hard collision, soft collision and interval collision functions are realized. On the basis of establishing the existing subway station BIM model, all component elements are traversed according to the filtering method provided by the API, and all elements are classified, the elements that need to collide are extracted and hard collision detection is performed, and the input of the tolerance allowable range value is adjusted according to specific rules and corresponding parameter settings to achieve the detection of soft collision and interval collision. Create a WPF interface, and for the hard collision of components, only one click is needed to generate the required results, and the results are summarized and organized. For soft collision and interval collision, it is necessary to input relevant parameters in the WPF window interface, detect components that collide with components within the corresponding distance, and output and organize the results.

[0164] This invention automatically adjusts and optimizes collision point results. Based on the collision point, precise avoidance optimization filtering conditions are set. Based on the avoidance priority rules, the automatic avoidance principle and the programming logic of three-dimensional avoidance direction and connection length are studied. Avoidance functionality is developed to implement various automatic collision point adjustment and connection optimization functions. A user interaction UI is created, and the relevant optimization avoidance parameter window is set to implement automatic component avoidance optimization.

[0165] In Example 1, it is important to note that the system families that come with Revit cannot fully meet the needs of all the types of components required for the actual engineering 3D model. The existing Revit family library cannot meet the modeling requirements of the subway station field. Therefore, it is necessary to use loadable families to create a family library of components related to the subway station engineering field. The main process ideas are as follows: Figure 2 shown.

[0166] This example will create a component family suitable for a 3D subway station BIM model, broadening the Revit family styles. The following uses a center column as an example to describe the process for creating a loadable family.

[0167] (1) Select a matching family template.

[0168] (2) Determine the placement origin and reference plane of the family components.

[0169] (3) Draw the center column of the special cross-section required for the subway station. After drawing the dimensions on a two-dimensional plane, use the stretching function to convert it into a three-dimensional column.

[0170] (4) Associated dimensioning information.

[0171] (5) Adding material and other parameter information.

[0172] (6) Load the project and relevant parameters, and test whether it can be created normally in the project. If it can be created normally, the construction of the column family in the subway station is completed.

[0173] After creating the component family of the subway station, you also need to create a corresponding subway station family library plug-in. The overall design idea is as follows Figure 3 shown.

[0174] In Example 2, the subway station BIM model constructed by Revit is as follows: Figure 4 shown.

[0175] According to the subway station component family established in Example 1 and the relevant BIM standards, combined with the actual project, the subway station modeling information analysis is carried out to ensure that the divided components correspond to the component family built in Example 1. Figure 5 shown.

[0176] Based on the characteristics of the subway station project itself and the characteristics of the component model, while taking into account the convenience and flexibility in the automatic modeling process, this invention will provide two different methods combined to construct the entire BIM model, as follows:

[0177] Method 1 is to conduct secondary development of Revit separately, write a program to obtain the component family in the interface, and create a corresponding WPF interface. For each component, a window for manually inputting coordinates of the component points is set to achieve accurate modeling of manually input coordinates for each component.

[0178] The second method is to identify and extract the modeling chart information in the two-dimensional CAD drawings through the joint secondary development of Revit and CAD, import the data into the Excel table, and then build a data transmission interface between Revit and Excel. Revit is developed so that it can read the data in the order of rows and columns in the table of imported data and realize automatic modeling.

[0179] The implementation of method one automatic modeling mainly includes: the implementation of filtering function, the implementation of automatic model creation, and the implementation of human-computer interaction interface function.

[0180] First, we implement the filtering function to obtain a specific family type. This paper uses a chain programming method to achieve the filtering effect. That is, after creating the filter, we use Lambda expressions to complete the filtering. The core code is as follows:

[0181] Elementele=collector.OfCategory(BuiltInCategory.OST_GenericModel).OfCla ss(typeof(FamilySymbol)).FirstOrDefault(x=>x.Name==“”);

[0182] In the Lambda expression, "OfCategory" and "OfClass" correspond to the category filter and family type filter respectively, and the name of the specific family type is entered after "Name".

[0183] Secondly, the implementation of automatic model creation. After obtaining a specific family type, code is written to create family instances to achieve automatic model creation. The specific steps are as follows:

[0184] (1) Conversion. The specific code is as follows: FamilySymbolfamilysymbol=eleasFamilySymbol;

[0185] (2) Get the elevation.

[0186] (3) Given coordinates.

[0187] (4) Create a transaction. The details are as follows:

[0188] Transactiontrans = newTransaction(doc."Create"); / / Create transaction trans.Start(); / / Start transaction / / Write transaction

[0189] trans.Commit(); / / Close transaction

[0190] (5) Create components.

[0191] After the creation function is written, you also need to create a WPF interface for human-computer interaction to achieve quick creation by inputting coordinates with one click. The specific steps are as follows:

[0192] (1) Build the WPF framework.

[0193] (2)Inherit the IExternalEventHandler interface.

[0194] (3) Under the Execute interface, write the code for creating components in steps 1 and 2, delete the return result code, and modify the code for obtaining documents as follows:

[0195] Documentdoc=app.ActiveUIDocument.Document;

[0196] (4) Attribute value transfer. 1) Add attributes in the component creation code, as follows: PublicdoubleXzuobiao{get;set}

[0197] PublicdoubleYzuobiao{get;set}PublicdoubleZzuobiao{get;set}

[0198] 2) Annotate the coordinate values ​​already written in the original creation code and associate the coordinate variables with the attributes. That is: doubleX = Xzuobiao / 0.3048; doubleY = Yzuobiao / 0.3048; doubleY = Yzuobiao / 0.3048;

[0199] (5) Connect the form to the component creation code. The specific steps are as follows:

[0200] 1) Register external events. CreateCreateCommand = null; ExternalEventCreateEvent = null;

[0201] 2) Initialization. Write below MainWindow():

[0202] CreateCommand = new Create(); CreateEvent = ExternalEvent.Create(CreateCommand); 3) Pass attribute values. Write the following code below the corresponding Button trigger code:

[0203] CreatCommandXzuobiao=Convert.ToDouble(this.textBox1.Text); CreatCommandYzuobiao=Convert.ToDouble(this.textBox2.Text); CreatCommandZzuobiao=Convert.ToDouble(this.textBox3.Text);

[0204] CreatEvent.Raise();

[0205] Finally, after completing the relevant code for the components manually created in Method 1 and placing the corresponding operation controls on a WPF interface, it can be generated and loaded into Revit for execution, so that the required subway station components can be created with one click by manually inputting coordinates.

[0206] The second method of automatic modeling implementation includes the automatic generation of CAD data required for subway station modeling and the writing of Excel data application modeling code.

[0207] First, in order to convert the plane data in the CAD chart into three-dimensional data, the CAD secondary development data extraction process is carried out. The main steps are as follows:

[0208] (1) Programmatically set up a filtering method in Visual Studio 2019 to filter out unnecessary data in the CAD drawing based on the polyline information provided by the API, and only obtain the polylines.

[0209] (2) Use the Foreach method and the If method, and set the judgment conditions and the filtering and extraction method to determine whether the difference between the maximum and minimum points of the polyline meets the requirements. If not, filter the polyline; if it meets the requirements, extract the polyline.

[0210] (3) Identify the bounding box where the polyline is located according to the rules and obtain the data therein.

[0211] (4) Extract data and establish software interaction to import data from CAD into Excel tables.

[0212] After extracting the data from CAD into Excel, you need to combine Excel with Revit for secondary development so that Revit can extract the table data. At the same time, obtain the components to be created through step 1 of method 1, and combine the data and model for modeling. Figure 6 shown.

[0213] Use NPOI components to implement program read and write operations on Excel tables. After creating a solution and project in Visual Studio 2019, load the NPOI component into the project and write code in the same project to read Excel data. The specific steps are as follows:

[0214] (1) Open the file stream and read the table.

[0215] (2) Write xlsx to workbook. Workbook = newXSSFWorkbook(Table);

[0216] (3) Read the sheet.

[0217] ISheetsheet=RWorkbook.GetSheetAt(0);

[0218] (4) Set the number of rows to be selected in the Excel table. If the number of rows read exceeds this number, the program will stop running.

[0219] (5) Use a For loop to get the sheet data, where row represents the row and cell represents the column. The examples are as follows: doublex_0 = Convert.ToDouble(sheet.GetRow(i).GetCell(1).ToString()) / 0.3048; doublex_0 = -Convert.ToDouble(sheet.GetRow(i).GetCell(2).ToString()) / 0.3048; doublex_1 = Convert.ToDouble(sheet.GetRow(i+1).GetCell(1).ToString()) / 0.3048; doublex_1 = -Convert.ToDouble(sheet.GetRow(i+1).GetCell(2).ToString()) / 0.3048;

[0220] Finally, add the control that realizes the Excel data application modeling function to the WPF interface created in step 3 of method 1, and the subway station BIM model automatic modeling plug-in is as follows: Figure 7 shown.

[0221] In Example 3, after determining the component classification of the BIM model, Revit secondary development technology is used to perform secondary development on Revit and its model to implement the collision detection function. Figure 8 shown.

[0222] The specific process of hard collision detection between professionals is as follows:

[0223] (1) Build the development environment, reference the relevant assemblies and implement the interface of the IExternalCommand method.

[0224] (2) Use UIDocument and Document to obtain the doc of interface interaction and actual content.

[0225] (3) Create a filter to filter all components of a certain profession that require collision detection.

[0226] (4) Create a collector.

[0227] (5) Create a highlight prompt function. The specific code is as follows:

[0228]

[0229] (6) Use the foreach method to parse all the elements in the collector created above to ensure that the subsequent method steps can cover every element in the collector.

[0230] (7) Use the element intersection filter to create a collision element filter and collector. According to the characteristics of the model, the ElementIntersectsElementFilter() method is selected to create a collision element filter and collector in the collector created in (4) and instantiate them using the new method respectively.

[0231] (8) Define auxiliary collision professional types for collision detection.

[0232] (9) Display of collision results. The output result code is as follows:

[0233] TaskDialog.Show("Hint","The number of building structures that collide with xx is "+i);

[0234] When displaying the names of the components that support the collision results, you can directly use the foreach method to traverse the list created in (8) and directly output the names of the elements in the list. The output code is as follows:

[0235] TaskDialog.Show("View auxiliary collision results",f.Name);

[0236] After performing hard collision detection between disciplines, we developed a function for collision detection within the same discipline. This method is similar to hard collision detection between disciplines. When defining the discipline family type for auxiliary collisions, define the family type as the same as the component for collision detection. This allows collision detection within the same discipline.

[0237] Further develop the function that displays information about the components that have collided after collision detection. The code development process is similar to that of the hard collision detection function. Filters and collectors are used to filter and collect components that contribute to the collision. A primitive intersection filter is then used to perform a collision check against the components being collided with. The results are converted into a List for output. The foreach method is then used to traverse the list and select the components being collided with, creating a highlighting function. Taking the air duct as an example, the specific code is as follows:

[0238] foreach(varfinlist)

[0239] {

[0240] TaskDialog.Show("Show unreasonable duct ID",f.UniqedId);

[0241] }

[0242] Finally, load the .dll file into Revit and run it to get the specific information of the collision component.

[0243] Develop the function of hard collision detection for a specific single component. The specific development process is as follows:

[0244] (1) Create specialized filters and collectors for collision detection and connect them.

[0245] (2) Create a List list and distinguish the list name from the collector name.

[0246] (3) Use the foreach method to parse the collector, and use the if language to judge in the collector. If the UniqeId of the component element in the collector is equal to the UniqeId of the single component that needs to be hard-collision detected, it will be selected and added to the list created in (2). The implementation code is as follows:

[0247] if(item.UniqueId=="")

[0248] {

[0249] elementList.Add(item);

[0250] }

[0251] (4)Highlight.

[0252] (5) Use the foreach method to parse the List list, and use the primitive intersection filter and auxiliary collision professional to perform hard collision detection.

[0253] (6) Create another list within this List list, add the collision results to the new list, and traverse the new list to output the results.

[0254] Based on the collision detection logic, different hard collision detection interfaces are created for different majors, and the detection functions required by the same major are placed in the same interface. The interface is developed using WPF application. Create a WPF project in Visual Studio and add controls such as Label, TextBox, and Button to the interface to associate them with different functions. The steps are as follows:

[0255] (1) Create new classes in the WPF project and define distinguishable names for each class. Use the IExternalEventHandler method to implement the interface.

[0256] (2) Write a program in each class to implement the corresponding functions.

[0257] (3) By registering external events, initializing, and passing property values, different classes are linked to corresponding Button controls, and Button controls are matched with Labels and TextBoxes. The text in the Label control prompts the designer of the detection function here.

[0258] (4) Place the controls reasonably on the interface, generate a .dll file, load it into Revit and check the running effect. Taking the duct professional as an example, the operation interface effect of the hard collision detection is as follows Figure 9 shown.

[0259] Similar to air ducts, all functions of hard collision detection are developed for each discipline involved in the subway station, and different detection interfaces are created separately. After being loaded into Revit and running successfully, they can be classified, packaged and merged to form a complete hard collision detection function for the subway station BIM model.

[0260] Similar to hard collision detection, the final detection method for soft collision is to detect the intersection of two components in the subway station BIM model and output the detection results.

[0261] First, consider the cross-sectional shape of the component. Since the soft collision detection developed by the present invention is mainly aimed at pipeline integration, and in actual engineering, the cross-sectional shapes of pipelines are mainly circular and square, the present invention will develop functions for pipeline integration with circular and square cross-sectional shapes.

[0262] (1) When the cross-sections of the two components to be tested for soft collision are the same, the function development steps are as follows:

[0263] 1) Create a new project in Visual Studio and add a new class, reference the relevant assembly, directly use the IExternalEventHandler method to implement the interface, and obtain the documentation of the interface interaction and actual content.

[0264] 2) Set global variables.

[0265] 3) Set four local variables that match the global variables for use in variables in this class file.

[0266] 4) Use the new method to create an instantiated ElementId and add an arbitrary initial element ID to it.

[0267] 5) Use filters and collectors to filter and collect the professions to which the components that require soft collision detection belong, so that the collector can collect elements of all components of the profession.

[0268] 6) Create a List list, use the foreach method to parse the collector, and use string.Compare in it

[0269] Method and if language determine its component ID, and collect the component ID that needs to be detected in the collector, that is, step 2).

[0270] The values ​​of the global variables and local variables set in step 3) are assigned to the initial ID values ​​set in step 4), and the component elements are added to the created List list.

[0271] 7) Start a transaction and set the name of the transaction.

[0272] 8) Set the copy distance.

[0273] Create a local distance variable for the copy distance in the positive direction of the section plane, and use trigonometric functions to convert the spacing value to obtain the correct copy distance in the positive direction. The specific copy code is as follows:

[0274] vardistance1=jianju*cosjiaodu;vardistance2=jianju*sinjiaodu;9)Copy the component.

[0275] 10) Detect collisions and output the results.

[0276] 11) Output the result of the component that produces a soft collision with the component with the given ID.

[0277] 12) Delete the copied elements.

[0278] Finally, run the program and load it into the software to perform soft collision detection on components with the same cross-section.

[0279] (2) When the cross-sections of the two components to be tested for soft collision are one circular and the other square, the specified spacing between the two components cannot be directly equated with the replication distance. The replication distance needs to be adjusted through geometric relationships. In addition, when the actual distance is slightly greater than the spacing, the horizontal replication distance of the component remains unchanged, so that the position of the component after vector synthesis will not intersect with the auxiliary detection component and cause a collision; on the contrary, when the actual distance is less than the spacing, the horizontal replication distance of the component remains unchanged, so that the replicated component will intersect with the auxiliary detection component and cause a collision.

[0280] As the relative angle θ between the auxiliary collision component and the detection component changes, the method for calculating the distance from the intersection of the line connecting the two components and the outer surface of the square cross section to the center of the square will also change. In addition, the positive and negative changes in the trigonometric function caused by the change in θ will also affect the direction of the copy, so it is necessary to distinguish them. The details are as follows:

[0281] When 0°<θ<45°,

[0282] d1=[d+r+a / (2cosθ)]cosθ-ra / 2d2=(d+r+a / (2cosθ)sinθ

[0283] When 45°<θ<90°,

[0284] d1=[d+r+a / (2sinθ)]cosθ-ra / 2d2=(d+r+a / (2sinθ)sinθ

[0285] When 90°<θ<135°,

[0286] d1=[d+ra / (2tanθ)]cosθ+r+a / 2d2=(d+ra / (2tanθ)sinθ

[0287] When 135°<θ<180°,

[0288] d1=[d+ra / (2cosθ)]cosθ+r+a / 2d2=(d+ra / (2cosθ)sinθ

[0289] When 180° < θ < 360°, the formula is similar to the above and will not be repeated here. Furthermore, it should be noted that regardless of whether the inspection component is circular or square, and the auxiliary inspection component is a different square or circular shape, the above-mentioned copy distance conversion method and formula remain the same. After adjusting the copy distance, follow the same steps as for the two component cross sections, creating a new program to complete development. Finally, compile the program as a .dll file, load it into Revit, and run it.

[0290] (3) Take the air duct as an example, and perform a soft collision test between it and the top plate. Enter the specified spacing, the angle between the two, and the IDs of the two. The result will be displayed as the name of the auxiliary detection component, which means that the spacing between the two does not meet the requirements and a soft collision occurs. Figure 10 shown.

[0291] Development of interval collision detection. Different .dll files need to be developed for different component cross-sectional shapes, as follows:

[0292] (1) When the cross-sectional shape of the test component is circular, the development process is as follows:

[0293] 1) Create a new class and add relevant references, and use the IExternalEventHandler method to implement the interface.

[0294] 2) Set global variables and their matching local variables

[0295] 3) Assign the ID value of the detected element to the initial ID value, and use the filter and collector to filter and collect the detected components.

[0296] 4) Create a List list, use the foreach method to parse the collector, and add the component elements to the created List list.

[0297] 5) Create and start a transaction, use the Sin and Cos methods to convert the angle value into a trigonometric function value, and assign it to the local variable of the component angle.

[0298] 6) Set the copy distance.

[0299] According to the geometric relationship shown in the figure, when the value of n is given, a local distance variable is created for the copy distance in the positive direction of the plane where the cross section is located, and the copy distance in the positive direction of the detection component is obtained. The details are as follows:

[0300] vardistance1=(n*2*banjing)*cosjiaodu;vardistance2=(n*2*banjing)*sinjiaodu;7) Copy the component.

[0301] 8) Output of results.

[0302] 9) Delete the copied components for testing and close the transaction. Generate a .dll file and load it into Revit to run it.

[0303] (2) When the cross-section of the detection component is a square, the steps for function development are similar to the above steps. The difference is that the square cross-section requires the copy distance to be adjusted accordingly according to the angle. The side length of the square is d, and the angle between the two components is θ. The details are as follows:

[0304] When 0°<θ<45°, d1=d

[0305] d2=dtanθ

[0306] When θ=45°, d1=d

[0307] d2=d

[0308] When 45°<θ<90°, d1=d / tanθ

[0309] d2=d

[0310] When the angle is 90°<θ<360°, the formula is similar to the above and will not be repeated.

[0311] After adjusting the copy distance, the interval collision function of the square cross section is developed in a similar way to the steps for the two component cross sections.

[0312] Combine the soft collision and interval collision operation interfaces into one interface and use WPF application to develop them uniformly. The specific steps are as follows:

[0313] (1) For the global variables required by the two collision forms, set Label and TextBox controls respectively, and match the two controls in the interface.

[0314] (2) Set up soft collision detection, interval collision detection, and the button that displays the maximum number of copies N

[0315] Controls and match them with the controls in (1) on the interface.

[0316] (3) By registering external events, initializing, and passing properties, different classes are programmatically linked to their corresponding Button controls. For the function that displays the maximum number of copies, N, a program is written directly within the property passing method: Use the TryParse method to pass in the spacing and the radius of the circular section or the side length of the square section, divide them, and then round the result, N, for output. Note that for square sections, the spacing must be converted to distance based on the angle between the two components.

[0317] Taking the detection between air ducts and pipes as an example, after completing the development steps, the operation interface is as follows Figure 11 As shown. Based on this interface, the detection of soft collision and interval collision between two components can be realized. The specific operation process is as follows Figure 12 shown.

[0318] Following this development approach, each discipline within the subway station BIM model will develop its own soft collision and interval collision detection interfaces, tailored to its specific discipline and those of other disciplines. For example, for air ducts, separate detection interfaces will be developed for duct-to-pipe, duct-to-structure, and duct-to-duct. Based on this, designers can select different detection interfaces based on specific testing requirements, ultimately establishing comprehensive soft collision and interval collision detection capabilities for the subway station BIM model.

[0319] In Example 4, it should be noted that the main method of adjustment and optimization is to make the components avoid each other, and to optimize the collision point by adjusting the direction and relative position of the components to avoid collision between the two components, thereby achieving optimized adjustment at the collision point.

[0320] In combination with engineering practice and operational feasibility, this embodiment will develop optimization functions from the following three different aspects, as follows:

[0321] (1) First, a function is developed that allows one to adjust the starting and ending points of the optimized position of components on the two-dimensional and three-dimensional planes of the subway station BIM model with one click.

[0322] (2) Secondly, develop a function for one-click optimization and adjustment of the collision point, automatically capture the collision point, and bend the component to avoid the collision point.

[0323] (3) Finally, develop a function to automatically adjust the bending of components that collide with each other by customizing the optimized parameters.

[0324] (4) Specific directions of component optimization and adjustment are developed separately. When the optimization in a certain direction does not meet the design requirements, the components can be adjusted in different directions to meet the conditions.

[0325] First, we developed a function that allows us to adjust the starting and ending points of components to optimize their positions with a single click. Taking the pipe components in the subway station model as an example, the specific steps are as follows:

[0326] (1) Get the interface interaction and actual content. And get the selection of the interface.

[0327] (2) Create a new method using ISelectionFilter and implement the interface. The code is as follows:

[0328] if(elemisPipe)returntrue;

[0329] else

[0330] returnfalse;

[0331] (3) Use the PickObject method to obtain the user's click point on the pipeline component, which is the starting and ending points of the component's optimized position. Select the PointOnElement overload here. Instantiate the filter in (2) using the new method and pass it into the PickObject method. Finally, use GetElement to obtain the pipeline object.

[0332] (4) Interrupt the pipeline at the optimization start and end points selected by the designer. The specific method is as follows: 1) Use locationCurve to obtain the location of the pipeline and the locations of the first and last endpoints of the pipeline. 2) Obtain the pipeline endpoint closest to the optimization adjustment start and end points clicked by the designer on the pipeline.

[0333] 3) Pass the GetNearXYZ method created in 2) into the original class. Note that you need to flexibly determine the order in which the overloads are placed in the method based on the different sorting in 2).

[0334] (5) Project the point clicked by the designer on the pipe to the center point of the component cross section. The specific code is as follows:

[0335] varPosTouYing=locationCurve.Curve.Project(NearXYZ).XYZPoint;

[0336] (6) Use the List list to receive the Line, adjust the number of pipelines that make up the optimized pipeline, that is, the number of copies of the Line that need to be copied, and create a new pipeline based on the line segment.

[0337] (7) Set the avoidance distance. Add the coordinates of the optimized start and end points to the offset coordinates set by offset to obtain the coordinates of the pipeline after avoidance. Use the same method to create a line from the optimized start and end points to the pipeline position after avoidance, as well as a line between the two avoidance points. Finally, return the values ​​of the lines in (6) and (7).

[0338] (8) Open a transaction outside the List list and name it, and use the foreach method to loop through the transaction

[0339] In (6), create a Line, obtain the pipeline ID, force it to become a Pipe, and create the pipeline. Finally, close the transaction. This will automatically avoid the pipeline.

[0340] (9) Create pipe elbows at avoidance points to connect pipes.

[0341] Load and run the .dll file, and compare the collision pipeline before and after optimization. Figure 13 shown.

[0342] After implementing the manual adjustment and optimization function at the component collision point, develop the function of automatic identification and optimization of the collision point.

[0343] Taking the automatic optimization of collisions between ducts and pipes as an example, the main development process is as follows:

[0344] 1) Create a new class and add relevant references to build a development environment;

[0345] 2) Use the filter to obtain all the ducts, and use the primitive intersection filter to define the type of collision result with the duct as pipe;

[0346] 3) Obtain collision point;

[0347] 4) Finally, write the optimization code developed in the first part of the function, delete the manual click function, and convert the manually clicked points into the collision points on the outer surface of the component obtained in 3), so that the function of automatic optimization and adjustment at the collision points on the outer surface of the component can be realized. The effect is as follows Figure 14 shown.

[0348] After achieving automatic component optimization, in order to meet the function described in (3) of this example function development, it is necessary to variable the parameters required for optimization. The main steps are as follows:

[0349] (1) Set the global variables of optimized width and optimized height in the optimization program.

[0350] (2) Delete the click function in the manual optimization program, use filters and collectors to filter and collect the components that need to be optimized, and use the foreach method to parse the collector and obtain the components that need to be optimized.

[0351] (3) Replace the avoidance distance offset with the global variable of optimized height. And obtain the collision point of the component and the distance between the collision points, and use the if method to make a judgment. After loading the program into the subway station BIM model and setting the optimized width and optimized height, the avoidance effect is as follows: Figure 15 shown.

[0352] After completing the optimization and adjustment function of the collision component, develop the corresponding UI operation interface, centralize various optimizations and the parameter input functions required for optimization, and realize the configuration on one operation interface. The main steps are as follows:

[0353] (1) Set the global variables of component ID, optimized width, and optimized height in the optimization program. And set the Label and TextBox controls respectively.

[0354] (2) Design input of the ID of the component that needs to be avoided.

[0355] (3) Set up Label controls for different optimization directions, develop different optimization directions separately, set up different Button controls, make them correspond to the Label controls one by one, and link them with the optimization program. The designer determines the appropriate optimization direction of the component based on the actual project situation and the surrounding environment of the component, and enters the parameters in the parameter input box corresponding to the optimization direction for optimization.

[0356] After running, load it into Revit. Taking the pipe avoidance duct as an example, the operation interface is as follows Figure 16As shown in the figure, based on this development method, we develop optimized adjustment interfaces for different disciplines within the subway station BIM model, such as avoiding ducts to avoid pipes, and hoses to avoid wires to avoid conduits. This allows designers to select different optimized operation interfaces based on the disciplines of the collision components, and finally package the programs together.

[0357] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A subway station space collision detection optimization method based on Revit secondary development technology, characterized in that: The following steps are involved: S1: Create component families and build a BIM model family library suitable for subway stations: Based on the current subway station structure, component characteristics, and the geometric and logical relationships of each component, select appropriate family templates, create each component family, and manage the component families by building a family library management system through secondary development of Revit. Classify and archive the Revit families according to component type; S2: Parametric creation of subway station BIM model: Establish Excel program interfaces between CAD and Revit, import modeling information and created component families into Revit modeling software, and use Revit secondary development parametric modeling to complete the creation of subway station BIM model; S3: Use the filtering method provided by the API to traverse all component elements, classify all elements, extract the elements that need to collide, and form a collision element set; S4: For each collision point in the collision element set, the collision type is determined. The collision types include hard collision, soft collision, and interval collision. The soft collision method is to copy the components at a specified interval in the soft collision detection direction. The copy function eliminates the distance between the component to be soft-collision-detected and the auxiliary collision detection component, thereby converting the soft collision detection into a hard collision detection. The primitive intersection filter is then used to detect whether the two components intersect. That is, when the copy distance matches the specified interval, if the components produce a hard collision, the soft collision detection fails, otherwise it passes. S5: Determine the optimization start and end points; S6: According to the collision point, call the corresponding optimization program to adjust and optimize; S7: Modify the engineering design based on the collision check results to obtain the final design plan.

2. The subway station space collision detection optimization method based on Revit secondary development technology according to claim 1 is characterized by: The specific steps of step S3 are: S31: Build the development environment, reference related assemblies and implement the interface of the IExternalCommand method; S32: Use UIDocument and Document to obtain interface interaction and actual content; S33: Create a filter to filter all components of a certain profession that require collision detection. Determine the filtering method for the category and family type of the profession by checking the Built-incategory and family type in Lookup. Use the ElementCategoryFilter method and the ElementClassFilter method to filter. Use the "and" filter LogicalAndFilter in the logical filter to connect the category filter and the family type filter. S34: Create a collector: Use the FilteredElementCollector method to create an element collector, and connect the filter connected in S33 to the collector using the WherePasses method; S35: Create a highlight prompt function: In the element collector that has been filtered out and meets the conditions, use the foreach method to traverse the collector and add the highlight function to all the elements in it; S36: Use the foreach method to parse all the elements in the collector created above, and use the primitive intersection filter to create a collision element filter and collector; S37: Define the auxiliary collision professional type for collision detection, use the WherePasses method to connect the collision element filter with the OfClass method, which is the definition method of the auxiliary collision element family type, so that the elements in the collector will only collide with the specific family type after typeof through the collision element filter and obtain the collision result. Connect the collision element collector with the collision element filter to receive the final collision result, and use the List method to output it in the form of a list.

3. The subway station space collision detection optimization method based on Revit secondary development technology according to claim 1 is characterized in that: The step S4 comprises the following steps: S41: Build the development environment, reference related assemblies and implement the interface of the IExternalCommand method; S42: Use UIDocument and Document to obtain interface interaction and actual content; S43: Create a filter to filter all components of a certain profession that require collision detection; S44: Create collector; S45: Create highlight prompt function; S46: Use the foreach method to parse all the elements in the collector created above; S47: Use the primitive intersection filter to create a collision element filter and collector. According to the characteristics of the model, select the ElementIntersectsElementFilter() method, create the collision element filter and collector again in the collector created in S44, and instantiate them respectively using the new method; S48: Define auxiliary collision professional types for collision detection; S49: Display of collision results.

4. The subway station space collision detection optimization method based on Revit secondary development technology according to claim 1 is characterized in that: The step S6 comprises the following steps: S61: Use locationCurve to obtain the location of the pipeline and the locations of the first and last endpoints of the pipeline; S62: Get the pipeline endpoint closest to the optimization adjustment start and end points clicked by the designer on the pipeline. Create a method using GetNearXYZ. In this method, three X, Y, and Z variables are passed in order according to the manual order. Assume that they are variables 1, 2, and 3. In this method, use the if language to make a judgment: if the distance from variable 2 to variable 1 is greater than the distance from variable 3 to variable 1, then return variable 3; otherwise, return variable 2. S63: The GetNearXYZ method created in S62 is passed to the original class, and the starting point of the optimization adjustment on the pipeline and the two endpoints of the component are matched with variables 1, 2, and 3. At the same time, the end point of the optimization adjustment on the pipeline and the two endpoints of the component are matched with variables 1, 2, and 3. S65: Project the point clicked by the designer on the pipe to the center point of the component cross section. Use the Project method to project the input point onto the given line, project the point on the pipe surface onto the center line of the component, and finally obtain the projected point. S66: Use the List list to receive the Line, adjust the number of pipes that make up the optimized pipeline, that is, the number of copies of the Line, and create a new pipeline based on the line segment. Use the GenerateLines method to pass in the X, Y, and Z values ​​of the two endpoints of the pipeline, the X, Y, and Z values ​​of the optimized start and end points, and the offset distance to avoid. Set the variable to use the CreateBound method to create a line between the two points of the optimized start and end points, and replace the variable with locationCurve.Curve. Create a new Line collection in the list, pass the optimized start and end points into the collection, and create a Line to avoid the pipeline. S67: Set the avoidance distance. Add the coordinates of the optimized start and end points to the offset coordinates set by offset to obtain the coordinates of the pipeline after avoidance. Use the same method to create a line from the optimized start and end points to the pipeline position after avoidance, as well as a line between the two avoidance points. Finally, return the line values ​​in S66 and S67. S68: Open a transaction outside the List list and name it. Use the foreach method in the transaction to loop through the Line created in S66, obtain the pipeline ID, force it to become a Pipe and create a pipeline. Finally, close the transaction and run it to achieve automatic avoidance of the pipeline.

Citation Information

Patent Citations

  • BIM electromechanical and structural collision checking method based on Revit

    CN111680412A

  • BIM-based subway vehicle base outdoor comprehensive pipeline collaborative design method and system

    CN115577421A