CAD drawing memory optimization method and system

By finding and optimizing block reference entities and sub-block reference entities in CAD drawings in CAD software, the problem of excessive memory usage caused by complex CAD drawings is solved, and the stability and performance improvement of the system is achieved.

CN119807204APending Publication Date: 2025-04-11SOUTH SURVEYING & MAPPING INSTR
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411991960.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

When existing CAD software reads complex CAD drawings, the memory usage is too high, causing system crash.

Method used

By finding the first tiles associated with all block reference entities in the model space, the model space memory optimization is performed, and after the model space memory optimization is completed, the second tiles associated with all sub-blocks in the database block table are recursively searched for all sub-blocks in the database block table reference entities, and the database block table memory optimization is performed.

Benefits of technology

Dual memory optimization of model space and database block tables is realized, significantly reducing redundant data and isolated resources in memory, and preventing system crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807204A_ABST
    Figure CN119807204A_ABST
Patent Text Reader

Abstract

The invention provides a CAD drawing memory optimization method and system, and relates to the technical field of computers.The method comprises the steps that a CAD drawing is read, and the CAD drawing comprises a model space and a database block table; searching a first image block associated with all block reference entities in the model space so as to perform memory optimization on the model space; judging whether memory optimization of the model space is completed or not; recursively searching a second graph block associated with all sub-block reference entities in the database block table so as to perform memory optimization on the database block table; and judging whether memory optimization of the database block table is completed or not, and if yes, completing memory optimization of the CAD drawing. According to the method, redundant data and isolated resources in the memory can be remarkably reduced, so that which entities of the CAD drawing are unused isolated resources is determined, the entities are unloaded from the memory space, and the purposes of effectively reducing memory occupation and preventing system crash when the complex CAD drawing is read are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a CAD drawing memory optimization method and system. Background Art

[0002] In the CAD design industry, as the complexity of design continues to increase, the amount of data carried by CAD drawings is also increasing. CAD drawings usually contain rich graphic elements, complex layer structures, and a large number of block references and nested references, which together constitute the complete expression of design information; however, this surge in complexity and data volume has brought unprecedented challenges to the memory management and processing performance of CAD software.

[0003] At present, when opening CAD drawings, CAD software needs to load the database objects in the CAD drawings into the memory. If the CAD drawings contain many database objects such as entities, data dictionaries, and blocks, a large amount of memory space will be occupied. When the occupied memory exceeds the current available memory of the device, the program will crash and fail to open. In order to deal with this problem, existing CAD software usually adopts some memory optimization strategies, such as memory paging, cache management, and data compression. However, these memory optimization strategies are often limited in effect when facing complex and large CAD drawings, and cannot fundamentally solve the problem of excessive memory usage leading to system crashes. Summary of the invention

[0004] In order to solve the problem in the above-mentioned prior art that the memory usage is too high when reading complex CAD drawings, resulting in system crash, the present invention proposes a CAD drawing memory optimization method and system, which effectively reduces the memory usage when reading complex CAD drawings and prevents system crash.

[0005] In order to achieve the above technical effects, the technical solution of the present invention is as follows:

[0006] A CAD drawing memory optimization method comprises the following steps:

[0007] S1. Reading a CAD drawing, wherein the CAD drawing includes a model space and a database block table;

[0008] S2. Finding the first block associated with all block reference entities in the model space to optimize the memory of the model space;

[0009] S3. Determine whether the model space memory optimization is completed. If so, execute S4; if not, return to S2;

[0010] S4. recursively searching the second block associated with all sub-blocks in the database block table with reference to the entity to optimize the memory of the database block table;

[0011] S5. Determine whether the database block table memory optimization is completed. If so, complete the CAD drawing memory optimization. If not, return to S4.

[0012] Preferably, the reading of the CAD drawing includes:

[0013] S11. Use CAD software to open the CAD drawing and obtain the data stream of the CAD drawing;

[0014] S12. Parsing the data stream to obtain parsed metadata;

[0015] S13. Read the handle object by traversing the handle tree in the metadata;

[0016] S14. Read the database object according to the offset address in the handle object;

[0017] S15. Check whether the database object is read correctly. If so, execute S16; if not, continue to check whether the database object is read correctly until the database object is read correctly, the check is completed, and execute S16;

[0018] S16. Determine whether the handle tree traversal is complete. If so, the reading of the CAD drawing is complete; if not, the reading of the CAD drawing is not complete, and return to S13.

[0019] Preferably, the metadata includes version information, verification information, auxiliary header, handle tree, class table, header information, template and summary information.

[0020] Preferably, all blocks in the model space refer to the first block associated with the entity to optimize the memory of the model space, including:

[0021] S21. Traverse all entities in the model space;

[0022] S22. Taking any entity among all entities in the model space as the current entity, starting from the current entity, reading the next entity of the current entity in the model space;

[0023] S23. Determine whether the next entity of the current entity is a block reference entity. If so, take the next entity of the current entity as the block reference entity and execute S24; if not, execute S28;

[0024] S24. Open the first block associated with the block reference entity, record the ID of the first block, and traverse all sub-entities in the first block;

[0025] S25. Taking any sub-entity among all the sub-entities in the first block as the current sub-entity, starting from the current sub-entity, reading the next sub-entity of the current sub-entity in the first block;

[0026] S26. Determine whether the next sub-entity of the current sub-entity is a sub-block reference entity. If so, return to S24; if not, execute S27;

[0027] S27. Determine whether the reading of the next sub-entity of the current sub-entity in the first block is finished. If so, the reading of the next sub-entity is finished and S28 is executed; if not, return to S25;

[0028] S28. Determine whether the traversal of all entities in the model space is complete. If so, the traversal is complete; if not, return to S22.

[0029] Preferably, if the traversal of all entities in the model space is completed, the memory optimization of the model space is completed; if the traversal of all entities in the model space is not completed, the memory optimization of the model space is not completed.

[0030] Preferably, the recursive searching of the second block associated with all sub-block reference entities in the database block table to optimize the memory of the database block table includes:

[0031] S31. Traverse all second blocks of the database block table;

[0032] S32. taking any second block among all the second blocks in the database block table as the current second block, starting from the current second block, reading the next second block of the current second block in the database block table;

[0033] S33. Determine whether the next second block of the current second block is the ID of the first block, if so, execute S36; if not, execute S34;

[0034] S34. Open all sub-entities in the first block for reading, and determine whether all sub-entities in the first block have been read. If so, execute S36; if not, execute S35;

[0035] S35. Delete the current sub-entity in the first block, release the memory space of the database object associated with the current sub-entity handle in the first block, and retain the offset address of the current sub-entity in the CAD drawing;

[0036] S36. Determine whether the traversal of all second blocks of the database block table is completed. If so, complete the memory optimization of the database block table. If not, return to S32.

[0037] Preferably, if traversing all the second blocks of the database block table is completed, the memory optimization of the database block table is completed; if traversing all the second blocks of the database block table is not completed, the memory optimization of the database block table is completed.

[0038] Preferably, the data stream is binary data.

[0039] The present invention also proposes a CAD drawing memory optimization system, comprising:

[0040] A CAD drawing reading module is used to read a CAD drawing, wherein the CAD drawing includes a model space and a database block table;

[0041] A first memory optimization module, used for finding a first block associated with all block reference entities in the model space, so as to perform memory optimization on the model space;

[0042] A first judgment module is used to judge whether the model space memory optimization is completed, and if so, call the second memory optimization module; if not, return to call the first memory optimization module;

[0043] A second memory optimization module, used for recursively searching for second blocks associated with all sub-block reference entities in the database block table, so as to perform memory optimization on the database block table;

[0044] The second judgment module is used to judge whether the memory optimization of the database block table is completed, and then complete the memory optimization of the CAD drawing. If not, it returns to call the second memory optimization module.

[0045] The present invention also proposes a computer device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;

[0046] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations such as the CAD drawing memory optimization method.

[0047] Compared with the prior art, the beneficial effects of the technical solution of the present invention are as follows: the present invention proposes a CAD drawing memory optimization method and system, firstly, in the process of reading the CAD drawing, by searching for the first block associated with all block reference entities in the model space, the model space is memory optimized, and then after the model space memory optimization is completed, the second block associated with all sub-block reference entities in the database block table is recursively searched to optimize the database block table memory, thereby realizing dual memory optimization of the model space and the database block table, which can significantly reduce redundant data and isolated resources in the memory, thereby determining which entities of the CAD drawing are unused isolated resources, and unloading them from the memory space, so as to achieve the purpose of effectively reducing memory usage and preventing system crashes when reading complex CAD drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A flowchart showing a CAD drawing memory optimization method proposed in an embodiment of the present invention;

[0049] Figure 2 A flowchart of reading a CAD drawing according to an embodiment of the present invention is shown;

[0050] Figure 3 A flowchart showing memory optimization of the model space proposed in an embodiment of the present invention;

[0051] Figure 4 A flowchart showing the memory optimization of the database block table proposed in an embodiment of the present invention;

[0052] Figure 5 A structural block diagram showing a CAD drawing memory optimization system proposed in an embodiment of the present invention;

[0053] Figure 6 A structural diagram showing a computer device proposed in an embodiment of the present invention;

[0054] 601. Processor; 602. Memory; 603. Communication interface; 604. Communication bus; 605. Executable instructions. DETAILED DESCRIPTION

[0055] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;

[0056] It is understandable to those skilled in the art that some well-known contents may be omitted in the drawings;

[0057] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0058] Example 1

[0059] like Figure 1 As shown, this embodiment proposes a CAD drawing memory optimization method, comprising the following steps:

[0060] S1. Reading a CAD drawing, wherein the CAD drawing includes a model space and a database block table;

[0061] In S1, see Figure 2 , the reading of the CAD drawing comprises:

[0062] S11. Use CAD software to open the CAD drawing and obtain the data stream of the CAD drawing;

[0063] In S11, the CAD software programming interface is opened to directly obtain the data stream of the CAD drawing, parse the metadata of the CAD drawing, and read the object handle set;

[0064] S12. Parsing the data stream to obtain parsed metadata;

[0065] In S12, the data stream is binary data, and the metadata includes version information, verification information, auxiliary headers, handle trees, class tables, header information, templates and summary information, etc.; wherein, the version information refers to the creation or modification version of the CAD drawing or related binary data stream, which helps users or software understand the version status of the current drawing or data, thereby ensuring compatibility and accuracy; the verification information is used to verify the integrity and accuracy of the data. In the CAD drawing or binary data stream, the verification information can ensure that the data has not been tampered with or damaged during transmission or storage. Common verification methods include checksums, hash values, etc.; Auxiliary headers are used to describe or manage specific parts of a data stream. In the binary data stream of a CAD drawing, the auxiliary header may contain metadata about the drawing, setting information, or application-specific data; A handle tree is a data structure used to manage and access objects or elements in a data stream. In a CAD drawing, a handle tree can represent the relationship and hierarchy between objects in the drawing. Each object has a unique handle (or index), and these objects can be easily accessed and modified through the handle tree; Class tables usually contain definitions of the types, properties, and behaviors of objects in a data stream. In a CAD drawing, a class table may define the types and properties of various objects in the drawing (such as lines, shapes, text, etc.), which helps software The header information is usually located at the beginning of the data stream or file, and contains metadata and setting information about the entire data stream or file. In the binary data stream of a CAD drawing, the header information may contain basic information such as the title, author, creation date, and modification date of the drawing, which helps users or software understand the background and source of the drawing. A template refers to a predefined format or style used to create a new CAD drawing or object. By using a template, users can quickly create drawings or objects with specific styles and settings, thereby improving design efficiency and consistency. Summary information is a brief description or summary of the content of a data stream or file. In a CAD drawing, the summary information may contain a brief description of the content, purpose, or importance of the drawing. This helps users quickly understand the main content and purpose of the drawing.

[0066] S13. Read the handle object by traversing the handle tree in the metadata;

[0067] In S13, the specific operation of reading the handle object is: after the reading of the last handle object is completed, the next handle object is read;

[0068] S14. Read the database object according to the offset address in the handle object;

[0069] In S14, the offset address in the handle object is saved in the CAD drawing, and is read and saved in the handle when the metadata is read;

[0070] S15. Check whether the database object is read correctly. If so, execute S16; if not, continue to check whether the database object is read correctly until the database object is read correctly, the check is completed, and execute S16;

[0071] S16. Determine whether the handle tree traversal is complete. If so, the reading of the CAD drawing is complete; if not, the reading of the CAD drawing is not complete, and return to S13.

[0072] Here, S1 first directly opens the CAD drawing through the CAD software and obtains its data stream. This step ensures the originality and integrity of the drawing and provides an accurate data basis for subsequent processing. Then, the data stream is parsed to obtain metadata. This process converts complex drawing data into a format that is easy to manage and operate, greatly improving the readability and usability of the data. Then, the handle objects are read one by one by traversing the handle tree in the metadata. This method not only has a clear structure, but also ensures that each handle object is read correctly, avoiding data omissions and errors. After reading the handle object, the database object is further read according to the offset address therein. This step realizes the access and extraction of specific graphic elements in the drawing, providing key information for subsequent drawing analysis and processing. In addition, the correctness of the read database object is checked to ensure the accuracy and reliability of the data and avoid subsequent problems caused by data errors. Finally, the end of the drawing reading is determined by judging whether the handle tree traversal is completed. This step ensures the integrity and consistency of the entire reading process. In summary, this process not only improves the reading efficiency and accuracy of CAD drawings, but also provides strong support for subsequent drawing processing and analysis.

[0073] S2. Finding the first block associated with all block reference entities in the model space to optimize the memory of the model space;

[0074] In S2, see Figure 3 , the searching for the first block associated with all block reference entities in the model space to optimize the memory of the model space includes:

[0075] S21. Traverse all entities in the model space;

[0076] S22. Taking any entity among all entities in the model space as the current entity, starting from the current entity, reading the next entity of the current entity in the model space;

[0077] S23. Determine whether the next entity of the current entity is a block reference entity. If so, take the next entity of the current entity as the block reference entity and execute S24; if not, execute S28;

[0078] In S23, whether the next entity of the current entity is a block reference entity is determined by comparing the entity type identifier or calling the API function of the CAD software to query the specific type of the entity. If the type matches the identifier of the block reference entity, the entity is confirmed to be a block reference entity, otherwise, the subsequent steps or judgments are continued.

[0079] S24. Open the first block associated with the block reference entity, record the ID of the first block, and traverse all sub-entities in the first block;

[0080] S25. Taking any sub-entity among all the sub-entities in the first block as the current sub-entity, starting from the current sub-entity, reading the next sub-entity of the current sub-entity in the first block;

[0081] S26. Determine whether the next sub-entity of the current sub-entity is a sub-block reference entity. If so, return to S24; if not, execute S27;

[0082] In S26, whether the next sub-entity of the current sub-entity is a sub-block reference entity is determined by comparing the type identifier of the sub-entity or calling the API function of the CAD software to query the specific type of the sub-entity. If the type matches the identifier of the sub-block reference entity, the sub-entity is confirmed to be a sub-block reference entity, otherwise, the subsequent steps or judgments are continued.

[0083] S27. Determine whether the reading of the next sub-entity of the current sub-entity in the first block is finished. If so, the reading of the next sub-entity is finished and S28 is executed; if not, return to S25;

[0084] S28. Determine whether the traversal of all entities in the model space is complete. If so, the traversal is complete; if not, return to S22.

[0085] In S28, the traversal program stored in the CAD software is used to check whether the last entity in the model space has been processed. This is achieved by maintaining a traversal counter or using the termination condition in the loop structure. If all entities have been visited and processed, that is, there are no more entities to traverse, the traversal is judged to be completed; otherwise, if there are still unprocessed entities, the previous step is returned to continue the traversal process.

[0086] Here, S2 can efficiently identify and process block reference entities and their associated blocks in the model space through a systematic traversal and judgment mechanism. The process first traverses all entities in the model space, accurately identifies the block reference entity, and further opens its associated blocks to traverse the sub-entities therein. By recursively checking whether the sub-block reference entity is contained in the sub-entity, it ensures that all nested blocks can be effectively accessed. In addition, after the traversal is completed, the process can accurately determine whether all entities in the model space have been processed, thereby ensuring the integrity and accuracy of the operation. This method not only improves the efficiency of memory optimization, but also helps to reduce memory usage and improve the overall performance of the CAD system.

[0087] S3. Determine whether the model space memory optimization is completed. If so, execute S4; if not, return to S2;

[0088] In S3, if the traversal of all entities in the model space is completed, the memory optimization of the model space is completed; if the traversal of all entities in the model space is not completed, the memory optimization of the model space is not completed.

[0089] S4. recursively searching the second block associated with all sub-blocks in the database block table with reference to the entity to optimize the memory of the database block table;

[0090] In S4, see Figure 4 , the recursive searching of the second block associated with all sub-block reference entities in the database block table to optimize the memory of the database block table includes:

[0091] S41. Traversing all second blocks of the database block table;

[0092] S42. taking any second block among all the second blocks in the database block table as the current second block, starting from the current second block, reading the next second block of the current second block in the database block table;

[0093] S43. Determine whether the next second block of the current second block has the ID of the first block. If so, execute S46; if not, execute S44;

[0094] S44. Open all sub-entities in the first block for reading, and determine whether all sub-entities in the first block have been read. If so, execute S46; if not, execute S45;

[0095] S45. Delete the current sub-entity in the first block, release the memory space of the database object associated with the current sub-entity handle in the first block, and retain the offset address of the current sub-entity in the CAD drawing;

[0096] S46. Determine whether the traversal of all second blocks of the database block table is completed. If so, complete the memory optimization of the database block table. If not, return to S42.

[0097] In S46, the traversal program stored in the CAD software is used to check whether the last second block in the database block table has been processed. This is achieved by maintaining a traversal counter (such as comparing the current block index with the total number of blocks) or using the natural termination condition in the loop structure (such as when the next block cannot be obtained). If all second blocks have been visited and checked, that is, the traversal counter reaches the total number of blocks or the next block cannot be obtained, it is determined that the traversal is completed, thereby completing the memory optimization process for the entire database block table.

[0098] Here, S4 systematically traverses all blocks in the database block table and accurately identifies the sub-block reference entities associated with the second block. This process can efficiently manage and optimize memory resources. During the traversal process, the sub-entities in the second block are read and processed one by one. By deleting the sub-entities that are no longer needed and releasing the memory space they occupy, the memory usage is significantly reduced. At the same time, the necessary information of the sub-entities in the CAD drawing (such as the offset address) is retained to ensure the integrity and availability of the drawing data. In addition, the process uses a recursive method to process nested sub-block reference entities, ensuring that all related blocks can be fully and accurately optimized, thereby improving the overall performance and stability of the CAD system.

[0099] S5. Determine whether the database block table memory optimization is completed. If so, complete the CAD drawing memory optimization. If not, return to S4.

[0100] In S5, if the traversal of all the second blocks of the database block table is completed, the memory optimization of the database block table is completed; if the traversal of all the second blocks of the database block table is not completed, the memory optimization of the database block table is completed.

[0101] In this embodiment, first, in the process of reading the CAD drawing, the model space is optimized in memory by searching for the first block associated with all block reference entities in the model space, and then after the memory optimization of the model space is completed, the second block associated with all sub-block reference entities in the database block table is recursively searched to optimize the memory of the database block table, thereby realizing dual memory optimization of the model space and the database block table, which can significantly reduce redundant data and isolated resources in the memory, thereby determining which entities of the CAD drawing are unused isolated resources, and unloading them from the memory space, so as to effectively reduce memory usage and prevent system crashes when reading complex CAD drawings. The present invention reduces the used memory by dynamically unloading unused isolated resources in the CAD drawing from the memory during the process of opening the CAD drawing. Compared with other dynamic memory optimization technologies, the present invention has the advantage of not affecting the use of other resources in the CAD drawing at all.

[0102] Example 2

[0103] See also Figure 5 This embodiment proposes a CAD drawing memory optimization system, which is characterized by comprising:

[0104] A CAD drawing reading module is used to read a CAD drawing, wherein the CAD drawing includes a model space and a database block table;

[0105] A first memory optimization module, used for finding a first block associated with all block reference entities in the model space, so as to perform memory optimization on the model space;

[0106] A first judgment module is used to judge whether the model space memory optimization is completed, and if so, call the second memory optimization module; if not, return to call the first memory optimization module;

[0107] A second memory optimization module, used for recursively searching for second blocks associated with all sub-block reference entities in the database block table, so as to perform memory optimization on the database block table;

[0108] The second judgment module is used to judge whether the memory optimization of the database block table is completed, and then complete the memory optimization of the CAD drawing. If not, it returns to call the second memory optimization module.

[0109] In this embodiment, first, in the process of reading the CAD drawing, the model space is optimized in memory by searching for the first block associated with all block reference entities in the model space, and then after the memory optimization of the model space is completed, the second block associated with all sub-block reference entities in the database block table is recursively searched to optimize the memory of the database block table, thereby realizing dual memory optimization of the model space and the database block table, which can significantly reduce redundant data and isolated resources in the memory, thereby determining which entities of the CAD drawing are unused isolated resources and unloading them from the memory space, thereby achieving the purpose of effectively reducing memory usage and preventing system crashes when reading complex CAD drawings.

[0110] Example 3

[0111] This embodiment also provides a computer device, see Figure 6 , including: a processor 601, a memory 602, a communication interface 603 and a communication bus 604, wherein the processor 601, the memory 602 and the communication interface 603 communicate with each other through the communication bus 604;

[0112] Wherein: the processor 601, the memory 602 and the communication interface 603 communicate with each other through the communication bus 604. The communication interface 603 is used for network communication with other devices such as a client or other servers. The processor 601 is used to execute executable instructions 605, which can specifically execute the operations of the described CAD drawing memory optimization method. Specifically, the executable instructions 605 may include program codes. The processor 601 may be a central processing unit CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement an embodiment of the present invention. The computer device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0113] The memory 602 is used to store executable instructions 605. The memory 602 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0114] The executable instruction 605 may be specifically called by the processor 601 to enable the computer device to perform the following operations:

[0115] S1. Reading a CAD drawing, wherein the CAD drawing includes a model space and a database block table;

[0116] S2. Finding the first block associated with all block reference entities in the model space to optimize the memory of the model space;

[0117] S3. Determine whether the model space memory optimization is completed. If so, execute S4; if not, return to S2;

[0118] S4. recursively searching the second block associated with all sub-blocks in the database block table with reference to the entity to optimize the memory of the database block table;

[0119] S5. Determine whether the database block table memory optimization is completed. If so, complete the CAD drawing memory optimization. If not, return to S4.

[0120] In this embodiment, first, in the process of reading the CAD drawing, the model space is optimized in memory by searching for the first block associated with all block reference entities in the model space, and then after the memory optimization of the model space is completed, the second block associated with all sub-block reference entities in the database block table is recursively searched to optimize the memory of the database block table, thereby realizing dual memory optimization of the model space and the database block table, which can significantly reduce redundant data and isolated resources in the memory, thereby determining which entities of the CAD drawing are unused isolated resources and unloading them from the memory space, thereby achieving the purpose of effectively reducing memory usage and preventing system crashes when reading complex CAD drawings.

[0121] Obviously, the above embodiments of the present invention are only examples for clearly illustrating the present invention, and are not intended to limit the implementation methods of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all implementation methods here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. A CAD drawing memory optimization method, characterized in that: The following steps are involved: S1. Reading a CAD drawing, wherein the CAD drawing includes a model space and a database block table; S2. Finding the first block associated with all block reference entities in the model space to optimize the memory of the model space; S3. Determine whether the model space memory optimization is completed. If so, execute S4; if not, return to S2; S4. recursively searching the second block associated with all sub-blocks in the database block table with reference to the entity to optimize the memory of the database block table; S5. Determine whether the database block table memory optimization is completed. If so, complete the CAD drawing memory optimization. If not, return to S4.

2. The CAD drawing memory optimization method according to claim 1, characterized in that: The reading of the CAD drawing comprises: S11. Use CAD software to open the CAD drawing and obtain the data stream of the CAD drawing; S12. Parsing the data stream to obtain parsed metadata; S13. Read the handle object by traversing the handle tree in the metadata; S14. Read the database object according to the offset address in the handle object; S15. Check whether the database object is read correctly. If so, execute S16; if not, continue to check whether the database object is read correctly until the database object is read correctly, the check is completed, and execute S16; S16. Determine whether the handle tree traversal is complete. If so, the reading of the CAD drawing is complete; if not, the reading of the CAD drawing is not complete, and return to S13.

3. The CAD drawing memory optimization method according to claim 2, characterized in that: The metadata includes version information, verification information, auxiliary header, handle tree, class table, header information, template and summary information.

4. The CAD drawing memory optimization method according to claim 2, characterized in that: The searching for the first block associated with all block reference entities in the model space to optimize the memory of the model space includes: S21. Traverse all entities in the model space; S22. Taking any entity among all entities in the model space as the current entity, starting from the current entity, reading the next entity of the current entity in the model space; S23. Determine whether the next entity of the current entity is a block reference entity. If so, take the next entity of the current entity as the block reference entity and execute S24; if not, execute S28; S24. Open the first block associated with the block reference entity, record the ID of the first block, and traverse all sub-entities in the first block; S25. Taking any sub-entity among all the sub-entities in the first block as the current sub-entity, starting from the current sub-entity, reading the next sub-entity of the current sub-entity in the first block; S26. Determine whether the next sub-entity of the current sub-entity is a sub-block reference entity. If so, return to S24; if not, execute S27; S27. Determine whether the reading of the next sub-entity of the current sub-entity in the first block is finished. If so, the reading of the next sub-entity is finished and S28 is executed; if not, return to S25; S28. Determine whether the traversal of all entities in the model space is complete. If so, the traversal is complete; if not, return to S22.

5. The CAD drawing memory optimization method according to claim 4, characterized in that: If the traversal of all entities in the model space is completed, the memory optimization of the model space is completed; if the traversal of all entities in the model space is not completed, the memory optimization of the model space is not completed.

6. The CAD drawing memory optimization method according to claim 5, characterized in that: The recursive searching of the second block associated with all sub-block reference entities in the database block table to optimize the memory of the database block table includes: S41. Traversing all second blocks of the database block table; S42. taking any second block among all the second blocks in the database block table as the current second block, starting from the current second block, reading the next second block of the current second block in the database block table; S43. Determine whether the next second block of the current second block has the ID of the first block. If so, execute S46; if not, execute S44; S44. Open all sub-entities in the first block for reading, and determine whether all sub-entities in the first block have been read. If so, execute S46; if not, execute S45; S45. Delete the current sub-entity in the first block, release the memory space of the database object associated with the current sub-entity handle in the first block, and retain the offset address of the current sub-entity in the CAD drawing; S46. Determine whether the traversal of all second blocks of the database block table is completed. If so, complete the memory optimization of the database block table. If not, return to S42.

7. The CAD drawing memory optimization method according to claim 6, characterized in that: If the traversal of all the second blocks of the database block table is completed, the memory optimization of the database block table is completed; if the traversal of all the second blocks of the database block table is not completed, the memory optimization of the database block table is completed.

8. The CAD drawing memory optimization method according to claim 2, characterized in that: The data stream is binary data.

9. A CAD drawing memory optimization system, characterized in that: include: A CAD drawing reading module is used to read a CAD drawing, wherein the CAD drawing includes a model space and a database block table; A first memory optimization module, used for finding a first block associated with all block reference entities in the model space, so as to perform memory optimization on the model space; A first judgment module is used to judge whether the model space memory optimization is completed, and if so, call the second memory optimization module; if not, return to call the first memory optimization module; A second memory optimization module, used for recursively searching for second blocks associated with all sub-block reference entities in the database block table, so as to perform memory optimization on the database block table; The second judgment module is used to judge whether the memory optimization of the database block table is completed, and then complete the memory optimization of the CAD drawing. If not, it returns to call the second memory optimization module.

10. A computer device, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation of the CAD drawing memory optimization method as described in any one of claims 1-8.

Citation Information

Cited By

  • CAD drawing loading method and system combined with cache optimization

    CN120315779A

  • A CAD drawing loading method and system combined with cache optimization

    CN120315779B