Urban engineering CAD drawing rapid retrieval method based on search engine
Through a search engine-based method, the rapid search of urban engineering CAD drawings is realized, cross-system search problems are solved, and rapid indexing and accurate search of massive drawings is realized, which is suitable for government information systems and internal enterprise information systems.
Patent Information
- Application Number
- CN202510412943.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2045-04-03
AI Technical Summary
The existing technology cannot effectively solve the problem of rapid search of CAD drawings in urban engineering among multiple departments and design enterprises, especially in the case of diverse data sources, long time span, many versions, and huge data volume. It is difficult for existing methods to achieve efficient search across systems.
Using a search engine-based method, the CAD drawing data source is obtained through a unified access method, converted into a dxf format file, the full text index and position index are calculated, and the unique ID and attribute description data are written to the search engine to realize full text search and position retrieval.
It realizes fast index query of massive CAD drawings, and applies to hypertext transmission protocol, file transfer protocol and local file transfer protocol. It has high automation, accurate and fast acquisition of drawing documents, and improves retrieval efficiency.
Smart Images

Figure CN120296232A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CAD drawing retrieval, and in particular to a method for quickly retrieving urban engineering CAD drawings based on a search engine. Background Art
[0002] AutoCAD is the most commonly used computer-aided design software in the field of urban survey and design. A large number of urban engineering CAD drawings have been accumulated in various e-government systems for urban construction management and the production practices of various survey and design enterprises and institutions. Practical activities such as urban management, administrative approval, and engineering design have extensive application requirements for these drawings.
[0003] Urban engineering CAD drawings usually adopt the dwg format, and have two significant characteristics on the drawing surface: standardization and normalization, as well as scale and accuracy requirements. The text content included in the drawings generally includes place names, names of designed structures, design unit information, etc. Architectural engineering drawings adopt internal relative coordinates, and other urban engineering coordinates adopt urban coordinate systems or geographic coordinate systems. Therefore, the target drawings can usually be quickly located by retrieving the drawing text and boundary positions.
[0004] The AutoCAD software itself also provides search functions based on the local location, file name keywords, and modification date, but it simply cannot meet the requirements for quickly querying drawings with diverse data sources, long time spans, multiple versions, and huge data volumes. Many departments, design units, or relevant scholars have explored various effective research and practices such as establishing drawing management systems, retrieval methods based on GIS technology, and CAD drawing retrieval methods based on deep learning. These methods have improved the drawing query efficiency to a certain extent in specific scenarios. However, these methods are often limited to the internal of specific software systems, enterprise internal networks, or the local machine in terms of drawing data sources, rely on manual continuous input or long-term data accumulation in data collection, and are difficult to be widely implemented and applied among many departments and design enterprises.
[0005] Therefore, there is an urgent need for a new method for quickly retrieving urban engineering CAD drawings. Summary of the Invention
[0006] In order to solve the above-mentioned problems, the present invention provides a method for quickly retrieving urban engineering CAD drawings based on a search engine.
[0007] A method for quickly retrieving urban engineering CAD drawings based on a search engine provided by the present invention adopts the following technical solutions: A method for quickly retrieving urban engineering CAD drawings based on a search engine includes: Obtain CAD drawing data sources; Establish a unified access method for the drawing files based on the obtained CAD drawing data source, and agree on a unique ID; Convert the CAD drawing into a DXF format file; calculate the drawing document for full-text indexing using the DXF format file; calculate the bounding box for location indexing using the DXF format file; Write the unique ID and attribute description data of the CAD drawing, along with the calculated drawing document and bounding box, into the search engine; Develop a Web service based on the search engine platform to implement full-text retrieval and location retrieval of CAD drawings.
[0008] Furthermore, the step of establishing a unified access method for the drawing files based on the obtained CAD drawing data source and agreeing on a unique ID includes reading the CAD drawing data source file to obtain the access methods of all drawing files, including the Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Local File Transfer Protocol (FILE); developing a Web service to unify the access method of the drawing files.
[0009] Furthermore, the step of developing a Web service to unify the access method of the drawing files includes developing a unified file access method in the format of "http: / / ip_or_domain / gctz / ID", where "ip_or_domain" is the IP or domain name of the Web service, "gctz" is the first letter of the pinyin of "engineering drawing" as the agreed URL prefix for accessing the drawing files, and "ID" is the agreed unique ID in the format of "dwg_D", where "dwg" is a fixed prefix and "D" is an auto-incrementing integer starting from 1.
[0010] Furthermore, the step of converting the CAD drawing into a DXF format file includes converting the DWG format file into a DXF format file based on Python programming according to the actual situation of the DWG format file in the CAD drawing data source.
[0011] Furthermore, the step of calculating the drawing document for full-text indexing using the DXF format file includes agreeing to use each text entity word in the CAD drawing file as a single word, obtaining all word lists of the drawing file from the DXF format file as the initial document; selecting a agreed number of initial documents as samples, calculating all word lists, generating fixed-name words, collapsible words, and isolated single words; processing each initial document with the obtained specific term items to obtain the drawing document.
[0012] Further, all the word lists obtained from the DXF format file are used as the initial document, including reading the DXF format file line by line as a text file, obtaining the text line strings according to the rules, formatting the text line strings containing Chinese, and formatting all the text lines included in the DXF file to obtain a word list, which is connected by line breaks into a string to obtain the initial document of the drawing file.
[0013] Further, a conventional number of initial documents are selected as samples to calculate all word lists, generate fixed-name words, collapsible words, and isolated single-character words, including randomly selecting a conventional number of initial documents from all the initial documents as the sample data for calculation; removing duplicates from all the words in the sample data to obtain all the words; then obtaining the fixed-name words from all the words according to the rules; taking all the words and the initial documents of the sample data as known conditions to calculate the collapsible words; and filtering out the isolated single-character words from the collapsible words by using two filtering conditions: having a length of 1 and not appearing in the fixed-name words.
[0014] Further, using the obtained specific terms to process each initial document to obtain the drawing document, including that the specific folding of a word in the word list means first calculating the number of times the word appears in the word list, then deleting the word from the word list, and finally connecting the word and its number of appearances with an underscore "_" as a new word and placing it at the end of the word list; reading the initial document line by line as a word list and folding the isolated single-character words in it; continuing to fold the single-character words that are not fixed-ending single-character words and are two or more consecutive single characters; grouping the consecutive single-character words (more than 3) according to the fixed-name words and placing them at the end of the list; folding the duplicate words in the obtained word list to obtain all the remaining words, which are connected by a semicolon ";" as text to obtain a drawing document, that is, the drawing document of the data source drawing of the processed initial document. Processing each initial document can obtain the drawing document of each drawing in the data source.
[0015] Further, calculating the drawing bounding box for position indexing by using the DXF format file, including calculating the drawing bounding box for position indexing by using the DXF format file, which includes obtaining the list of valid entities of the drawing by using a third-party Python plugin; traversing the obtained entity list, traversing the vertex coordinates of each entity, determining the bounding box of each entity according to the vertex coordinates, and determining the drawing bounding box according to the vertex coordinates of all the entity bounding boxes.
[0016] Further, writing the ID and attribute description data of each drawing file, along with the calculated drawing document and bounding box, into the search engine 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 respectively taking them as a text type that can be segmented and a spatial shape type. Other attribute descriptions are defined and assigned according to the actual situation. The sharding and replication mechanism of the index is reasonably set according to the data scale. Using Python programming, write the ID of each drawing file and the index field values into the index according to the data insertion operation of the search engine platform.
[0017] In summary, the present invention has the following beneficial technical effects: The present invention realizes the rapid index query of urban engineering CAD drawings. The data sources applicable include three types: Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Local File Transfer Protocol (FILE). It can accept massive data input, does not require manual data input, has a high degree of automation, has good applicability for the drawing document acquisition method, is not restricted by the AutoCAD software version, has less information redundancy, accurately obtains the location of CAD drawing files, has a fast calculation speed, realizes a fast retrieval method for CAD drawing files based on full-text index and location index, can quickly index the massive CAD drawings existing in the government information system, enterprise internal information system, and local environment, and greatly improves the retrieval efficiency of CAD drawing files in the urban engineering field. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a schematic diagram of a method for rapid retrieval of urban engineering CAD drawings based on a search engine according to Embodiment 1 of the present invention.
[0019] Figure 2 is a schematic diagram of the process of calculating a drawing document from a DXF format file according to Embodiment 1 of the present invention.
[0020] Figure 3 is a schematic diagram of the method of forming words by combining consecutive single words according to a fixed name in Embodiment 1 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0021] The present invention will be further described in detail below with reference to the accompanying drawings.
[0022] Embodiment 1 Refer to Figure 1 , a method for rapid retrieval of urban engineering CAD drawings based on a search engine in this embodiment specifically includes the following steps: S1. Obtain the CAD drawing data source, establish a unified access method for the drawing files, and agree on a unique ID. Specifically, The CAD drawing data source is obtained, a unified access method for the drawing files is established, and a unique ID is agreed upon, including reading the CAD drawing data source file to obtain the access methods of all drawing files. The main supported file access methods include three types: Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Local File Transfer Protocol (FILE); develop a Web service to unify the access method of the drawing files, and the access format is "http: / / ip_or_domain / gctz / ID", where "ip_or_domain" is the IP or domain name of the Web service, "gctz" is the first letter of the pinyin of "engineering drawing" as the agreed drawing file access URL prefix, and "ID" is the agreed unique ID, in the format of "dwg_D", where "dwg" is the fixed prefix and "D" is a self-incrementing integer starting from 1.
[0023] S2. Convert the CAD drawing into a DXF format file.
[0024] Specifically, First, according to the actual situation of the DWG format file of the CAD drawing data source, select an AutoCAD software version that is newer 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 the DWG format files one by one and saving them as DXF format files, realize batch automation of converting the drawing DWG format files into DXF format.
[0025] S3. Use the DXF format file to calculate the drawing document for full-text indexing, referring to Figure 2 。
[0026] Specifically, (1) Agree that each text entity text of the CAD drawing file is used as a single word, and obtain all the word lists of the drawing file from the DXF format file as the initial document; (2) Select a predefined number of initial documents as samples, calculate all the word lists, generate fixed-name words, collapsible words, and isolated single-character words; (3) Use the obtained specific term items to process each initial document to obtain the drawing document.
[0027] Among them, obtaining all the word lists of the drawing file from the DXF format file as the initial document, the specific method is: 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 text content of the text entity, and it is read as a text line string; 2) Format the read Chinese text line string to obtain a word. The processing content includes removing spaces at the beginning and end, removing style definition characters, removing trailing symbols, removing meaningless characters (spaces, "\\P", "{", "\f"), and replacing multiple line breaks with a single line break in sequence. Among them, the method for removing style definition characters is as follows: Remove format definition characters ("{", "}"), obtain a string array split by the English semicolon ";", obtain the text of each string in the array, and then concatenate the obtained text list into a string. The method for obtaining the text contained in each string in the array is as follows: First, replace the "\\f" contained in the string with "\f", and then remove the contained "\P" or "\f" characters.
[0028] 3) Concatenate all the obtained words with the line break character "\n" to obtain an initial document of a dxf format file.
[0029] Among them, select a conventional number of initial documents as samples, calculate all word lists, generate fixed name words, collapsible words, and isolated single words. The specific method is as follows: 1) Randomly select 2,000 from all initial documents as sample data for calculation. When there are not enough, take all initial documents. The sample data is expressed as: C = {d1, d2,.., d m} (m is the total number of sample documents); 2) After removing duplicates from all the words in the sample data, obtain all the words, expressed as: Lu = {t1, t2,..., t n} (n is the total number of words), and save them as a file named "universal_terms.txt". 3) Obtain fixed name words from all the words according to the rules, expressed as: L f = {t f1 , t f2 ,..., t fn} (fn is the total number of fixed name words), and save them as a file named "fix_terms.txt". The specific method is as follows: ① Considering the characteristics that the text of urban engineering drawing files contains a large amount of content such as place names and design structure markings of roads, water systems, buildings, and units, extract the words ending with fixed characters from all the words. The agreed fixed ending characters include: road, city, road, bridge, lane, li, street, ditch, canal, river, and stream. ② Continue to filter the obtained words with the condition that the character length range is 2 - 7. After removing duplicates, and then exclude the case where a word with a length of 6 is composed of two words with the same length of 3. After removing duplicates again, obtain the fixed name words. ③ Manually add fixed terms as needed to obtain the final fixed terms. Manually add fixed terms to the fixed terms file "fix_terms.txt", for example, add a line "** City Surveying, Mapping and Design Group Co., Ltd." at the end of the file, and the unit name can be used as a new fixed term.
[0030] 4) With all words and the initial document of the sample data as known conditions, calculate the foldable words for processing repeated text words. The method for calculating the foldable words is: ① Calculate the number of documents in which each word appears in all documents, expressed 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; ② Calculate the maximum number of times each word appears in a single document, expressed 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 occurrences in a single document; ③ According to the number of documents and the maximum number of times in a single document obtained in the above two steps, set the filtering conditions, the number of documents is greater than 3, the maximum number of times in a single document is greater than 3, and the word length is required to be less than 9, so that the foldable words are filtered out from all words, expressed as: L c ={t|t∈L and df t >3 and fd max (t)>3 and len(t)<9} (where len(t) represents the word length in characters) is saved as a file named “collapsible_terms.txt”.
[0031] 5) Among the words with a character length of 1 in the foldable words, some of them have many repetitions in the file word list, which is not conducive to document retrieval and affects the re-combination of consecutive single-word words. This part is regarded as an isolated single-word word, and two filtering conditions are used: length 1 and not appearing in fixed name words. It is filtered from the foldable words, expressed as: L s ={t|t∈L c And len(t)=1 and contain(L f ,t)=False}(where contain(L f, t) = False means the word does not appear in the fixed name word list L f and save it as a file named "single_terms.txt".
[0032] Among them, the obtained specific terms are used to process each initial document to obtain the drawing document. It is agreed that folding a specific word in the word list means first calculating the number of times the word appears in the word list, then deleting the word from the word list, and finally connecting the word and its number of appearances with an underscore "_" as a new word and placing it at the end of the word list. The specific processing method is as follows: 1) Read the initial document line by line into a word list and fold the isolated single-character words in it; 2) Continue to fold single-character words that are not fixed-ending single-character words and have two or more consecutive single characters; 3) Group consecutive single-character words (more than 3) into fixed name words and place them at the end of the list; Among them, grouping consecutive single-character words into fixed name words refers to Figure 3 , and the specific method is as follows: Take the currently obtained word list as the input list, first extract the consecutive single-character words, connect adjacent ones as a string to get a list of consecutive single-character word strings, and delete the extracted consecutive single-character words from the input list; then take the positive and reverse orders of each consecutive single-character word string twice to combine fixed name words, and take the one with the smaller length of the combination result list as its combination result; connect each combination result to get a word list, and after removing duplicates, get the combination result; place it in the input list and return the obtained list.
[0033] Among them, taking combinable fixed name words from consecutive single-character word strings, the specific method is ① Construct a trie class for matching target words to fixed name words, and add a complete matching search method on the basis of the ordinary trie to achieve returning the target word as long as there is a successful matching result in the depth-first search query, otherwise returning an empty list; ② Read the fixed name word list from the fixed name word text file, regard words with a character length greater than 7 as extra-long fixed words, and other words with a character length greater than 2 and less than 8 as ordinary words to construct a trie instance. Except for the design unit name, the fixed name words in urban engineering drawings rarely exceed 7 characters. Fixed name words such as roads, place names, and rivers can be regarded as ordinary words. By classification and length limitation, the efficiency advantage of the trie structure can be fully utilized to improve the word combination efficiency; ③ Take the continuous single-character string as the input string. Starting from the 3rd character, obtain the list of words to be combined in the order of forward direct conjunctions, reverse direct conjunctions, and all permutation and combination words. Starting from the first word in the list, compare with the ordinary word trie tree one by one. If a match is found, store it in the output list. The remaining characters are used as the input string again. Otherwise, take one more character forward and recombine for comparison. When the number of characters is greater than 7, flip the string once and start comparing from 3 characters again. For the remaining strings with a length still greater than 7 and less than 13, as long as each character is in the specific extra-long fixed word, it is considered that the remaining word is this word and store it in the output list. The remaining characters are stored as a word in the output list, and return the output list.
[0034] 4) Fold the duplicate words in the obtained word list to get all the remaining words finally, connect them with the English semicolon ";" as text, and obtain a drawing document, which is the drawing document of the original document data source drawing of the processed initial document. Processing each initial document can obtain the drawing document of each drawing of the data source.
[0035] S4. Calculate the drawing bounding box for position indexing using the dxf format file.
[0036] Specifically, (1) Use the Python third-party plugin ezdxf to read the dxf file, set the entity type to "LINE", "LWPOLYLINE" or "POLYGON", and filter all entities by specifying the layer name to obtain an entity list. If the list is empty, only take the entity list obtained by filtering according to the entity type; (2) Traverse the obtained entity list, and traverse the vertex coordinates (x i , y i ) for each entity; Take the minimum coordinates (min_x, min_y) and maximum coordinates (max_x, max_y) of all vertices. The positive rectangle determined by the minimum coordinates as the lower left vertex and the maximum coordinates as the upper right vertex is the bounding box of this entity; Take the minimum coordinates (ext_minx, ext_miny) of the lower left vertices and the maximum coordinates (ext_maxx, ext_maxy) of the upper right vertices of all entity bounding boxes to determine a positive rectangle as the bounding box of the drawing file.
[0037] S5. Write each drawing file ID, attribute description data, together with the calculated drawing document and bounding box, into the search engine.
[0038] Specifically, (1)Create an index for drawing files. Take the drawing file ID as a custom document ID. Define the drawing document and the bounding box as required fields, which are of the text type that can be segmented and the spatial shape type respectively. Other attribute descriptions are defined and assigned according to the actual situation. The sharding and replication mechanism of the index is reasonably set according to the data scale; (2)Use Python programming to write the ID of each drawing file and the numerical values of the index fields into the index according to the data insertion operation of the search engine platform.
[0039] S6. Develop a Web service based on the search engine platform to implement full-text search and location search for CAD drawings.
[0040] As a further implementation method, Among them, regarding the search engine, the present invention adopts the Elasticsearch platform to implement the technical solution of Embodiment 1. 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 use the drawing file ID, that is, "dwg_D", as the document ID, and insert the specific numerical values of the graphic document, the bounding box, and other attributes as the document attribute values into the index. As the index template for the drawing file index, the script for defining its attribute fields is: "properties":{"dxf_document":{"type": "text","analyzer":"ik_smart"},"boundary_box":{"type": "geo_shape"},"modified_time":{"type":"date","format":"yyyy-MM-dd HH:mm:ss"}, "dwg_name":{"type": "text","analyzer":"ik_max_word"}}. Among them, the drawing document attribute field "dxf_document" is of the type "text", that is, the full-text search field, and the Chinese word segmentation adopts the "ik_smart" type of the IK word segmenter. The drawing bounding box attribute field "boundary_box" is of the type "geo_shape". Other attribute fields of the drawing file include the modification time "modified_time" of the type "date", and the file name "dwg_name" of the type "text", and the word segmentation adopts the "ik_max_word" type; the statement for calling the function of creating the index template is: response = es.indices.put_template(name=index_pattern_name, body=body), where es is an Elasticsearch instance, index_pattern_name is the name of the drawing file index template 'template_dwg_file', body is the dictionary value of the index template definition, and the return value response indicates whether it is successful; an example statement for inserting a document into the drawing file index is: response=es.index(index="index_dwg_file-20240425",body= document,id ='dwg_1024'), where es is an Elasticsearch instance, the parameter index is the index name, body is the document value, id is the custom document ID, and a definition script for a document value is, document={"dxf_document":"Parcel scope and number;Jingshi East Road...;Partial land use plan of the former Linuo Industrial Park","boundary_box":{"type": "envelope","coordinates":[[117.005,36.645],[117.023,36.651]]}, "modified_time":'2025-01-01T00:00:00',"dwg_name":'Attachment of land use planning conditions'}. When inserting data in batches, the function call statement form is: elasticsearch.helpers.bulk(es,actions), where es is an Elasticsearch example, actions is the operation list, and a definition script for an operation is, 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"]}}, where "_op_type" represents the batch operation type, "_index" takes the index name, "_id" takes the custom ID of the inserted document, and "_source" takes a document value document.
[0041] Among them, Python programming is used to call the Elasticsearch client for full-text keyword search and spatial search. The query statement for full-text search is: query_body = {"query": {"match": {"content": "keyword1 keyword2"}}}, where "match" indicates that the query form is based on full-text search, and "content" represents the search term; the query statement form for spatial search is: query = {"query": {"bool": {"must": {"geo_shape": {"location": {"shape": {"type": "envelope", "coordinates": [[117.008, 36.664], [117.016, 36.659]]}, "relation": "within"}}}}}}, where the spatial relation "relation" can take values such as fully contained (i.e., within), intersects, contains, etc. The statement for calling the retrieval function is: response = es.search(index = 'dwg_index', body = query), where "query" takes the defined query.
[0042] Regarding the implementation of Python programming, the present invention adopts the technical solution of Embodiment 1 through Python programming. Among them, the Flask framework is used to create a REST API to implement a web service. A service with the access format of "http: / / ip_or_domain / gctz / ID" is developed to unify the access method of drawing files. A service with the access format of "http: / / ip_or_domain / queryresult" is developed to output retrieval results. Among them, the Python third-party plug-in ezdxf is used to define the function get_dwg_bbox for calculating the drawing bounding box. The implementation idea is to first load the dxf format file. The main coding statement is: dwg = ezdxf.readfile(dxf_url), where dxf_url is the storage location of the dxf format file. Select the effective expression entities on the drawing surface and calculate the drawing bounding box to improve the calculation speed and effectiveness of obtaining the drawing bounding box. Therefore, the entity types "LINE", "LWPOLYLINE", or "POLYGON" are selected. The coding statement for filtering by type is: query_result=modelspace.query("LINE"). Specify the layer name to continue filtering entities. The statement for obtaining the entity layer name is: layer_name=entity.dxf.layer. If the result is empty, only take the entity list obtained by filtering by entity type. Traverse the obtained entity list and traverse the vertex coordinates (x i , y i ); Take the minimum coordinates (min_x, min_y) and maximum coordinates (max_x, max_y) of all vertices. The positive rectangle determined by the minimum coordinates as the lower left vertex and the maximum coordinates as the upper right vertex is the bounding box of the entity. Take the minimum coordinates (ext_minx, ext_miny) of the lower left vertices and the maximum coordinates (ext_maxx, ext_maxy) of the upper right vertices of all entity bounding boxes to determine a positive rectangle as the bounding box of the drawing file.
[0043] Among them, Python is used to call the win32com interface to implement the conversion of dwg format files to dxf format. Specifically, the convert_dwg_to_dxf function is defined to implement the conversion of a single dwg format file to dxf format, and the convert_source_to_dxf function is used to implement the conversion of a specified data source file list to dxf format files for obtaining dxf format files of sample data. The main idea of the convert_dwg_to_dxf function is to install a relatively new version of AutoCAD software locally, call the local AutoCAD through win32com, open the location of the input dwg format file, and save it as a dxf format file at the specified location. The main coding statements are as follows: acad = win32com.client.Dispatch("AutoCAD.Application") document = acad.Documents.Open(source_path) document.SaveAs(target_path,61) Among them, "61" indicates that the type of the saved file is AutoCAD 2013 DXF. The main idea of the convert_source_to_dxf function is to obtain the dwg format files of the drawings one by one from the input data source file list through a unified access method to the local machine, then call convert_dwg_to_dxf to save the dxf format files to the local machine, and finally delete the saved dwg format files.
[0044] Among them, Python programming is used to calculate the drawing documents from dxf format files. The functional functions implemented by coding mainly include 7: (1)The function read_dxf_text for calculating the initial drawing document. Input the path of the dxf format file, read the text of the text entities in the way of reading a text file, obtain all words after format processing, and return a string of all words connected by the line break character "\n" as the initial document.
[0045] (2)The function build_specific_terms for calculating specific terms. Read the initial document of the sample data, calculate all word lists and save them as the file "universal_terms.txt", calculate the fixed name words and save them as the file "fix_terms.txt", calculate the collapsible words and save them as the file "collapsible _terms.txt", and calculate the isolated single-character words and save them as the file "single_terms.txt".
[0046] (3)The function fold_single_terms for folding isolated single-character words in a word list realizes folding isolated single-character words in 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.
[0047] (4)The function fold_continue_term for folding single-character words that are not fixed-ending and have two or more consecutive single characters realizes folding single-character words that are not fixed-ending and have two or more consecutive single characters in a specified word list. The input parameter is the source word list, and it returns the folded word list. It needs to be called after folding isolated single-character words, so there will be no folding of isolated single-character words.
[0048] (5)The function combine_source for extracting combinable fixed-name words from a string. The input parameters include the string, the trie instance, and the fixed-name words. First, extract the list of ultra-long fixed-name words and construct a trie for ordinary word fixed-name words. Then, start combining words from 3 characters in the string according to the rules, calculate the word combination result, and the return value is a word list.
[0049] (6)The function string_series_terms for combining fixed-name words with consecutive single-character words (more than 3). The input parameters include the source word list and the fixed-name words. Calculate the word list after combining fixed-name words with consecutive single-character 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, directly concatenate the consecutive single-character word list. Call the function combine_source for each string in the forward and reverse order, take the list with the smaller length of the word combination result list, and place it at the end of the source word list. Return the list after removing duplicates.
[0050] (7)The function build_dxf_document for calculating a drawing document. Input the initial document string, read it line by line to obtain a word list, and sequentially call the function fold_single_terms for folding isolated single-character words, the function fold_continue_term for folding single-character words that are not fixed-ending and have two or more consecutive single characters, and the function string_series_terms for combining fixed-name words with consecutive single-character words. Then, fold duplicate words in the obtained word list, and get all the remaining words in the end. Connect them with the English semicolon ";" as text, and thus obtain a drawing document.
[0051] The above are all the preferred embodiments of the present invention, and the protection scope of the present invention is not limited thereto. Therefore, all equivalent changes made according to the structure, shape, and principle of the present invention should be covered within the protection scope of the present invention.
Claims
1. A fast retrieval method for urban engineering CAD drawings based on a search engine, characterized in that, Including: Obtain the CAD drawing data source; Based on the obtained CAD drawing data source, establish a unified access method for the drawing files and agree on a unique ID; Convert the CAD drawing into a DXF format file; calculate the drawing document for full-text indexing using the DXF format file; calculate the bounding box for location indexing using the DXF format file; Write the unique ID of the CAD drawing, the attribute description data, along with the calculated drawing document and bounding box into the search engine; Develop a web service based on the search engine platform to achieve full-text retrieval and location retrieval of CAD drawings.
2. The rapid retrieval method of urban engineering CAD drawings based on a search engine according to claim 1, wherein The step of establishing a unified access method for the drawing files and agreeing on a unique ID based on the obtained CAD drawing data source includes reading the CAD drawing data source file to obtain the access method for each drawing file, including the Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), and Local File Transfer Protocol (FILE); developing a web service to unify the access method for the drawing files.
3. A method for quickly retrieving urban engineering CAD drawings based on a search engine according to claim 2, characterized in that, The step of developing a web service to unify the access method for the drawing files includes developing a unified file access method in the format of "http: / / ip_or_domain / gctz / ID", where "ip_or_domain" is the IP or domain name of the web service, "gctz" is the first letter of the pinyin of "engineering drawing" as the agreed URL prefix for accessing drawing files, and "ID" is the agreed unique ID in the format of "dwg_D", where "dwg" is a fixed prefix and "D" is an auto-incrementing integer starting from 1.
4. A method for quickly retrieving urban engineering CAD drawings based on a search engine according to claim 3, characterized in that The step of converting the CAD drawing into a DXF format file includes converting the drawing DWG format file into a DXF format file based on Python programming according to the actual situation of the DWG format file in the CAD drawing data source.
5. A method for quickly retrieving urban engineering CAD drawings based on a search engine according to claim 4, characterized in that, The step of calculating the drawing document for full-text indexing using the DXF format file includes agreeing to use each text entity word in the CAD drawing file as a single word, and obtaining all the word lists of the drawing file from the DXF format file as the initial document; Select a predetermined number of initial documents as samples, calculate all the word lists, generate fixed-name words, collapsible words, and isolated single-character words; process each initial document with the obtained specific terms to obtain the drawing document.
6. A method for quickly retrieving urban engineering CAD drawings based on a search engine according to claim 5, characterized in that, The step of obtaining all the word lists of the drawing file from the DXF format file as the initial document includes reading the DXF format file line by line as a text file, obtaining the text line string according to the rules; formatting the read text line string containing Chinese to obtain a word; connecting all the words obtained with line breaks to obtain the initial document of a DXF format file.
7. A rapid retrieval method for urban engineering CAD drawings based on a search engine according to claim 6, characterized in that, The step of selecting a predetermined number of initial documents as samples, calculating all the word lists, generating fixed-name words, collapsible words, and isolated single-character words includes randomly selecting a predetermined number of initial documents from all the initial documents as the calculation sample data; removing duplicates from all the words in the sample data to obtain all the words; then obtaining the fixed-name words from all the words according to the rules; calculating the collapsible words with all the words and the initial documents of the sample data as known conditions; Isolated single-character words are filtered from collapsible words using two filtering conditions: the length is 1 and they do not appear in fixed-name words.
8. A method for quickly retrieving urban engineering CAD drawings based on a search engine according to claim 7, characterized in that The obtained specific terms are used to process each initial document to obtain a drawing document. The specific operations include: for folding a specific word in the word list, it means first calculating the number of times the word appears in the word list, then deleting the word from the word list, and finally connecting the word and its appearance count with an underscore "_" as a new word and placing it at the end of the word list; reading the initial document line by line as a word list and folding the isolated single-character words in it; continuing to fold non-fixed-ending single-character words that are two or more consecutive single characters; grouping consecutive single-character words into fixed-name words and placing them at the end of the list; performing duplicate-word folding on the obtained word list to get all the remaining words, connecting them with a semicolon ";" as text to obtain a drawing document; processing each initial document to obtain the drawing document for each drawing file in the data source.
9. A method for quickly retrieving urban engineering CAD drawings based on a search engine according to claim 8, characterized in that, The drawing bounding box for position indexing is calculated using a DXF format file, including using a third-party Python plugin to obtain a list of valid entities in the drawing; traversing the obtained entity list, traversing the vertex coordinates for each entity, determining the bounding box of each entity based on the vertex coordinates, and determining the drawing bounding box based on the vertex coordinates of all entity bounding boxes.
10. A method for quickly retrieving urban engineering CAD drawings based on a search engine according to claim 9, characterized in that, The ID and attribute description data of each drawing file, along with the calculated drawing document and bounding box, are written into the search engine, including 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, taking them as a word-segmentable text type and a spatial shape type respectively, and defining and assigning other attribute descriptions according to the actual situation; reasonably setting the sharding and replication mechanism of the index according to the data scale; using 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.
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
Intelligent drawing auditing method and system for water conservancy project
CN119203264A
System and method for managing drawing and document
JP2005078429A