A search engine-based urban engineering CAD drawing rapid retrieval method
By using a search engine-based approach, rapid retrieval of urban engineering CAD drawings was achieved, solving the problem of cross-system retrieval, improving drawing query efficiency, and supporting multiple data transmission protocols and automated processing.
Patent Information
- Application Number
- CN202510412943.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-04-03
AI Technical Summary
Existing technologies cannot effectively solve the problem of rapid retrieval of urban engineering CAD drawings among multiple departments and design companies, especially when data sources are diverse, time spans are long, versions are numerous, and data volumes are huge, making it impossible to achieve efficient cross-system queries.
A search engine-based approach is adopted to obtain CAD drawing data sources through a unified access method, convert them into DXF format files, calculate full-text index and location index, and write the drawing ID and attribute description data into the search engine to achieve full-text search and location search.
It enables rapid indexing and querying of CAD drawings for urban engineering projects, supports HTTP, FTP, and FILE protocols, has a high degree of automation, accurate acquisition of drawing documents, fast calculation speed, and improves retrieval efficiency. It is suitable for government information systems and enterprise internal information systems.
Smart Images

Figure CN120296232B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of CAD drawing retrieval, and particularly relates to a city engineering CAD drawing fast retrieval method based on a search engine. BACKGROUND
[0002] AutoCAD is the most commonly used computer-aided design software in the field of city survey and design, and has accumulated a large amount of city engineering CAD drawings in various e-government systems for city construction management and production practices of various survey and design enterprises. City management, administrative approval and engineering design and other practical activities have extensive application requirements for these drawings.
[0003] City engineering CAD drawings are usually in dwg format, and have two significant features of standardization and specification, scale and accuracy requirements on the drawing. The text content contained in the drawings generally includes place names, design structure names, design unit information and the like. Building engineering drawings use internal relative coordinates, and other city engineering coordinates use city coordinate system or geographic coordinate system. Therefore, the target drawings can be quickly located through drawing text and boundary position retrieval.
[0004] AutoCAD software itself also provides search functions based on local location, file name keywords and modification date, but it is fundamentally impossible to meet the requirements of fast query of drawings with various data sources, long time span, multiple versions and huge data volume. Many departments, design units or related scholars have explored various effective researches and practices such as establishment of drawing management system, retrieval method based on GIS technology and CAD drawing retrieval method based on deep learning. These methods improve the query efficiency of drawings to a certain extent in specific scenarios. However, these methods are often limited to specific software systems, internal enterprise networks or local ranges in terms of drawing data sources, and rely on manual continuous input or long-term data accumulation in data collection, which is difficult to be widely implemented among numerous departments and design enterprises.
[0005] Therefore, a new type of city engineering CAD drawing fast retrieval method is urgently needed. SUMMARY
[0006] In order to solve the above-mentioned problems, the present application provides a city engineering CAD drawing fast retrieval method based on a search engine.
[0007] The city engineering CAD drawing fast retrieval method based on the search engine provided by the present application adopts the following technical scheme:
[0008] The city engineering CAD drawing fast retrieval method based on the search engine comprises the following steps:
[0009] obtaining a CAD drawing data source;
[0010] According to the CAD drawing data source, a unified access method is established for the drawing file, and a unique ID is agreed;
[0011] The CAD drawing is converted into a dxf format file; the dxf format file is used to calculate the drawing document for full-text indexing; the dxf format file is used to calculate the boundary box for position indexing;
[0012] The unique ID and attribute description data of the CAD drawing are written into the search engine together with the calculated drawing document and boundary box;
[0013] Based on the search engine platform, a Web service is developed to realize full-text retrieval and position retrieval of CAD drawings.
[0014] Further, according to the CAD drawing data source, a unified access method is established for the drawing file, and a unique ID is agreed, which includes reading the CAD drawing data source file to obtain the access method of all drawing files, including Hypertext Transfer Protocol HTTP, File Transfer Protocol FTP and local file transfer protocol FILE; a Web service is developed to unify the access method of the drawing file.
[0015] Further, the development of the Web service unified drawing file access method includes the development of a unified file access method in the format of "http: / / ip_or_domain / gctz / ID", wherein "ip_or_domain" is the IP or domain name of the Web service, "gctz" is the agreed drawing file access URL prefix with the first letter of the Pinyin of "engineering drawing", and "ID" is the agreed unique ID in the format of "dwg_D", wherein "dwg" is a fixed prefix and "D" is a self-incrementing integer starting from 1.
[0016] Further, the CAD drawing is converted into a dxf format file, which includes converting the dwg format file into a dxf format file based on Python programming according to the actual situation of the CAD drawing data source.
[0017] Further, the dxf format file is used to calculate the drawing document for full-text indexing, which includes agreeing that each text entity character of the CAD drawing file is a single word, and obtaining all the word lists of the drawing file from the dxf format file as the initial document; selecting a certain number of initial documents as samples to calculate all the word lists, generate fixed name words, foldable words and isolated single word words; and processing each initial document using the obtained specific term to obtain the drawing document.
[0018] Further, the all word list of the drawing file obtained from the dxf format file is taken as the initial document, including reading the dxf format file line by line according to the text file, obtaining the character string of the text line according to the rule, and formatting the text line string containing Chinese. After formatting all the text lines contained in the dxf file, a word list is obtained, which is connected by a line feed character to form a string, and the initial document of the drawing file is obtained.
[0019] Further, the initial document of the agreed number is selected as the sample, and all the words are calculated, the fixed name word, the foldable word and the isolated single word are generated, including randomly selecting the initial document of the agreed number from all the initial documents as the sample data; all the words are obtained after removing the duplicate words of the sample data; then the fixed name word is obtained from all the words according to the rule; the foldable word is calculated with the initial document of the sample data as the known condition; the isolated single word is filtered from the foldable word by using the two filtering conditions of length 1 and not appearing in the fixed name word.
[0020] Further, the obtained specific word item is used to process each initial document to obtain a drawing document, including that the folding of the specific word of the word list means that the number of times the word appears in the word list is calculated first, then the word is deleted in the word list, and finally the word and its number of times are connected by an underscore "_" as a new word at the end of the word list; the initial document is read by line to form a word list, and the isolated single word is folded; the fixed ending single word and the continuous two or more single words are continuously folded; the continuous single word (more than 3) is combined according to the fixed name word and placed at the end of the list; the obtained word list is folded repeatedly, and the last remaining all words are obtained, which are connected by a semicolon ";" to form a text, and a drawing document is obtained, which is the processed initial document data source drawing of the drawing document. The drawing document of each initial document is processed to obtain the drawing document of each drawing data source.
[0021] Further, the drawing boundary box for position indexing is calculated by using the dxf format file, including that the drawing boundary box for position indexing is calculated by using the dxf format file, which includes obtaining the list of valid entities of the drawing by using the third-party plug-in of Python; the vertex coordinates of each entity are traversed, the boundary box of each entity is determined according to the vertex coordinates, and the drawing boundary box is determined according to the vertex coordinates of all entity boundary boxes.
[0022] Further, the ID of each drawing file, attribute description data, together with the calculated drawing document and the bounding box are written into a search engine, including creating a drawing file index, taking the drawing file ID as a custom document ID, defining the drawing document and the bounding box as necessary fields, taking them as a wordable text type and a spatial shape type respectively, and defining and assigning other attribute descriptions according to actual conditions, and the index shard and replica mechanism is reasonably set according to the data size; the ID of each drawing file and the index field value are written into the index according to the data insertion operation of the search engine platform by using Python programming.
[0023] In summary, the present application has the following beneficial technical effects:
[0024] The present application realizes the rapid index query of urban engineering CAD drawings, the data source is applicable to three kinds of hypertext transfer protocol (HTTP), file transfer protocol (FTP) and local file transfer protocol (FILE), can accept mass data input, does not need manual data input, has high automation degree, the drawing document acquisition method has good applicability, is not limited by the version of AutoCAD software, has less information redundancy, accurate CAD drawing file position acquisition, fast calculation speed, realizes the rapid retrieval method of CAD drawing file based on full-text index and position index, can quickly realize the index of mass CAD drawings already existing in the government information system, enterprise internal information system and local environment, greatly improves the retrieval efficiency of CAD drawing files in the field of urban engineering. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 is a schematic diagram of a search engine-based rapid retrieval method of urban engineering CAD drawings according to embodiment 1 of the present application.
[0026] Figure 2 is a schematic diagram of the process of calculating the drawing document from the dxf format file according to embodiment 1 of the present application.
[0027] Figure 3 is a schematic diagram of the continuous single word according to the fixed name word group method according to embodiment 1 of the present application. DETAILED DESCRIPTION
[0028] The present application will be further described in detail below with reference to the accompanying drawings.
[0029] Embodiment 1
[0030] Referring to Figure 1 The search engine-based rapid retrieval method of urban engineering CAD drawings according to the present embodiment specifically includes the following steps:
[0031] S1. Obtain the CAD drawing data source, establish a unified access method for the drawing file, and agree on a unique ID. Specifically,
[0032] The CAD drawing data source is obtained, a unified access method for drawing files is established, and a unique ID is agreed, including reading the CAD drawing data source file to obtain the access method of all drawing files. The main supported file access methods include HyperText Transfer Protocol (HTTP), File Transfer Protocol (FTP), and local file transfer protocol (FILE); the Web service unified drawing file access method is developed, and the access format is "http: / / ip_or_domain / gctz / ID", wherein "ip_or_domain" is the IP or domain name of the Web service, "gctz" is the agreed drawing file access URL prefix with the first letter of the Pinyin of "engineering drawing", and "ID" is the agreed unique ID, with the format "dwg_D", wherein "dwg" is a fixed prefix, and "D" is a self-incrementing integer starting from 1.
[0033] S2. Convert the CAD drawing to a dxf format file.
[0034] Specifically,
[0035] First, according to the actual situation of the dwg format file of the CAD drawing data source, select the AutoCAD software version that is more updated than the data source AutoCAD software, and then install it on the computer for data processing; then use Python programming to call the Windows COM component (Win32com) interface to operate the local AutoCAD software, and by opening each dwg format file and saving it as a dxf format file, the batch automatic conversion of the drawing dwg format file to the dxf format is realized.
[0036] S3. Calculate the drawing document for full-text indexing using the dxf format file, refer to Figure 2 .
[0037] Specifically,
[0038] (1) Agree to take each text entity of the CAD drawing file as a single word, and obtain all the word lists of the drawing file from the dxf format file as the initial document;
[0039] (2) Select a certain number of initial documents as samples, calculate all the word lists, generate fixed name words, foldable words, and isolated single word words;
[0040] (3) Process each initial document using the obtained specific term to obtain the drawing document.
[0041] Among them, all the word lists of the drawing file from the dxf format file are obtained as the initial document, and the specific method is:
[0042] 1) Read the dxf format file line by line as a text file. If the line text continuously appears "AcDbText" or "AcDbMText", "1", then the next line text is the literal content of the text entity. Read it as a literal line string;
[0043] 2) Format the read literal line string containing Chinese to get a word. The processing content includes removing spaces at the beginning and end, removing style definition characters, removing end symbols, removing meaningless characters (spaces, "\ P", "{", "\ f"), and replacing multiple line feeds with a single line feed.
[0044] Among them, the processing method of removing style definition characters is: removing format definition characters ("{" and "}"), obtaining a string array divided by English semicolon ";", obtaining the literal of each string in the array, and then connecting the obtained literal list into a string. The method for obtaining the literal of each string in the array is: first replace "\ f" in the string with "\ f", and then remove "\ P" or "\ f" characters.
[0045] 3) Connect all the words obtained by the newline character "\ n" to get an initial document of a dxf format file.
[0046] Among them, a certain number of initial documents are selected as samples, and all word lists, fixed name words, foldable words and isolated single word words are calculated. The specific method is:
[0047] 1) Randomly select 2000 from all initial documents as sample data, and take all initial documents if insufficient. The sample data is represented as: C={d1,d2,..,d m} (m is the total number of sample documents);
[0048] 2) After removing duplicates from all words of the sample data, all words are obtained, represented as: Lu={t1,t2,...,t n} (n is the total number of words), and saved as a file named "universal_terms.txt";
[0049] 3) From all words, fixed name words are obtained according to the rules, represented as: L f ={t f1 ,t f2 ,...,t fn} (fn is the total number of fixed name words), and saved as a file named "fix_terms.txt". The specific method is:
[0050] ① Considering that urban engineering drawings contain a large number of place names and design structure labels such as roads, water systems, buildings and units, words ending with fixed characters are extracted from all words. The agreed fixed ending characters include: road, city, road, frame, alley, lane, street, ditch, canal, river, and stream.
[0051] ② Filter the obtained words further with a character length range of 2 to 7 to remove duplicates. Then exclude words with a length of 6 that are composed of two words with the same length of 3. Remove duplicates again to obtain fixed name words.
[0052] ③ Manually add fixed terms as needed to obtain the final fixed terms. Manually add terms to the fixed term file "fix_terms.txt". For example, adding a line like "**City Surveying and Mapping Design Group Co., Ltd." at the end of the file will use that company name as a new fixed term.
[0053] 4) Using all words and the initial document of the sample data as known conditions, calculate collapsible words for handling repeated words. The method for calculating collapsible words is as follows:
[0054] ① Calculate the number of documents in which each word appears in all documents, represented as: DF={df t1 ,df t2 ,...,df tn}, where df ti For the word t i The number of documents that appear in all sample documents;
[0055] ② Calculate the maximum number of times each word appears in a single document, denoted as: TF max ={fd max (t1),fd max (t2),...,fd max (t n )}, where fd max (t i ) is the word t i Maximum number of times it appears in a single document;
[0056] ③ Based on the number of documents and the maximum number of occurrences per document obtained in the above two steps, set filtering conditions: the number of documents appearing must be greater than 3, the maximum number of occurrences per document must be greater than 3, and the word length must be less than 9. This will filter all words to obtain collapsible words, represented as: L c ={t|t∈L and df t >3 and fd maxSave the expression `(t)>3 and len(t)<9` (where len(t) represents the word length in characters) as a file named "collapsible_terms.txt".
[0057] 5) Words with a length of 1 character in the collapsible word list often have significant repetitions, which hinders document retrieval and affects the recombination of consecutive single-character words. These are treated as isolated single-character words and filtered from the collapsible word list using two criteria: length 1 and not appearing in fixed-name terms. This is represented as: L s ={t|t ∈ L c And len(t) = 1 and contain(L) f ,t)=False} (where,contain(L f ,t)=False indicates that the word is not in the fixed name word L f (Appears in the text), save it as a file named "single_terms.txt".
[0058] The process involves processing each initial document using the obtained specific terms to generate drawing documents. The convention for folding specific words in the word list is to first calculate the number of times the word appears in the word list, then delete the word from the word list, and finally connect the word and its occurrence count with an underscore "_" and place it at the end of the word list as a new word. The specific processing method is as follows:
[0059] 1) Read the initial document line by line into a word list, and collapse the isolated single words;
[0060] 2) Continue folding words that are not fixed-ending words and have two or more consecutive words;
[0061] 3) For consecutive single-character words (3 or more), form words using fixed nouns and place them at the end of the list;
[0062] Among them, consecutive single-character words are grouped according to fixed-name words. Figure 3 The specific method is as follows: First, take the current word list as the input list and extract consecutive single-character words. Connect adjacent words directly into a string to obtain a list of consecutive single-character word strings. Delete the extracted consecutive single-character words from the input list. Then, for each consecutive single-character word string, extract two possible fixed-name words in ascending and descending order, and take the word with the shorter word combination result list as the word combination result. Concatenate each word combination result to obtain a word list, remove duplicates, and then place it in the input list and return the obtained list.
[0063] Among them, continuous single-character word strings are extracted from fixed name words that can be combined. The specific method is as follows:
[0064] ① Construct a dictionary tree class for matching target words to fixed name words. On the basis of a general dictionary tree, add a complete matching search method. If there is a matching success result in the depth-first search query, return the target word. Otherwise, return an empty list.
[0065] ② Read the fixed name word list from the fixed name word text file. Words with a character length greater than 7 are considered as super-long fixed words, and other words with a character length greater than 2 and less than 8 are considered as ordinary words to construct a dictionary tree instance. The fixed name words of city engineering drawings, except for the design unit name which rarely exceeds 7 characters, can be considered as ordinary words. Through classification and length limitation, the efficiency advantage of the dictionary tree structure can be fully utilized to improve the word combination efficiency.
[0066] ③ Take the continuous single-character word string as the input string from the 3rd character. According to the position order of the straight connected word in normal order, the straight connected word in reverse order, and all permutation and combination words, get the list of words to be combined. From the first word in the list, compare it with the ordinary word dictionary tree one by one. If it hits, store it in the output list. The remaining characters are used as input strings. Otherwise, take another word in the forward direction and recombine and compare. When the number of words is greater than 7, flip the string once and compare from the 3rd character again. For the remaining string with a length still greater than 7 and less than 13, as long as each character is in a specific super-long fixed word, it is considered as the remaining word and stored in the output list. The remaining characters are stored as a word in the output list, and the output list is returned.
[0067] 4) Fold the repeated words in the obtained word list to get the last remaining all words. Connect them with semicolons “;” to get a text, which is a drawing document of the initial document data source drawing.
[0068] S4. Calculate the drawing boundary box for position indexing using the dxf format file.
[0069] Specifically,
[0070] (1) Use the Python third-party plug-in ezdxf to read the dxf file. Set the entity type to “LINE”, “LWPOLYLINE”, or “POLYGON”. Specify the layer name to filter all entities. If the list is empty, only take the entity list filtered by the entity type.
[0071] (2) Traverse the obtained entity list and traverse the vertex coordinates (x i , y i); take the minimum coordinate (min_x, min_y) and the maximum coordinate (max_x, max_y) of all vertices, and the bounding box of the entity is a rectangle determined by the minimum coordinate as the lower left corner and the maximum coordinate as the upper right corner; take the minimum coordinate (ext_minx, ext_miny) of the lower left corner and the maximum coordinate (ext_maxx, ext_maxy) of the upper right corner of all entity bounding boxes to determine a rectangle as the bounding box of the drawing file.
[0072] S5. Write each drawing file ID, attribute description data, together with the calculated drawing document and bounding box, into a search engine.
[0073] Specifically,
[0074] (1) Create a drawing file index, take the drawing file ID as a custom document ID, define the drawing document and the bounding box as mandatory fields, and take them as a wordable text type and a spatial shape type, respectively, and define and assign other attribute descriptions according to actual conditions, and the sharding and replication mechanism of the index is reasonably set according to the data size;
[0075] (2) Use Python programming to write the ID and index field values of each drawing file into the index according to the data insertion operation of the search engine platform.
[0076] S6. Develop a Web service based on the search engine platform to realize full-text retrieval and location retrieval of CAD drawings.
[0077] As a further implementation,
[0078] Wherein, regarding the search engine, the application adopts the Elasticsearch platform to realize the technical solution of embodiment 1, and specifically, the main idea of using python programming to call the Elasticsearch client to create a drawing file index and insert data is to first define an index template, then create a specific index, and then insert the drawing file ID "dwg_D" as the document ID, and the specific values of the graphic document, the bounding box and other attributes as the document attribute values into the index. As the index template of the drawing file index, the script for defining the attribute fields is:
[0079] The properties field "dxf_document" is of type "text", "analyzer""ik_smart"}, "boundary_box" is of type "geo_shape"}, "modified_time" is of type "date", "format""yyyy-MM-dd HH:mm:ss"}, and "dwg_name" is of type "text", "analyzer""ik_max_word"}}. The drawing document attribute field "dxf_document" is of type "text" (full-text search field), and the Chinese word segmentation uses the IK word segmenter, "ik_smart". The drawing boundary box attribute field "boundary_box" is of type "geo_shape". Other attribute fields of the drawing file include modification time "modified_time" of type "date", file name "dwg_name" of type "text", and word segmentation using "ik_max_word". The statement that calls the function to create the index template is:
[0080] The `response = es.indices.put_template(name=index_pattern_name, body=body)` method puts a template into an Elasticsearch file index. Here, `es` is an Elasticsearch instance, `index_pattern_name` is the name of the index template ('template_dwg_file'), and `body` is the dictionary definition of the index template. The return value `response` indicates whether the insertion was successful. An example statement for inserting a document into the index is:
[0081] `response=es.index(index="index_dwg_file-20240425",body= document,id ='dwg_1024')`, where `es` is an Elasticsearch instance, `index` is the index name, `body` is the document value, and `id` is a custom document ID. A document value is defined as: `document={"dxf_document":"Plot Scope and Number; Jing Shi East Road...; Original Linuo Industrial Park Partial Land Use Planning","boundary_box":{"type":
[0082] "envelope","coordinates":[[117.005,36.645],[117.023,36.651]]}, "modified_time":'2025-01-01T00:00:00',"dwg_name":'Land Use Planning Conditions Attachment'}. The function statement for batch data insertion is as follows:
[0083] The `elasticsearch.helpers.bulk(es, actions)` method takes an Elasticsearch instance as its value and a list of actions as its values. The script for defining one action is...
[0084] The code snippet `action={"_op_type": "index","_index": 'index_dwg_file-20240425',"_id": 'dwg_1024',"_source":{"dxf_document":document["dxf_document"], "boundary_box":document["boundary_box"],"dwg_name":document["dwg_name"], "modified_time":document["modified_time"]}}` defines a batch operation. The `"_op_type"` represents the batch operation type, `"_index"` is the index name, `"_id"` is the custom ID of the inserted document, and `"_source"` is a document value (`document`).
[0085] The code uses Python to call the Elasticsearch client for keyword full-text search and spatial search. The query for full-text search is: `query_body={"query":{"match":{"content": "keyword1 keyword2"}}}`, where `match` indicates that the query is based on full-text search, and `content` represents the search terms. The query for spatial search is:
[0086] The query is defined as follows: `query = {"query": {"bool": {"must": {"geo_shape": {"location": {"shape": {"type": "envelope", "coordinates": [[117.008, 36.664], [117.016, 36.659]]},"relation": "within"}}}}}}`. The spatial relation `relation` can take the value "within", or it can use `intersects`, `contains`, etc. The statement to call the search function is: `response = es.search(index = 'dwg_index', body = query)`, where `query` is the value that defines the query.
[0087] Regarding the Python programming implementation, this invention adopts Python programming to implement the technical solution of Embodiment 1. In this embodiment, the Flask framework is used to create a REST API to implement Web services. A service with the access format "http: / / ip_or_domain / gctz / ID" is developed to unify the access method of drawing files; a service with the access format "http: / / ip_or_domain / queryresult" is developed to output search results.
[0088] The function `get_dwg_bbox` for calculating the drawing bounding box is defined using the Python third-party plugin `ezdxf`. The implementation first loads the DXF format file using the statement: `dwg = ezdxf.readfile(dxf_url)`, where `dxf_url` is the storage location of the DXF file. Then, valid entities are selected from the drawing to calculate the bounding box. To improve the speed and effectiveness of the bounding box calculation, entity types "LINE", "LWPOLYLINE", or "POLYGON" are selected. The filtering statement by type is: `query_result = modelspace.query("LINE")`. Entities are further filtered by specifying the layer name, and the statement to obtain the entity layer name is: `layer_name = entity.dxf.layer`. If the result is empty, only the entity list filtered by entity type is retrieved. Finally, the obtained entity list is traversed, and for each entity, the vertex coordinates (x, y, y) are iterated. i ,y i); Take the minimum coordinates (min_x, min_y) and maximum coordinates (max_x, max_y) of all vertices. Use the minimum coordinates as the bottom left vertex and the maximum coordinates as the top right vertex. The resulting rectangle is the bounding box of the entity. Take the minimum coordinates (ext_minx, ext_miny) of the bottom left vertex and the maximum coordinates (ext_maxx, ext_maxy) of the top right vertex of all entity bounding boxes to determine a rectangle, which is used as the bounding box of the drawing file.
[0089] This implementation uses Python to call the win32com interface to convert DWG format files to DXF format. Specifically, the `convert_dwg_to_dxf` function is defined to convert a single DWG file to DXF format, and the `convert_source_to_dxf` function converts a list of files from a specified data source to DXF format. This is used to obtain DXF format files for sample data. The main idea behind the `convert_dwg_to_dxf` function is to install a relatively new version of AutoCAD software locally, call the local AutoCAD via win32com, open the input DWG file location, and save it as a DXF file in the specified location. The main coded statements are as follows:
[0090] acad = win32com.client.Dispatch("AutoCAD.Application")
[0091] document = acad.Documents.Open(source_path)
[0092] document.SaveAs(target_path,61)
[0093] The "61" indicates that the file type saved as is AutoCAD 2013 DXF. The main idea of the convert_source_to_dxf function is to obtain the drawing dwg format files one by one to the local machine based on the input data source file list through a unified access method, then call convert_dwg_to_dxf to save the dxf format files to the local machine, and finally delete the saved dwg format files.
[0094] The implementation of calculating drawing documents from DXF format files using Python programming includes seven main functions:
[0095] (1) The function read_dxf_text is used to calculate the initial document of the drawing. The input is the path of the dxf format file. The function reads the text of the text entity by reading the text file. After the format is processed, all words are obtained. The function returns the string of all words connected by the newline character "\n", which is the initial document.
[0096] (2) The function build_specific_terms is used to calculate specific terms. It reads the initial document of the sample data, calculates the list of all terms and saves it as the file "universal_terms.txt", calculates the fixed name terms and saves them as the file "fix_terms.txt", calculates the collapsible terms and saves them as the file "collapsible_terms.txt", and calculates the isolated single-word terms and saves them as the file "single_terms.txt".
[0097] (3) The function fold_single_terms is used to fold isolated single-character words from a word list. It folds isolated single-character words from a specified word list and returns the folded word list. The input parameters include the source word list and the isolated single-character word list.
[0098] (4) The function fold_continue_term is used to fold words that are not fixed-ending words and have two or more consecutive words in a word list. The input parameter is the source word list, and the function returns the folded word list. It needs to be called after folding isolated words, so there will be no folding of isolated words.
[0099] (5) The string can be combined fixed name words function combine_source. The input parameters include string, trie instance and fixed name words. First, extract the long fixed name word list and construct the trie of ordinary word fixed name words. Then, start from 3 characters and combine the string into words according to the rules. Calculate the word combination result and return the word list.
[0100] (6) The function string_series_terms, which combines three or more consecutive single-character words into fixed-name words, takes a source word list and fixed-name words as input parameters. It calculates a word list after combining fixed-name words. The main idea is to first extract consecutive single-character words from the source word list and delete these single-character words from the list. Then, the consecutive single-character word lists are directly concatenated. The function combine_source, which extracts the combined fixed-name words, is called on each string in ascending and descending order. The list with the shorter length of the word combination result list is taken and placed at the end of the source word list. The function returns a list after removing duplicates.
[0101] (7) The function build_dxf_document calculates the drawing document. The initial document string is input, and the word list is read line by line. The functions fold_single_terms, fold_continue_term, and string_series_terms are called in sequence to fold isolated single words, fold_continue_term, and string_series_term. After folding the repeated words in the obtained word list, all the remaining words are obtained and connected with semicolons ";" to form a text, which is a drawing document.
[0102] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for rapid retrieval of urban engineering CAD drawings based on a search engine, characterized in that, include: Obtain the CAD drawing data source; Establish a unified access method for drawing files based on the obtained CAD drawing data source, and agree on a unique ID; Convert CAD drawings to DXF format files; use DXF format files to calculate drawing documents for full-text indexing; use DXF format files to calculate bounding boxes for location indexing; The unique ID and attribute description data of the CAD drawing, along with the calculated drawing document and bounding box, are written into the search engine. Develop a web service based on a search engine platform to enable full-text search and location search of CAD drawings; The process involves establishing a unified access method for drawing files based on the acquired CAD drawing data source, and agreeing on a unique ID. This includes reading the CAD drawing data source file to obtain the access method for each drawing file, including Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Local File Transfer Protocol (FILE); and developing a Web service to unify the access method for drawing files. The development of a unified access method for drawing files via Web services includes developing a unified file access method in the format "http: / / ip_or_domain / gctz / ID", where "ip_or_domain" is the IP address or domain name of the Web service, "gctz" is the first letter of the pinyin for "engineering drawings" and is the agreed-upon URL prefix for accessing drawing files, and "ID" is the agreed-upon unique ID in the format "dwg_D", where "dwg" is a fixed prefix and "D" is an incrementing integer starting from 1. The process of converting CAD drawings into DXF format files includes converting dwg format files of drawings into DXF format files based on Python programming, according to the actual situation of dwg format files of the CAD drawing data source. The process of calculating drawing documents for full-text indexing using DXF format files includes: treating each text entity in the CAD drawing file as a single word; obtaining a list of all words in the drawing file from the DXF format file as an initial document; selecting a predetermined number of initial documents as samples; calculating the list of all words; generating fixed-name words, foldable words, and isolated single-character words; and processing each initial document with the obtained specific terms to obtain the drawing document. The process of obtaining a list of all words from a drawing file in DXF format as an initial document includes reading the DXF format file line by line as a text file, obtaining text line strings according to rules, formatting the text line strings containing Chinese characters to obtain a word, and concatenating all the obtained words with newline characters to obtain an initial document in DXF format. The process of selecting a predetermined number of initial documents as samples, calculating a list of all words, generating fixed-name words, foldable words, and isolated single-character words includes: randomly selecting a predetermined number of initial documents as calculation sample data from all initial documents; removing duplicate words from all words in the sample data to obtain all words; then obtaining fixed-name words from all words according to rules; calculating foldable words using all words and the initial documents of the sample data as known conditions; and filtering out isolated single-character words from foldable words using two filtering conditions: a length of 1 and no appearance in fixed-name words. The process of using specific terms to process each initial document to obtain a drawing document includes the following steps: First, the number of times a word appears in the word list is calculated. Then, the word is deleted from the word list, and finally, the word and its occurrence count are connected by an underscore "_" and placed at the end of the word list as a new word. The initial document is read line by line into a word list, and isolated single-character words are folded. Single-character words that do not have a fixed ending and are consecutive (two or more characters) are folded. Consecutive single-character words are grouped into words with fixed names and placed at the end of the list. Repeated words in the resulting word list are folded to obtain all remaining words, which are then connected by semicolons ";" to form a drawing document. Processing each initial document yields the drawing document for each drawing file in the data source.
2. The method for rapid retrieval of urban engineering CAD drawings based on a search engine according to claim 1, characterized in that, The process of calculating the drawing bounding box for location indexing using a DXF format file includes obtaining a list of valid entities in the drawing using a third-party Python plugin; traversing the obtained entity list, iterating through the vertex coordinates of each entity, determining the bounding box of each entity based on the vertex coordinates, and finally determining the drawing bounding box based on the vertex coordinates of all entity bounding boxes.
3. The method for rapid retrieval of urban engineering CAD drawings based on a search engine according to claim 2, characterized in that, The process involves writing the unique ID and attribute description data of the CAD drawing, along with the calculated drawing document and bounding box, into the search engine. This includes creating a drawing file index, taking the drawing file ID as a custom document ID, defining the drawing document and bounding box as required fields, and taking them as word-segmentable text type and spatial shape type, respectively. Other attribute descriptions are defined and assigned values according to the actual situation. The index sharding and copying mechanism is reasonably set according to the data scale. Python programming is used to write the ID and index field values of each drawing file into the index according to the data insertion operation of the search engine platform.
Citation Information
Patent Citations
CAD blueprint search method based on GIS technology
CN104537098A
Method for establishing a full-text retrieval document for an engineering file and a database
CN109871473A
Deep learning-based CAD drawing retrieval method and technology
CN115878828A