Excel and dwg file mutual conversion method and device
Patent Information
- Application Number
- CN202211351948.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2042-10-31
AI Technical Summary
[0004]1.针对部分特殊绘图格式的图纸,比如IO表、端子表等,制图软件中绘制操作较复杂,影响设计效率;
[0037] 1. Editing DWG format spreadsheet files is far less flexible and convenient than Excel. This invention supports mutual conversion between the two files, which can significantly improve drawing efficiency and ensure accuracy.
Smart Images

Figure CN115618819B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of construction drawing design, and specifically relates to a method and apparatus for converting between Excel and Dwg files. Background Technology
[0002] Large-scale engineering projects are characterized by tight project cycles, high construction requirements, and large construction scale. As the most upstream stage of the entire industry chain, the design phase of a project places high demands on the construction drawing design process of surveying and design enterprises, significantly increasing the workload and necessitating the search for methods to improve design efficiency. Standardization is an important foundation for improving design quality and enhancing the precision of design, while simplification is an essential element for simplifying design methods and improving design efficiency.
[0003] Currently, almost all design firms use computer software for 2D drafting, with the drawing type being DWG. However, 2D drafting software has the following drawbacks:
[0004] 1. For certain special drawing formats, such as I / O tables and terminal tables, the drawing operations in drafting software are relatively complex, which affects design efficiency;
[0005] 2. For tabular drawings, such as material lists, purchase orders, equipment lists, and piping data tables, operations such as adding or deleting rows, copying, and merging are inconvenient, which seriously affects the drawing output time;
[0006] 3. For drawings with a small number of calculations, such as drawing catalogs, the summary and other functions cannot be automatically calculated, increasing the probability of designers making statistical errors.
[0007] Therefore, 2D drafting software cannot meet the application requirements for efficient drawing of certain types of drawings.
[0008] If the above types of drawings are compiled and printed in Excel format, the printing quality is difficult to guarantee due to the large number of Excel versions, making standardized printing difficult and failing to meet the requirements of standard digital printing. Summary of the Invention
[0009] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method and apparatus for converting between Excel and Dwg files. This method allows for the mutual conversion of Excel and Dwg file formats, enabling the creation of graphics in Excel files and their rapid and accurate conversion to Dwg files. Furthermore, Dwg files can be converted to Excel files for modification and drawing, thereby improving graphics efficiency.
[0010] The technical solution of this invention is implemented as follows: This invention discloses a method for converting an Excel file to a Dwg file, comprising:
[0011] Get the list of name managers for Excel files, iterate through all values in the list, and compare them with the configured common table field prefix to determine whether a template file with the corresponding name in the Excel name manager list can be found in the Dwg template list;
[0012] If found, read the configuration file from the Excel file and write it into the corresponding Dwg template;
[0013] If not found, all Dwg templates are displayed to the user for manual selection, and then the configuration file of the Excel file is read and written into the corresponding Dwg template.
[0014] Retrieve the sequence of all text box names for the combo box component in the Excel file and store them in a temporary header table;
[0015] Iterate through all attribute definitions of the Dwg tag block, perform matching, and store the temporary table data in the attribute values.
[0016] Furthermore, when a template file with the corresponding name in the Excel Name Manager list can be found in the Dwg template list, the Dwg template is opened to obtain the attribute definition marker with the template name as the block name, the single row height of the Dwg template table is calculated, the content of the Excel file table is stored in a temporary table, and then the values in the temporary table are written to the corresponding attribute marker position in the Dwg element, row by row.
[0017] Furthermore, when the Excel file to be converted is a purchase order list type, the purchase order list Dwg cover template is obtained, and the sequence of all text box names of the combo box components in the Excel file is stored in the attribute definition of the corresponding block to generate the purchase order list cover.
[0018] Furthermore, the calculation of the single row height of the Dwg template table includes: finding two tags with the same name in the attribute definition tags and subtracting their coordinate positions to obtain the total row height; obtaining the default layer name of Dwg from the configuration file; identifying the number of lines on the layer whose primitive type is line and whose angle does not exceed ±5 degrees horizontally as the total number of rows; and dividing the total row height by the total number of rows to obtain the single row height value.
[0019] Furthermore, the step of writing the values from the temporary table into the corresponding attribute marker position in the Dwg, row by row, also includes: when the cell text exceeds the width of the Dwg cell, using an intelligent indentation algorithm for format optimization.
[0020] Furthermore, the step of writing the values from the temporary table into the corresponding attribute marker position in the Dwg, row by row, also includes: for multi-line text, obtaining the total actual height of the text to be written, deleting the horizontal lines of the lines that are superimposed on the lines, and calculating the starting line number of the next line based on the coordinates of the nearest horizontal line position to achieve intelligent format optimization.
[0021] This invention also discloses an apparatus for converting an Excel file to a Dwg file, specifically comprising:
[0022] The acquisition module is used to retrieve the list of name managers for an Excel file, and to retrieve the sequence of all text box names for combo box components in an Excel file.
[0023] The storage module is used to store the contents of an Excel file into a temporary table, to store the sequence of all text box names of a combo box component in an Excel file into a temporary header table, and to store the data in the temporary header table into attribute values.
[0024] The conversion module is used to iterate through all values in the list, find the template file with the corresponding name in the Excel Name Manager in the Dwg template list, open the Dwg template and get the attribute definition marker with the template name as the block name; calculate the height of a single row in the table and then write the values in the temporary table into the corresponding attribute marker position in the Dwg, row by row; and iterate through all attribute definitions of the Dwg label block and perform matching.
[0025] This invention also discloses a method for converting a Dwg file to an Excel file. After converting an Excel file to a Dwg file using the above method, the Dwg file can also be converted to an Excel file. The method includes: identifying Dwg tile information and matching the corresponding Excel template using a plug-in tool, reading the configuration file and writing it into the Excel template, and then performing file conversion.
[0026] Furthermore, the specific steps for identifying DWG tile information and matching it with the corresponding Excel template using a plug-in tool, reading the configuration file and writing it into the Excel template, and then performing file conversion are as follows:
[0027] Get the block attribute definition list of the Dwg file, iterate through all the values in the list and compare them with the common table field prefixes configured, and store the attribute definition name and coordinate position corresponding to the matching items in the configuration table into a temporary table.
[0028] Locate the corresponding file in the Excel template list and open the name manager list for that template;
[0029] Record the row number in the Dwg file, and then write the values from the temporary table into the corresponding column and row number in the Name Manager list in Excel, row by row.
[0030] Retrieve all attribute definitions of the blocks in the Dwg image tag section and store them in the temporary table in the table header;
[0031] Iterate through all the text box name sequences of the combo box components in the Excel file, match them, and then store the header temporary table data into the attribute values.
[0032] This invention also discloses an apparatus for converting Dwg files to Excel files, comprising:
[0033] The `get` module is used to retrieve the list of block attribute definitions in a Dwg file; it is also used to retrieve all block attribute definitions in the Dwg title block.
[0034] The storage module is used to store the attribute definition names and coordinate positions corresponding to the matching items in the configuration table into a temporary table; it is used to store all attribute definitions of the blocks in the Dwg drawing label into a temporary header table; and it is used to store the data in the temporary header table into attribute values.
[0035] The conversion module is used to traverse all values in the list and compare them with the configured common table field prefixes; it is used to find the corresponding file in the Excel template list, open the name manager list of the template, record the Dwg row number, and then write the values in the temporary table into the corresponding column and row number of the name manager list in Excel, row by row; it is used to traverse all text box name sequences of combo box components in the Excel file and match them.
[0036] Compared with the prior art, the present invention has the following main advantages:
[0037] 1. Editing DWG format spreadsheet files is far less flexible and convenient than Excel. This invention supports mutual conversion between the two files, which can significantly improve drawing efficiency and ensure accuracy.
[0038] 2. Existing technologies require manual adjustment of the format after conversion. This invention incorporates intelligent indentation and automatic optimization of multi-line text. For cases with a lot of cell content, it can automatically adjust the indentation and format after conversion to the new format, reducing repetitive workload.
[0039] 3. This invention can be applied to multiple versions of 2D drawing software CAD, such as 2007, 2014, and 2021, to meet the design habits of designers using different drawing software. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 This is a system schematic diagram of a plug-in tool for converting between Excel and Dwg files provided in an embodiment of the present invention;
[0042] Figure 2 This is a flowchart illustrating a method for converting between Excel and Dwg files according to an embodiment of the present invention. Detailed Implementation
[0043] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0044] See Figure 1 and Figure 2 This invention discloses a method and apparatus for converting between Excel and Dwg files. First, a plug-in tool is deployed in 2D drawing software (e.g., multiple versions of CAD such as 2007, 2014, and 2021) to convert between Excel and Dwg files for both common and special file types. Second, the administrator defines names and blocks according to the configuration file requirements, creates multiple types of Excel and Dwg templates, and synchronizes them to the client via the plug-in tool. This enables offline conversion between Excel and Dwg files even when the templates are not synchronized to the client; if the templates are not synchronized to the client, an internet connection is required to use the plug-in tool.
[0045] For drawings of common table types, templates are set up for both Excel and Dwg formats, and label information is positioned in the corresponding row and column cells to ensure a one-to-one correspondence between Excel and Dwg cells. During conversion, the Excel file header (including drafter, professional information, drafting date, project information, approval information, drawing number, security classification, etc.) and table content are written into the Dwg template file. For drawings of non-standard table types (such as IO tables, terminal tables, etc.), the table type and cell position are recorded through a configuration file to write the Excel table content into the Dwg file.
[0046] After the user selects and edits the desired Excel template, they upload one or more Excel files to the conversion plugin tool. The plugin tool matches the corresponding template based on the Excel attribute name, then reads the configuration file of the Excel file and writes it into the corresponding Dwg template for file conversion. Specifically, this includes: obtaining the name manager list of the Excel file, traversing all values in the list, and comparing them with the configured general table field prefix to determine whether a template file with the corresponding name in the Excel name manager list can be found in the Dwg template list.
[0047] If a template file with the corresponding name from the Excel Name Manager list can be found in the Dwg template list, the configuration file of the Excel file is read and written to the corresponding Dwg template. At this point, the Excel file is either a general table type or an order list type; the column attribute configuration file of the general table is read and written to the corresponding Dwg template. Specifically, when a template file with the corresponding name from the Excel Name Manager list can be found in the Dwg template list, the Dwg template is opened to obtain the attribute definition markers with the template name as the block name. The single-row height of the Dwg template table is calculated, the content of the Excel file table is stored in a temporary table, and then the values in the temporary table are written row by row to the corresponding attribute marker position in the Dwg template. Specifically, the content of the Excel file cells is stored in the temporary table according to columns.
[0048] The calculation of the single row height of the Dwg template table includes: finding two tags with the same name in the attribute definition tags and subtracting their coordinate positions to obtain the total row height; obtaining the default layer name of Dwg from the configuration file; identifying the number of lines on the layer whose primitive type is line and whose angle does not exceed ±5 degrees horizontally as the total number of rows; and dividing the total row height by the total number of rows to obtain the single row height value.
[0049] When cell text exceeds the width of a DWG cell, a smart indentation algorithm is used for format optimization. Specifically: the positions of the two nearest vertical lines are obtained based on the coordinate information of the column attribute markers on the layer, and the corresponding column width is calculated; then the actual text width of each row in that column is calculated. If the actual text width exceeds the column width, the algorithm checks at intervals of 0.1 until the text width does not exceed the column width. The width factor must be at least 0.6; otherwise, the text will appear ghosted. If the last line number of a single DWG has been written, a new DWG template is automatically created to continue writing.
[0050] For multi-line text, it is necessary to obtain the total height of the actual text written, delete the horizontal lines that are superimposed on the lines, and calculate the starting line number of the next line based on the coordinates of the nearest horizontal line to achieve intelligent format optimization.
[0051] If the template file with the corresponding name cannot be found in the Excel Name Manager list in the Dwg template list, all Dwg templates will be displayed to the user for manual selection. Then, the configuration file of the Excel file will be read and written to the corresponding Dwg template. At this time, the Excel file is an irregularly shaped table type.
[0052] Then, the plugin tool retrieves the sequence of all text box names for the combo box component in the Excel file and stores them in a temporary header table; it then iterates through all attribute definitions of the Dwg label block, matches them, and stores the data from the temporary header table into the attribute values for conversion.
[0053] When the Excel file to be converted is a purchase order list type, obtain the purchase order list Dwg cover template, store the sequence of all text box names of the combo box components in the Excel file into the attribute definition of the corresponding block, and generate the purchase order list cover.
[0054] If there are multiple Excel files, the user can choose whether to generate a single DWG file or split it into multiple single-frame DWG files.
[0055] If the conversion is successful, a Dwg file and a result log will be generated; if the conversion fails, a result log will be generated explaining the reason for the failure.
[0056] This invention also discloses an apparatus for converting an Excel file to a Dwg file, specifically comprising:
[0057] The acquisition module is used to retrieve the list of name managers for an Excel file, and to retrieve the sequence of all text box names for combo box components in an Excel file.
[0058] The storage module is used to store the contents of an Excel file into a temporary table, to store the sequence of all text box names of a combo box component in an Excel file into a temporary header table, and to store the data in the temporary header table into attribute values.
[0059] The conversion module is used to iterate through all values in the list, find the template file with the corresponding name in the Excel Name Manager in the Dwg template list, open the Dwg template and get the attribute definition marker with the template name as the block name; calculate the height of a single row in the table and then write the values in the temporary table into the corresponding attribute marker position in the Dwg, row by row; and iterate through all attribute definitions of the Dwg label block and perform matching.
[0060] This invention also discloses a method for converting Dwg files to Excel files. One or more general-type Dwg files converted by the tool can also be edited and modified before being converted to Excel. The tool identifies the Dwg block information, matches it with the corresponding Excel file, and reads the configuration file. The general table content of the general-type Dwg file is written into the Excel template. If the conversion is successful, an Excel file and a result log are generated. If the conversion fails, a result log is generated, explaining the reason for the failure.
[0061] The specific steps for using a plugin tool to identify DWG tile information, match it with the corresponding Excel template, read the configuration file, write it into the Excel template, and then perform file conversion are as follows:
[0062] Retrieve the block attribute definition list of the Dwg file, iterate through all values in the list and compare them with the common table field prefixes configured, and store the attribute definition name and coordinate position corresponding to the matching items in the configuration table into a temporary table; store the contents of the Excel cells into the temporary table in column format;
[0063] Locate the corresponding file in the Excel template list and open the name manager list for that template;
[0064] Record the Dwg line number, obtain the default layer name of the Dwg from the configuration file, identify the number of lines on the layer whose primitive type is line and whose angle does not exceed ±5 degrees horizontally, record the coordinate position of each line, and perform sequence encoding.
[0065] Then, write the values from the temporary table into the corresponding columns and rows of the Name Manager list in Excel, row by row;
[0066] Retrieve all attribute definitions of the blocks in the Dwg image tag section and store them in the temporary table in the table header;
[0067] Iterate through all the text box name sequences of the combo box components in the Excel file, match them, and then store the header temporary table data into the attribute values.
[0068] This invention also discloses an apparatus for converting Dwg files to Excel files, comprising:
[0069] The `get` module is used to retrieve the list of block attribute definitions in a Dwg file; it is also used to retrieve all block attribute definitions in the Dwg title block.
[0070] The storage module is used to store the attribute definition names and coordinate positions corresponding to the matching items in the configuration table into a temporary table; it is used to store all attribute definitions of the blocks in the Dwg drawing label into a temporary header table; and it is used to store the data in the temporary header table into attribute values.
[0071] The conversion module is used to traverse all values in the list and compare them with the configured common table field prefixes; it is used to find the corresponding file in the Excel template list, open the name manager list of the template, record the Dwg row number, and then write the values in the temporary table into the corresponding column and row number of the name manager list in Excel, row by row; it is used to traverse all text box name sequences of combo box components in the Excel file and match them.
[0072] To better illustrate the technical solution of this application, several embodiments will be listed below.
[0073] Example 1
[0074] The specific steps to convert a standard spreadsheet file (Excel) to a DWG file are as follows:
[0075] The program retrieves the list of name managers for the Excel file, iterates through all values in the list, compares them with the configured common table field prefixes, and stores the contents of the Excel file into a temporary table. Specifically, it stores the name of the name manager corresponding to the matching item in the configuration table and the reference position relationship into the temporary table, and stores the cell contents in the reference position relationship into the temporary table in a column manner.
[0076] Locate the template file with the corresponding name in the Excel Name Manager in the Dwg template list, open the Dwg template, and obtain the attribute definition tags with the template name as the block name;
[0077] Calculating the height of a single row in a Dwg template table involves: finding two tags with the same name in the attribute definition tags and subtracting their coordinates to get the total row height; obtaining the default layer name of Dwg from the configuration file; identifying the number of lines on that layer whose element type is line and whose angle does not exceed ±5 degrees horizontally as the total number of rows; and dividing the total row height by the total number of rows to get the single row height value.
[0078] Next, the values from the temporary table are written into the corresponding attribute marker in the Dwg, row by row, to the position of the graphic element as single-line text. If the last line number of a single Dwg has been written, a new Dwg template is automatically created to continue writing. If it is multi-line text, the format is automatically optimized, including: getting the total height of the actual text written, deleting the horizontal lines of the lines that are superimposed on the lines, and calculating the starting line number of the next line based on the coordinates of the nearest horizontal line.
[0079] When cell text exceeds the width of the DWG cell, a smart indentation algorithm is used to optimize the format. Specifically, the coordinate information of the column attribute marker on the layer is used to obtain the positions of the two nearest vertical lines and the corresponding column width. Then, the actual text width of each row in the column is calculated. If the actual text width exceeds the column width, the judgment is made at intervals of 0.1 until the text width does not exceed the column width. The width factor is not less than 0.6. Otherwise, the text will be displayed with ghosting.
[0080] The program retrieves the sequence of all text box names for the combo box component in an Excel file and stores them in a temporary header table.
[0081] Iterate through all attribute definitions of the Dwg tag block, perform matching, and store the data from the temporary header table into the attribute values.
[0082] Example 2
[0083] The specific steps to convert an Excel file (order list) to a DWG file are as follows:
[0084] The program retrieves the list of name managers from the Excel file, iterates through all values in the list, compares them with the prefixes of the common table fields configured, and stores the name of the name manager corresponding to the matching item in the configuration table and the reference position relationship.
[0085] Store the contents of cells in the referenced position relationship into a temporary table in a columnar manner;
[0086] Locate the template file with the corresponding name in the Excel Name Manager in the Dwg template list, open the Dwg template, and obtain the attribute definition tags with the template name as the block name;
[0087] Calculating the height of a single row in a Dwg template table involves: finding two tags with the same name in the attribute definition tags and subtracting their coordinates to get the total row height; obtaining the default layer name of Dwg from the configuration file; identifying the number of lines on that layer whose element type is line and whose angle does not exceed ±5 degrees horizontally as the total number of rows; and dividing the total row height by the total number of rows to get the single row height value.
[0088] Next, write the values from the temporary table into the corresponding attribute marker in the Dwg, row by row, to the position where the graphic element is multi-line text; if the last line number of a single Dwg has already been written, a new Dwg template will be automatically created to continue writing;
[0089] Get the total height of the actual text written, delete the horizontal lines that are above the lines, and calculate the starting line number of the next line based on the coordinates of the nearest horizontal line.
[0090] When cell text exceeds the width of the DWG cell, a smart indentation algorithm is used to optimize the format. Specifically, the coordinate information of the column attribute marker on the layer is used to obtain the positions of the two nearest vertical lines and the corresponding column width. Then, the actual text width of each row in the column is calculated. If the actual text width exceeds the column width, the judgment is made at intervals of 0.1 until the text width does not exceed the column width. The width factor is not less than 0.6. Otherwise, the text will be displayed with ghosting.
[0091] The program retrieves the sequence of all text box names for the combo box component in an Excel file and stores them in a temporary header table.
[0092] Iterate through all attribute definitions of the Dwg tag block, and after matching, store the temporary table data in the header into the attribute value;
[0093] The program retrieves the order list Dwg cover template, stores the sequence of all text box names of the combo box components in the Excel file into the attribute definition of the corresponding block, and generates the order list cover.
[0094] Example 3
[0095] The specific steps to convert an irregularly shaped Excel file to a DWG file are as follows:
[0096] The program retrieves the string representing the template name from the name manager of the Excel file, finds the matching Dwg template name and file type in the irregular table configuration, and if the template is not what the user needs, it displays all templates of that file type for the user to choose from. In an irregular table, one Excel template header can correspond to multiple Dwg template headers.
[0097] Read the configuration item for this file type from the irregular shape correspondence table, and write the attribute definition tag of the corresponding Dwg block according to the cell code of each string of data;
[0098] The program retrieves the sequence of all text box names for the combo box component in an Excel file and stores them in a temporary header table.
[0099] Iterate through all attribute definitions of the Dwg tag block, and after matching, store the temporary table data in the header into the attribute value.
[0100] Example 4
[0101] This invention also discloses an apparatus for converting an Excel file to a Dwg file, specifically comprising:
[0102] The acquisition module is used to retrieve the list of name managers for an Excel file, and to retrieve the sequence of all text box names for combo box components in an Excel file.
[0103] The storage module is used to store the name and reference position relationship of the name manager corresponding to the matching item in the configuration table into the table temporary table, to store the sequence of all text box names of the combo box component in the Excel file into the table header temporary table, and to store the data of the table header temporary table into attribute values.
[0104] The conversion module is used to iterate through all values in the list, find the template file with the corresponding name in the Excel Name Manager in the Dwg template list, open the Dwg template and get the attribute definition marker with the template name as the block name; calculate the height of a single row in the table and then write the values in the temporary table into the corresponding attribute marker position in the Dwg, row by row; and iterate through all attribute definitions of the Dwg label block and perform matching.
[0105] Example 5
[0106] This invention also discloses a method for converting a Dwg file to an Excel file. After converting an Excel file to a Dwg file using the above method, the Dwg file can also be converted to an Excel file. The method includes: identifying Dwg tile information and matching the corresponding Excel template using a plug-in tool, reading the configuration file and writing it into the Excel template, and then performing file conversion.
[0107] The specific steps are as follows:
[0108] The program retrieves the block attribute definition list of the Dwg file, iterates through all values in the list and compares them with the prefix of the common table field in the configuration. It then stores the attribute definition name and coordinate position corresponding to the matching item in the configuration table into a temporary table. Finally, it stores the cell contents in the coordinate position relationship into the temporary table in a columnar manner.
[0109] Locate the corresponding file in the Excel template list and open the name manager list for that template;
[0110] Recording DWG line numbers specifically includes: obtaining the default layer name of the DWG from the configuration file, identifying the number of lines on the layer whose primitive type is line and whose angle does not exceed ±5 degrees horizontally, recording the coordinate position of each line, and performing sequence encoding;
[0111] Then, write the values from the temporary table into the corresponding columns and rows of the Name Manager list in Excel, row by row;
[0112] The program retrieves all attribute definitions of the blocks in the Dwg image tag section and stores them in a temporary table in the header.
[0113] Iterate through all the text box name sequences of the combo box components in the Excel file, match them, and then store the header temporary table data into the attribute values.
[0114] Example 6
[0115] This invention also discloses an apparatus for converting Dwg files to Excel files, comprising:
[0116] The `get` module is used to retrieve the list of block attribute definitions in a Dwg file; it is also used to retrieve all block attribute definitions in the Dwg title block.
[0117] The storage module is used to store the attribute definition names and coordinate positions corresponding to the matching items in the configuration table into a temporary table; it is used to store all attribute definitions of the blocks in the Dwg drawing label into a temporary header table; and it is used to store the data in the temporary header table into attribute values.
[0118] The conversion module is used to traverse all values in the list and compare them with the configured common table field prefixes; it is used to find the corresponding file in the Excel template list, open the name manager list of the template, record the Dwg row number, and then write the values in the temporary table into the corresponding column and row number of the name manager list in Excel, row by row; it is used to traverse all text box name sequences of combo box components in the Excel file and match them.
[0119] This plug-in tool, installed in 2D drawing software, enables rapid conversion between Excel and DWG files. It primarily includes functions for converting general-format Excel to DWG, order list-format Excel to DWG, irregularly shaped table-format Excel to DWG, and general-format DWG to Excel. The order list-format Excel to DWG function is similar to the general-format Excel to DWG function, but additionally generates an order list cover. For multi-line text, this invention also features automatic format optimization.
[0120] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process may be rearranged without departing from the scope of this disclosure. The appended method claims provide elements of various steps in an exemplary order and are not intended to limit the scope to the specific order or hierarchy described.
[0121] In the detailed description above, various features are combined together in a single embodiment to simplify this disclosure. This approach to disclosure should not be construed as reflecting an intention that embodiments of the claimed subject matter require more features than are explicitly stated in each claim. Rather, as reflected in the appended claims, the invention is presented with fewer features than all of the features in a single disclosed embodiment. Therefore, the appended claims are hereby explicitly incorporated into the detailed description, with each claim representing a separate preferred embodiment of the invention.
[0122] Those skilled in the art will also understand that the various illustrative logic blocks, modules, circuits, and algorithm steps described in conjunction with the embodiments herein can be implemented as electronic hardware, computer software, or a combination thereof. To clearly illustrate the interchangeability between hardware and software, the various illustrative components, blocks, modules, circuits, and steps described above are generally described in terms of their functionality. Whether such functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the overall system. Those skilled in the art can implement the described functionality in alternative ways for each specific application; however, such implementation decisions should not be construed as departing from the scope of this disclosure.
[0123] The steps of the methods or algorithms described in conjunction with the embodiments herein can be directly embodied in hardware, software modules executed by a processor, or a combination thereof. The software modules can reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium well known in the art. An exemplary storage medium is connected to the processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. The ASIC can reside in a user terminal. Alternatively, the processor and storage medium can exist as discrete components in the user terminal.
[0124] For software implementation, the techniques described in this application can be implemented using modules (e.g., procedures, functions, etc.) that perform the functions described in this application. This software code can be stored in memory units and executed by a processor. The memory units can be implemented within the processor or outside the processor; in the latter case, they are communicatively coupled to the processor via various means, as is well known in the art.
[0125] The foregoing description includes examples of one or more embodiments. It is certainly impossible to describe all possible combinations of components or methods in order to describe the above embodiments, but those skilled in the art will recognize that further combinations and arrangements of the various embodiments are possible. Therefore, the embodiments described herein are intended to cover all such changes, modifications, and variations that fall within the scope of the appended claims. Furthermore, the term “comprising” as used in the specification or claims is interpreted in a manner similar to the term “including,” as it is understood when used as a conjunction in the claims. Additionally, the use of the term “or” in any of the claims and specification is intended to mean “non-exclusive or.”
[0126] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for converting an Excel file into a Dwg file, characterized by, include: Get the list of name managers for Excel files, iterate through all values in the list, and compare them with the configured common table field prefix to determine whether a template file with the corresponding name in the Excel name manager list can be found in the Dwg template list; If found, read the configuration file from the Excel file and write it into the corresponding Dwg template; If not found, all Dwg templates are displayed to the user for manual selection, and then the configuration file of the Excel file is read and written into the corresponding Dwg template. Retrieve the sequence of all text box names for the combo box component in the Excel file and store them in a temporary header table; Iterate through all attribute definitions of the Dwg tag block, perform matching, and store the temporary table data in the attribute values. When a template file with the corresponding name in the Excel Name Manager list can be found in the Dwg template list, open the Dwg template to obtain the attribute definition marker with the template name as the block name, calculate the single row height of the Dwg template table, store the content of the Excel file table into a temporary table, and then write the values in the temporary table into the corresponding attribute marker in the Dwg element position, row by row.
2. The method for converting an Excel file to a Dwg file according to claim 1, characterized in that, When the Excel file to be converted is a purchase order list type, obtain the purchase order list Dwg cover template, store the sequence of all text box names of the combo box components in the Excel file into the attribute definition of the corresponding block, and generate the purchase order list cover.
3. The method for converting an Excel file to a Dwg file according to claim 1, characterized in that, The calculation of the single row height of the Dwg template table includes: finding two tags with the same name in the attribute definition tags and subtracting their coordinate positions to obtain the total row height; obtaining the default layer name of Dwg from the configuration file; identifying the number of lines on the layer whose primitive type is line and whose angle does not exceed ±5 degrees horizontally as the total number of rows; and dividing the total row height by the total number of rows to obtain the single row height value.
4. The method for converting an Excel file to a Dwg file according to claim 1, characterized in that, The step of writing the values from the temporary table into the corresponding attribute marker position in the Dwg, row by row, also includes: when the cell text exceeds the width of the Dwg cell, using an intelligent indentation algorithm for format optimization.
5. The method for converting an Excel file to a Dwg file according to claim 1, characterized in that, The process of writing values from the temporary table into the corresponding attribute marker position in the Dwg, row by row, also includes: for multi-line text, obtaining the total actual height of the text to be written, deleting the horizontal lines of the lines that are superimposed on the lines, and calculating the starting line number of the next line based on the coordinates of the nearest horizontal line to achieve intelligent format optimization.
6. An apparatus for converting an Excel file to a Dwg file, characterized in that, Specifically, it includes: The acquisition module is used to retrieve the list of name managers for an Excel file, and to retrieve the sequence of all text box names for combo box components in an Excel file. The storage module is used to store the contents of an Excel file into a temporary table, to store the sequence of all text box names of a combo box component in an Excel file into a temporary header table, and to store the data in the temporary header table into attribute values. The conversion module is used to traverse all values in the list, find the template file with the corresponding name in the Excel Name Manager in the Dwg template list, open the Dwg template and get the attribute definition tags with the template name as the block name; This function is used to calculate the single-row height of a Dwg template table, store the contents of an Excel file table into a temporary table, and then write the values from the temporary table into the corresponding attribute marker in the Dwg file, row by row, to mark the position of the graphic element. It is also used to iterate through all attribute definitions of the Dwg icon block and perform matching.
7. A method for converting a DWG file to an Excel file, characterized in that, After converting an Excel file to a Dwg file using any one of the methods described in claims 1 to 5, the Dwg file can also be converted to an Excel file, including: identifying Dwg tile information and matching the corresponding Excel template using a plug-in tool, reading the configuration file and writing it into the Excel template, and then performing file conversion, specifically including: Get the block attribute definition list of the Dwg file, iterate through all the values in the list and compare them with the common table field prefixes configured, and store the attribute definition name and coordinate position corresponding to the matching items in the configuration table into a temporary table. Locate the corresponding file in the Excel template list and open the name manager list for that template; Record the row number in the Dwg file, and then write the values from the temporary table into the corresponding column and row number in the Name Manager list in Excel, row by row. Retrieve all attribute definitions of the blocks in the Dwg image tag section and store them in the temporary table in the table header; Iterate through all the text box name sequences of the combo box components in the Excel file, match them, and then store the header temporary table data into the attribute values.
8. The method for converting a DWG file to an Excel file according to claim 7, characterized in that, Recording DWG line numbers specifically includes: obtaining the default layer name of the DWG from the configuration file, identifying the number of lines on the layer whose primitive type is line and whose angle does not exceed ±5 degrees horizontally, recording the coordinate position of each line, and performing sequence encoding.
9. An apparatus for converting Dwg files to Excel files, characterized in that, include: The get module is used to retrieve the list of block attribute definitions of a Dwg file; Used to obtain all attribute definitions of blocks in the Dwg tag section, wherein the Dwg file is converted based on the method described in any one of claims 1 to 5; The storage module is used to store the attribute definition name and coordinate position corresponding to the matching item in the configuration table into a temporary table. Used to store all attribute definitions of the blocks in the Dwg tag section into a temporary table in the table header; Used to store the header temporary table data into attribute values; The conversion module is used to traverse all values in the list and compare them with the configured common table field prefixes; it is used to find the corresponding file in the Excel template list, open the name manager list of the template, record the Dwg row number, and then write the values in the temporary table into the corresponding column and row number of the name manager list in Excel, row by row; it is used to traverse all text box name sequences of combo box components in the Excel file and match them.
Citation Information
Patent Citations
CAD house type drawing batch drawing method based on data table
CN110569626A
Table file analysis method and device thereof
CN113505580A
AutoCAD-based block attribute identification and export method
CN114386129A