Method for calculating terminal cable in building based on shortest path algorithm

By applying the calculation method of the shortest path algorithm in buildings, the cable length from the terminal to the computer room is automatically calculated, solving the problem of low efficiency and inaccurate manual measurement in large buildings, achieving more efficient and accurate calculations.

CN120068326APending Publication Date: 2025-05-30CHINA RAILWAY DESIGN GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510017426.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-06
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In large buildings, when manually measuring the length of equipment cables from terminals to computer rooms, the workload is huge and not accurate enough, especially when the building scale is large, the layout is complex, and the number of terminals is large.

Method used

The calculation method based on the shortest path algorithm is adopted to automatically calculate the cable length from the terminal to the computer room by drawing the cable tray/channel path, inserting the tray node, adding edges and weights, inserting the terminal and calculating the shortest distance.

Benefits of technology

It realizes automatic calculation of the cable length from the terminal to the computer room in large buildings, improves computing efficiency and accuracy, and reduces the workload of manual measurement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120068326A_ABST
    Figure CN120068326A_ABST
Patent Text Reader

Abstract

The invention discloses a method for calculating a terminal cable in a building based on a shortest path algorithm. The method comprises the following steps: drawing a path of a cable bridge / channel; bridge nodes are inserted, and a graph model is established; inserting a terminal; calculating the shortest distance from the terminal to the bridge / channel; and calculating the cable length from the terminal to the machine room. According to the method, basic operations such as cable bridge / channel drawing, bridge node inserting, edge adding and terminal inserting are completed by utilizing an ActiveX interface provided by AutoCAD; the method comprises the following steps: establishing communication and interaction between Python and an AutoCAD application program by introducing a win32com. Client module and a pythoncom module, and calculating a shortest path from a node to a computer room by adopting a Dijkstra algorithm; and calculating the shortest distance from the terminal to the node, and finally generating the cable length from the terminal to the machine room.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of cable design, and particularly relates to a calculation method for terminal cables in a building based on the shortest path algorithm. Background Art

[0002] The equipment cables from the terminal to the machine room in a building are laid along cable trays / trunking. The traditional calculation method can only be carried out through manual measurement. When the building scale is large, the building layout is complex, and the number of terminals is large, the workload of manual measurement is extremely huge, and the measurement is not accurate enough. Summary of the Invention

[0003] The present invention is proposed to solve the problems existing in the prior art, and its purpose is to provide a calculation method for terminal cables in a building based on the shortest path algorithm, which automatically calculates the cable length from the terminal to the machine room laid along the cable tray / trunking.

[0004] The technical solution of the present invention is: a calculation method for terminal cables in a building based on the shortest path algorithm, including the following steps: A. Draw the path of the cable tray / trunking; B. Insert bridge nodes, add edges and weights, and establish a graph model; C. Insert terminals; D. Calculate the shortest distance from the terminal to the cable tray / trunking; E. Calculate the cable length from the terminal to the machine room.

[0005] Furthermore, for step A of drawing the path of the cable tray / trunking, the specific process is as follows: First, obtain the width Width of the cable tray / trunking; Then, draw a polyline plineObj1, and the polyline plineObj1 is the inner edge of the cable tray / trunking; Next, according to the width Width and the polyline plineObj1, obtain the polyline plineObj2 of the outer edge; Finally, obtain the closed polyline of the cable tray / trunking.

[0006] Furthermore, for step B of inserting bridge nodes, the specific process is as follows: First, select the insertion point coordinates at the starting point, ending point of the generated bridge, and the intersection of the cable tray / trunking; Then, use the GetPoint method to obtain the insertion point coordinate value InsertVERTEXCOR; Then, use the AddText method to add the node name with the node insertion point InsertVERTEXCOR as the reference point; Finally, add one "+" symbol before and after the node name as the frame header and frame footer, use "J" as the keyword, and the naming rule is "+J-x+", where x is an Arabic numeral.

[0007] Furthermore, in step B, insert bridge nodes, add edges and weights to establish a graph model, including adding graph vertices, edges and edge weighting. The specific process is as follows: First, search for nodes in the model file according to the keyword "J" and the identifier "+"; Then, after removing the keyword "J" and the identifier "+" from the inserted nodes, store the node names in the list VERTEX[]; Then, select two adjacent nodes to generate an edge and store it in the list EDGE[]; After that, calculate the distance between two adjacent nodes according to the insertion point coordinates of the two nodes, and store the distance value as the edge weight value in the list WEIGHT[]; Finally, the graph model data of graph vertices VERTEX[], edges EDGE[] and edge weighting WEIGHT[] is established.

[0008] Furthermore, the specific process of establishing the graph model in step B is as follows: First, create an undirected graph G; Then, add graph vertices according to the VERTEX[] list; Finally, add weighted edges according to the EDGE[] list and the WEIGHT[] list, and the graph model is established.

[0009] Furthermore, the specific process of inserting terminals in step C is as follows: First, represent the terminal with a block; Then, after inserting the terminal into the graph, determine the insertion point coordinates of the terminal according to the InsertionPoint attribute of the block; Finally, complete the insertion of all terminals in the graph.

[0010] Furthermore, in step D, calculate and select the cable tray / duct closest to the equipment terminal. The closest distance is the shortest distance from the insertion point of the equipment terminal to a certain node or the vertical distance from the insertion point of the equipment terminal to a certain edge.

[0011] Furthermore, the specific process of calculating and selecting the cable tray / duct closest to the equipment terminal in step D is as follows: First, calculate the distances from the insertion point coordinates of all nodes to the insertion point of the terminal, and record the shortest distance DISTANCE_V and the corresponding node VERTEX_END; Then, the vector method (vector cross product) is used to calculate the perpendicular distance from the block insertion point to all sides, determine whether the foot of the perpendicular falls on the side, record the shortest distance DISTANCE_E, record the side EDGE_T, and record two adjacent nodes VERTEX_1 and VERTEX_2; After that, take the minimum value of DISTANCE_V and DISTANCE_E as DISTANCE.

[0012] Furthermore, for DISTANCE_V, calculate the cable length, and the specific process is as follows: First, according to G, the starting point and the ending point, use the nx.dijkstra_path() method to generate the shortest path DISTANCE_G from the graph node VERTEX_END to the computer room, where the starting point is the computer room, VERTEX[0]; the ending point is VERTEX_END; Then, the shortest distance from the terminal to the communication is the sum of DISTANCE_G and DISTANCE_V.

[0013] The beneficial effects of the present invention are as follows: The present invention utilizes the ActiveX interface provided by AutoCAD to complete basic operations such as drawing cable trays / channels, inserting tray nodes, adding edges, and inserting terminals; by referencing the win32com.client module and the pythoncom module, establish the communication and interaction between Python and the AutoCAD application program, use the Dijkstra algorithm to calculate the shortest path from the node to the computer room; calculate the shortest distance from the terminal to the node, and finally generate the cable length from the terminal to the computer room. Brief Description of the Drawings

[0014] Figure 1 is the flowchart of the method of the present invention; Figure 2 is the schematic diagram of step A in the present invention; Figure 3 is the schematic diagram of step D in the present invention; Figure 4 is the schematic diagram of step D in the present invention; Figure 5 is the schematic diagram of layout D in the present invention. Detailed Embodiments

[0015] Hereinafter, the present invention will be described in detail with reference to the drawings and embodiments: As Figures 1 to 5 shown, a method for calculating the terminal cable in a building based on the shortest path algorithm includes the following steps: A. Draw the path of the cable tray / channel; B. Insert bridge node, add edges and weights, and establish a graph model; C. Insert terminals; D. Calculate the shortest distance from the terminal to the bridge / tray; E. Calculate the cable length from the terminal to the computer room.

[0016] Step A: Draw the path of the cable bridge / tray. The specific process is as follows: First, obtain the width Width of the bridge / tray; Then, draw a polyline plineObj1, where the polyline plineObj1 is the inner edge of the bridge / tray; Next, based on the width Width and the polyline plineObj1, obtain the outer-edge polyline plineObj2; Finally, obtain the closed polyline of the bridge / tray.

[0017] Step B: Insert bridge nodes. The specific process is as follows: First, select the insertion point coordinates at the starting point, ending point of the generated bridge, and the intersection points of the bridge / tray; Then, use the GetPoint method to obtain the insertion point coordinate value InsertVERTEXCOR; Then, use the AddText method to add the node name with the node insertion point InsertVERTEXCOR as the reference point; Finally, add 1 "+" symbol before and after the node name as the frame header and frame tail, and use "J" as the keyword. The naming rule is "+J-x+", where x is an Arabic numeral.

[0018] Step B: Insert bridge nodes, add edges and weights, and establish a graph model, including adding graph vertices, edges, and edge weights. The specific process is as follows: First, search for nodes in the model file according to the keyword "J" and the identifier "+"; Then, after removing the keyword "J" and the identifier "+" from the inserted nodes, store the node names in the list VERTEX[]; Then, select two adjacent nodes to generate an edge and store it in the list EDGE[]; Next, calculate the distance between two adjacent nodes based on the insertion point coordinates of the two nodes, and store the distance value as the edge weight in the list WEIGHT[]; Finally, the graph model data of the graph vertices VERTEX[], edges EDGE[], and edge weights WEIGHT[] is established.

[0019] Step B: Establish a graph model. The specific process is as follows: First, create an undirected graph G; Then, add graph vertices according to the VERTEX[] list; Finally, add weighted edges according to the EDGE[] list and the WEIGHT[] list, and the graph model is established.

[0020] In step C, insert terminals. The specific process is as follows: First, represent the terminal with a block; Then, after inserting the terminal into the graph, determine the insertion point coordinates of the terminal according to the InsertionPoint attribute of the block; Finally, complete the insertion of all terminals in the graph.

[0021] In step D, calculate and select the cable tray / duct closest to the device terminal. The shortest distance is the shortest distance from the insertion point of the device terminal to a certain node or the vertical distance from the insertion point of the device terminal to a certain edge.

[0022] In step D, calculate and select the cable tray / duct closest to the device terminal. The specific process is as follows: First, calculate the distances from the insertion point coordinates of all nodes to the insertion point of the terminal, and record the shortest distance DISTANCE_V and the corresponding node VERTEX_END; Then, use the vector method (vector cross product) to calculate the vertical distance from the block insertion point to all edges, determine whether the foot of the perpendicular falls on the edge, and record the shortest distance DISTANCE_E, record the edge EDGE_T, and record two adjacent nodes VERTEX_1 and VERTEX_2; Next, take the minimum value of DISTANCE_V and DISTANCE_E as DISTANCE.

[0023] Specifically, calculate the cable length for DISTANCE_V. The specific process is as follows: First, according to G, the starting point, and the ending point, use the nx.dijkstra_path() method to generate the shortest path DISTANCE_G from the graph node VERTEX_END to the computer room. Among them, the starting point is the computer room, VERTEX[0]; the ending point is VERTEX_END; Then, the shortest distance from the terminal to the communication is the sum of DISTANCE_G and DISTANCE_V.

[0024] Specifically, calculate the cable length for DISTANCE_E. The specific process is as follows: First, based on G, the starting point (computer room, VERTEX[0]), and respectively based on the ending points (VERTEX_1) and (VERTEX_2), use the dijkstra_path() method to generate the shortest paths DISTANCE_G_1 and DISTANCE_G_2; Then, according to the principle of trigonometric functions, determine the distances from the terminal insertion point (O) through the foot of the perpendicular (T) to the two nodes (VERTEX_1) and (VERTEX_2), and add them to DISTANCE_G_1 and DISTANCE_G_2 respectively. Take the minimum value of the two as DISTANCE_G_T; Finally, the sum of DISTANCE_G_T and DISTANCE_E is the shortest distance from the inserted terminal to the computer room.

[0025] Specifically, in step A, based on the width Width and the polyline plineObj1, the outer-edge polyline plineObj2 is obtained. The specific process is as follows: According to the width of the cable tray / duct and the inner edge of the cable tray / duct, use the Offset(Width) method to draw the outer-edge polyline plineObj2 of the cable tray / duct.

[0026] Specifically, in step A, the closed polyline of the cable tray / duct is obtained. The specific process is as follows: Use the AddLightweightPolyline() method to connect the starting points and ending points of plineObj1 and plineObj2 respectively, and form a closed polyline representing the cable tray / duct with a polyline.

[0027] Specifically, in step B, the node name at the computer room is "+J-0+".

[0028] Specifically, step B to establish the graph model is described in combination with the attached drawings. The specific process is as follows: First, after removing the keyword "+" from the inserted nodes, store them in the list VERTEX[].

[0029] As an implementation, VERTEX[0,1,2,3,4,5] contains a total of 6 nodes: "+J-0+", "+J-1+", "+J-2+", "+J-3+", "+J-4+", "+J-5+".

[0030] Then, select two adjacent nodes to generate edges and store them in the list EDGE[].

[0031] As an implementation, EDGE[0-1, 1-2, 2-3, 3-4, 4-5, 0-5, 1-4, 2-4] represents that there is an edge "0-1" (path) between nodes "+J-0+" and "+J-1+", and there is also an edge between nodes "+J-0+" and "+J-5+", and so on, with a total of 8 edges (paths).

[0032] Subsequently, according to the insertion point coordinates of the two nodes, calculate the distance between the two adjacent nodes, and store the distance value as the weighted value of the edge (path) in the list WEIGHT[].

[0033] Among them, the storage order of the weighted value list WEIGHT[] is the same as that of the edge list EDGE[], and the lengths of the list WEIGHT[] and EDGE[] are the same. For example, the value of WEIGHT[0] corresponds to EDGE[0], representing the weighted value of the first edge "0-1" (path).

[0034] The present invention utilizes the ActiveX interface provided by AutoCAD to complete basic operations such as drawing cable trays / ducts, inserting tray nodes, adding edges, and inserting terminals; by referencing the win32com.client module and the pythoncom module, establish the communication and interaction between Python and the AutoCAD application program, and use the Dijkstra algorithm to calculate the shortest path from the node to the computer room; calculate the shortest distance from the terminal to the node, and finally generate the cable length from the terminal to the computer room.

Claims

1. A method for calculating terminal cables in a building based on the shortest path algorithm, characterized in that: The following steps are involved: A. Draw the path of the cable tray / trough; B. Insert bridge nodes, add edges and weights, and build a graph model; C. Insert terminal; D. Calculate the shortest distance from the terminal to the bridge / channel; E. Calculate the cable length from the terminal to the computer room.

2. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 1, characterized in that: Step A: Draw the path of the cable tray / channel. The specific process is as follows: First, obtain the width of the bridge / channel; Then, draw the polyline plineObj1, which is the inner edge of the bridge / channel; Then, according to the width Width and the polyline plineObj1, the polyline plineObj2 of the outer edge is obtained; Finally, a closed polyline segment of the bridge / channel is obtained.

3. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 1, characterized in that: Step B inserts the bridge node. The specific process is as follows: First, select the insertion point coordinates at the generated bridge start point, end point, and bridge / channel intersection; Then, use the GetPoint method to get the insertion point coordinate value InsertVERTEXCOR; Then, use the AddText method to add the node name with the node insertion point InsertVERTEXCOR as the reference point; Finally, add a "+" sign before and after the node name as the frame header and frame tail, use "J" as the keyword, and the naming rule is "+J-x+", where x is an Arabic numeral.

4. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 1, characterized in that: Step B inserts bridge nodes, adds edges and weights, and builds a graph model, including adding graph vertices, edges, and edge weights. The specific process is as follows: First, search for nodes in the model file based on the keyword "J" and the identifier "+"; Then, remove the keyword "J" and the identifier "+" from the inserted node and store the node name in the list VERTEX[]; Then, select two adjacent nodes, generate edges, and store them in the list EDGE[]; Then, according to the insertion point coordinates of the two nodes, the distance between the two adjacent nodes is calculated, and the distance value is stored in the list WEIGHT[] as the weighted value of the edge; Finally, the graph model data of graph vertices VERTEX[], edges EDGE[] and edge weights WEIGHT[] are established.

5. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 1, characterized in that: Step B builds a graph model. The specific process is as follows: First, create an undirected graph G; Then, add graph vertices according to the VERTEX[] list; Finally, according to the EDGE[] list and WEIGHT[] list, add edges with weights, and the graph model is established.

6. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 1, characterized in that: Step C: Insert the terminal. The specific process is as follows: First, terminals are represented by blocks; Then, after the terminal is inserted into the graphic, the insertion point coordinates of the terminal are determined according to the InsertionPoint attribute of the block; Finally, complete all terminal insertions in the drawing.

7. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 1, characterized in that: Step D calculates and selects the cable tray / channel closest to the equipment terminal. The closest distance is the shortest distance from the equipment terminal insertion point to a node or the perpendicular distance from the equipment terminal insertion point to an edge.

8. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 1, characterized in that: Step D calculates and selects the cable tray / channel closest to the equipment terminal. The specific process is as follows: First, calculate the distance from the insertion point coordinates of all nodes to the terminal insertion point, and record the shortest distance DISTANCE_V and the corresponding node VERTEX_END; Then, use vector cross product to calculate the perpendicular distance from the block insertion point to all edges, determine whether the foot of the perpendicular falls on the edge, and record the shortest distance DISTANCE_E, record the edge EDGE_T, and record the two adjacent nodes VERTEX_1 and VERTEX_2; Then, the minimum value of DISTANCE_V and DISTANCE_E is taken as DISTANCE.

9. The method for calculating terminal cables in a building based on the shortest path algorithm according to claim 8, characterized in that: Calculate the cable length for DISTANCE_V. The specific process is as follows: First, based on G, the starting point and the end point, use the nx.dijkstra_path() method to generate the shortest path DISTANCE_G from the graph node VERTEX_END to the computer room, where the starting point is the computer room, VERTEX[0]; and the end point is VERTEX_END. Then, the shortest distance from the terminal to the communication is the sum of DISTANCE_G and DISTANCE_V.