Loading method and device for custom entity in CAD drawing and storage medium
Through the differentiated loading strategy of multi-threaded architecture and a class of labels, the problem of low single-thread loading efficiency of custom entities is solved, and the efficient loading and resource security of custom entities is achieved, which is suitable for complex drawing scenarios.
Patent Information
- Application Number
- CN202510840098.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-06-23
AI Technical Summary
In the prior art, the single-threaded loading method of custom entities causes the overall processing speed of drawings to decrease, affecting engineering efficiency and collaboration experience.
Using a multi-threading architecture, differentiated loading strategies are performed through class one labels, custom entities are allocated to the main thread, multiple class one subthreads and class two subthreads, and accurately allocated according to the load type of the entity to achieve step-by-step optimization of loading speed.
In the highly free design environment of custom entities, it effectively balances loading efficiency and resource security, especially suitable for complex drawing scenarios containing a large number of heterologous custom entities, shortening the overall loading time and improving processing efficiency.
Smart Images

Figure CN120353518A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer graphics, and in particular to a method, device and storage medium for loading custom entities in CAD drawings. Background Art
[0002] As the requirements for drawing accuracy and functionality in industries such as construction, manufacturing, and machinery continue to increase, in the field of Computer Aided Design (CAD), standard CAD entities (such as lines, circles, and surfaces) can no longer meet the diverse design scenarios, prompting the continued growth in the demand for the development of custom entities. Custom entities refer to non-standard objects with specific geometric shapes and behavioral characteristics created through secondary development interfaces. For example, in AutoCAD, developers can create custom entities through the ObjectARX platform.
[0003] For example, an invention patent application with a patent application publication number of CN117910088A discloses a method and device for rapid construction and linkage update of a three-dimensional railway line, which relates to the technical field of railway line design, including: obtaining first information, the first information including standard design information of the plane, longitudinal section and cross section of the railway line; performing spatial line position splitting processing according to the first information to obtain a custom entity; performing multi-threaded parallel construction processing according to the custom entity to obtain a line entity model; performing minimum segment division processing according to the line entity model to obtain an update range, and obtaining an optimized scene model according to the update range and the line entity model; establishing a communication channel according to the optimized scene model, and the communication channel is used for the linkage update of the line.
[0004] It can be seen that custom entities are completely developed by users independently, and can deeply integrate professional domain knowledge to adapt to the usage requirements of different scenarios. They are highly flexible. In order to ensure data security when importing across devices or platforms, single-threaded sequential loading is usually adopted.
[0005] However, in actual applications, drawings containing custom entities often need to be exchanged frequently. The inefficiency of single-threaded loading leads to a decrease in the overall processing speed of drawings, seriously affecting engineering efficiency and collaboration experience. Summary of the invention
[0006] The main purpose of this application is to provide a method, device and storage medium for loading custom entities in CAD drawings. In order to solve the above-mentioned technical problems, this application specifically adopts the following technical solutions: A first aspect of the present application is to provide a method for loading a custom entity in a CAD drawing, the method comprising: S101. Obtain the CAD drawing to be loaded. The CAD drawing includes several custom entities, and a type of label is associated with each custom entity. The type of label is determined based on the loading type supported by the associated custom entity. S102. Create an entity loading thread, which includes a main thread, a second type of sub-thread, and multiple first type of sub-threads. For each of the custom entities, perform step S103 or S104: S103. According to the type of label, allocate the custom entity to the corresponding entity loading thread for loading to generate the display data of the custom entity. S104. If the type of label is identified as an abnormal state, allocate the corresponding unknown custom entity to the second type of sub-thread for loading to generate the display data of the unknown custom entity.
[0007] In some embodiments, the custom entity includes a first type of entity, and the loading type supported by the first type of entity is multi-threaded concurrent loading. S103 includes: Allocate the first type of entity to the corresponding first type of sub-thread for loading to generate the display data of the first type of entity.
[0008] In some embodiments, the custom entity includes a second type of entity, and the loading type supported by the second type of entity is concurrent loading. S103 includes: Allocate the second type of entity to the second type of sub-thread for loading to generate the display data of the second type of entity.
[0009] In some embodiments, the custom entity includes a third type of entity, and the loading type supported by the third type of entity is single-threaded loading. S103 includes: Allocate the third type of entity to the main thread for loading to generate the display data of the third type of entity.
[0010] In some embodiments, the method includes: Count the number of custom entities to be loaded in the second type of sub-thread; when the number of entities to be loaded is greater than a preset number, analyze the programming data of the unknown custom entity to determine the predicted loading type supported by the unknown custom entity; update the type of label of the unknown custom entity according to the predicted loading type; perform step S103 according to the updated type of label to allocate the unknown custom entity to the corresponding entity loading thread for loading.
[0011] In some embodiments, analyzing the predicted loading type supported by the unknown custom entity based on the programming data of the unknown custom entity includes: analyzing whether there is a shared resource reference in the unknown custom entity according to the programming data of the unknown custom entity; if not, the predicted loading type supported by the unknown custom entity is multi-threaded concurrent loading; if so, the predicted loading type supported by the unknown custom entity is concurrent loading.
[0012] In some embodiments, the custom entity is associated with a second type of label, and the second type of label stores the expected display characteristics of the custom entity. The method includes: based on the expected display characteristics, verifying the display data of the custom entity to determine the matching degree between the display data and the expected display characteristics; if the matching degree is lower than the preset matching degree, assigning the corresponding abnormal custom entity to the main thread for reloading to update the display data of the abnormal custom entity.
[0013] In some embodiments, the method includes: obtaining the historical display data of the CAD drawing to be loaded, and extracting the expected display data corresponding to each custom entity from the historical display data; extracting expected display characteristics from the expected display data, where the expected display characteristics include at least one of shape characteristics, color characteristics, or area characteristics.
[0014] The second aspect of the present application lies in providing a computer device, which includes: A memory for storing a computer program; A processor for executing the computer program and implementing the steps of the method for loading custom entities in a CAD drawing provided in any embodiment of the present application when executing the computer program.
[0015] The third aspect of the present application correspondingly provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor implements the steps of the method for loading custom entities in a CAD drawing provided in any embodiment of the present application.
[0016] Beneficial effects: The embodiments of the present application provide a method, device, and storage medium for loading custom entities in a CAD drawing, establishing a deep adaptation system between the custom entity and the multi-threaded architecture, and then guiding the execution of a differentiated loading strategy through a first type of label, achieving a step-by-step optimization of the loading speed. Thus, in a design environment with a high degree of freedom of custom entities, the loading efficiency and resource security are effectively balanced, especially suitable for complex drawing scenarios containing a large number of heterogeneous custom entities.
[0017] Specifically, tasks are accurately allocated to the main thread, multiple first-class sub-threads, and second-class sub-threads according to entity loading characteristics. By combining the collaborative work of the main thread, second-class sub-threads, and multiple first-class sub-threads, hierarchical management of loading tasks is achieved. The main thread focuses on processing single-thread-dependent entities to ensure their stability and correctness. Multiple first-class sub-threads accelerate the processing of independently loadable entities through a parallel mechanism, giving full play to the performance of multi-core processors. Second-class sub-threads are dedicated threads for concurrent loading. Thus, the overall loading time is significantly shortened through differentiated multi-threaded processing and parallel processing.
[0018] Moreover, when the custom entity loading type is unknown, second-class sub-threads serve as the default processing threads for unknown custom entities, moderately increasing concurrency to improve processing efficiency and avoiding the risk of resource conflicts that may be caused by using first-class sub-threads and the efficiency loss of using the main thread for processing. To further improve processing speed, an entity type prediction mechanism for unknown custom entities is triggered based on the task backlog situation of second-class sub-threads, so as to adaptively adjust thread allocation during high task backlogs, effectively utilize multi-thread resources, and improve loading efficiency, especially suitable for scenarios that require rapid loading during drawing review.
[0019] Furthermore, to ensure resource security and loading accuracy, single-threaded loading with conservative slow processing and high accuracy is adopted for some entities. The display results are automatically verified through the expected features in the second-class tags to identify display anomalies caused by incorrect thread allocation, and to distinguish between deliberately designed special effects by designers and real loading failures. When an unexpected display deviation is detected, the abnormal entity is automatically transferred to the most reliable main thread for reloading, which is highly applicable to complex drawings with complex geometric structures or special rendering requirements. Brief Description of the Drawings
[0020] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to actual scale. Obviously, the following-described drawings are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0021] Figure 1 is a schematic flowchart of a method for loading custom entities in CAD drawings provided by an embodiment of the present application; Figure 2 is a schematic diagram of entity loading thread allocation provided by an embodiment of the present application; Figure 3It is a schematic flowchart of another method for loading custom entities in CAD drawings provided by an embodiment of the present application; Figure 4 It is a schematic block diagram of the structure of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0022] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some but not all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0023] In this document, suffixes such as "module", "component" or "unit" used to represent elements are only for the convenience of description of the present application, and have no specific meaning in themselves. Therefore, "module", "component" or "unit" can be used interchangeably.
[0024] In this document, terms such as "upper", "lower", "inner", "outer", "front", "rear", "one end", "the other end", etc. indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be construed as a limitation to the present application. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.
[0025] In this document, unless otherwise clearly specified and defined, terms such as "installed", "provided with", "connected", etc. should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, a direct connection, or an indirect connection through an intermediate medium, and can be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific situations.
[0026] In this document, "and / or" includes any and all combinations of one or more of the listed related items.
[0027] In this document, "a plurality of" means two or more, that is, it includes two, three, four, five, etc.
[0028] It should be noted that in this article, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or device comprising that element.
[0029] In this article, the drawing can be a CAD drawing, and the format of this drawing can be the dwg format, dxf format, dwt format, etc., and can also be a proe drawing, SolidWorks drawing and other drawings that can support concurrent computing, which are not limited here.
[0030] In this article, an entity refers to the graphic data in a drawing and is displayed on the drawing interface. Entities can be divided into two categories. One is the standard entities provided in advance inside the software, such as lines, circles, surfaces, etc.; the other is the custom entities customized by users according to needs, that is, non-standard objects created through secondary development interfaces and having specific geometric forms and behavioral characteristics.
[0031] In this article, concurrency means that multiple tasks are executed within the same time period. Multithreading is a way to achieve concurrency. By creating and running multiple threads in a program, each thread executes a different task, enabling the program to execute multiple tasks simultaneously, thereby improving the efficiency and performance of the program.
[0032] In the development process of custom entities, users are given a high degree of design freedom, enabling custom entities to deeply integrate professional domain knowledge and adapt to complex scenario requirements. However, since the geometric structure, behavioral logic, and data storage method of custom entities are all defined by developers themselves, the loading process has strong uncertainty and uncontrollability. To avoid security risks such as data format incompatibility or logical conflicts that may occur during cross-platform import, the existing technology generally adopts a conservative single-thread sequential loading mechanism, resulting in low resource utilization and affecting the overall processing efficiency of the drawing.
[0033] Based on this, the embodiments of this application provide a method, device, and storage medium for loading custom entities in CAD drawings, establishing a deep adaptation system between custom entities and a multithreaded architecture, and then implementing a differential loading strategy through a type of tag to achieve a stepped optimization of the loading speed. Thus, in the highly free design environment of custom entities, the loading efficiency and resource security are effectively balanced, especially suitable for complex drawing scenarios containing a large number of heterogeneous custom entities.
[0034] The following will describe in detail some embodiments of the present application with reference to the accompanying drawings. Without conflict, the following embodiments and the features in the embodiments may be combined with each other. Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a method for loading custom entities in a CAD drawing provided by an embodiment of the present application. As Figure 1 shown, an embodiment of the present application provides a method for loading custom entities in a CAD drawing, and the method includes S101 to S104.
[0035] S101, obtain a CAD drawing to be loaded, where the CAD drawing includes a plurality of custom entities, and the custom entities are associated with a type of label, and the type of label is determined based on the loading type supported by the associated custom entity.
[0036] Among them, the type of label can be an entity type identifier or a thread support identifier to quickly determine the loading characteristics of the custom entity according to the type of label, such as whether it supports concurrent operations and whether it is compatible with multi-threaded processing, so as to provide a decision basis for subsequent differential thread allocation and ensure a high degree of fit between the loading strategy and the entity characteristics. Exemplarily, there is a preset mapping relationship between the entity type identifier or the thread support identifier and the loading characteristics of the custom entity. For example, there is a mapping relationship between a type of entity and the loading type of multi-threaded concurrent loading. When the thread support identifier is "support multi-threaded concurrency" or the entity type identifier is "a type of entity", the custom entity is allocated to a type of sub-thread.
[0037] Among them, the custom entities include a type of entity, a type of entity, and a type of entity, and the supported loading types are multi-threaded concurrent loading, concurrent loading, and single-threaded loading respectively. The type of entity is a custom entity that supports multi-threaded concurrent loading, and its data and resources are completely independently maintained without involving shared resource access. Such custom entities can make full use of the parallel computing power of multi-core processors during the display data generation process to achieve efficient loading. The type of entity is a custom entity that only supports concurrent loading but does not support multi-threaded loading. Since it shares resources with other custom entities, such as a graphics database, a display list, a file system, etc., it is necessary to avoid data inconsistency or conflicts that may be caused by multiple threads accessing the same resource simultaneously, and only different tasks are allowed to access different resources concurrently. The type of entity is a custom entity that neither supports concurrency nor multi-threaded loading and can only be loaded in a single thread. It highly depends on other entities or its own historical state, or has a sequential dependence logical relationship, or depends on specific single-threaded resources during operation. Therefore, it needs to be serially processed in a single thread to ensure resource security.
[0038] It should be understood that due to differences in the implementation functions and writing methods of different custom entities, there are limitations on the applicable loading types for custom entities. For example, in the loading of a certain type of entity, there is no involvement of loading dependencies and shared resource references, and all three above-mentioned loading types (i.e., multi-threaded concurrent loading, concurrent loading, single-threaded loading) are applicable. The selection of the loading type only affects the overall loading efficiency of the drawing. Another example is that the loading of a second type of entity involves shared resource references. The applicable loading types for it are concurrent loading and single-threaded loading. Concurrent loading is the fast loading method it can support, while single-threaded loading is a slower loading method. Under both of these loading methods, the second type of entity can be correctly loaded. However, in the loading of a third type of entity, there may be involvement of loading dependencies and specific single-threaded resources, and it is only applicable to single-threaded loading. If a loading type other than single-threaded loading is selected for the third type of entity, or if multi-threaded concurrent loading is selected for the second type of entity, it may lead to loading errors or data corruption.
[0039] Among them, the loading dependency means that a custom entity depends on the existence, state, or loading order of other entities during the loading process. For example, in the loading process of a certain custom entity, it is necessary to reference the position information of other geometric bodies, or the flowchart nodes need to be generated in a specific logical order. The shared resource reference means that a custom entity needs to access the common resources in the drawing file during loading, and these resources may be read and written by multiple entities simultaneously.
[0040] In some embodiments, a flag bit is added to the secondary development file of the CAD drawing. The user can define a type of label for each custom entity through the flag bit. The flag bit is embedded in the attributes of the custom entity in the form of metadata. When extracting the custom entity from the CAD drawing, the specific value of the type of label can be quickly identified by parsing the flag bit. It should be understood that the setting of the flag bit realizes the acceleration of custom entity loading, effectively improving the loading efficiency and the user experience without increasing memory consumption and development complexity.
[0041] S102, create an entity loading thread, and the entity loading thread includes a main thread, a second-type sub-thread, and multiple first-type sub-threads.
[0042] Among them, the entity loading thread is a multi-threaded architecture created to process custom entities, including a main thread and multiple parallel sub-threads with the same priority. These parallel sub-threads run independently of the main thread and are used to execute entity loading tasks in parallel.
[0043] The main thread is the thread that runs by default when the program starts. It is responsible for initializing resources, managing other threads, and coordinating the operation of the entire program. In addition, the main thread is also responsible for loading entities with strict single-thread dependencies. The sub-threads are further divided into type-one sub-threads and type-two sub-threads. Multiple type-one sub-threads are used to process entities that support multi-threaded concurrent loading through type-one label verification; type-two sub-threads are used to process entities that only support concurrent loading through type-one label verification. It should be noted that the type-two sub-threads and the type-one sub-threads can have the same thread structure, and the distinction between them is only due to the different entity loading tasks they handle.
[0044] For each of the said custom entities, step S103 or S104 is executed to parse its associated type-one label to determine the loading strategy.
[0045] S103, allocate the custom entity to the corresponding entity loading thread for loading according to the type-one label to generate the display data of the custom entity; S104, if the type-one label is identified as an abnormal state, allocate the corresponding unknown custom entity to the type-two sub-thread for loading to generate the display data of the unknown custom entity.
[0046] Specifically, if the type-one label is valid and clear, based on the parsing result of the type-one label, the custom entity is accurately allocated to the corresponding entity loading thread. For example, if the thread support flag is "support multi-threaded concurrency" or the entity type flag is "type-one entity", the custom entity is allocated to the type-one sub-thread; if the type-one label is identified as abnormal, such as label missing, format error, or the identifier cannot match the preset identifier, at this time the entity is determined to be of an unknown type, and the unknown custom entity is allocated to the type-two sub-thread for loading.
[0047] Among them, the display data is the visual information generated after the entity is processed by the thread. For example, the geometric shape, color, texture and other entity information of the entity. When the entity loading is abnormal, the display data may include an error prompt, which is not limited here.
[0048] It should be understood that the secondary type of sub-threads, as the default processing threads, are used to execute the concurrent loading tasks of regular secondary type entities and unknown custom entities, and generate corresponding display data. Since the loading type of unknown custom entities is not yet clear, loading them in the secondary type of sub-threads can improve the loading speed through concurrency, avoid performance losses caused by completely serial processing, and avoid the risk of resource conflicts that may be caused by directly using multi-threaded concurrent loading. At the same time, although in actual applications the types of custom entities included in the drawing are determined by the implementation requirements of the user during secondary development, the tertiary type of entities that do not support either concurrency or multi-threaded loading strictly depend on a single-threaded execution environment, and their development complexity is relatively high. The workload required by the user during actual writing is much greater than that of the primary type of entities and the secondary type of entities, resulting in an extremely low proportion of the tertiary type of entities in actual projects. Moreover, for such extremely few custom entities used, the primary type of tags input by the user are generally relatively complete and have a low error rate. Therefore, using the secondary type of sub-threads as the default processing threads has a high degree of feasibility and can achieve a dynamic balance between resource security and processing speed.
[0049] Please refer to Figure 2 , Figure 2 which is a schematic diagram of entity loading thread allocation provided by an embodiment of the present application.
[0050] In some embodiments, the custom entity includes a primary type of entity, and the loading type supported by the primary type of entity is multi-threaded concurrent loading; S103 includes: allocating the primary type of entity to the corresponding primary type of sub-threads for loading to generate the display data of the primary type of entity.
[0051] Specifically, as Figure 2 shown, the custom entity can be a primary type of entity, and its loading type supports multi-threaded concurrent loading, that is, the data resources of this custom entity are independent and have no shared dependencies, and can be safely processed in parallel. Thus, after identifying such a custom entity according to the primary type of tags, it is allocated to the corresponding primary type of sub-threads for loading. The primary type of sub-threads, as parallel processing units, load the display data of this custom entity through a multi-threaded mechanism, making full use of the computing power of the multi-core processor and shortening the loading time.
[0052] In some embodiments, the custom entity includes a secondary type of entity, and the loading type supported by the secondary type of entity is concurrent loading; S103 includes: allocating the secondary type of entity to the secondary type of sub-threads for loading to generate the display data of the secondary type of entity.
[0053] Specifically, as Figure 2As shown, the custom entity can be a type-two entity, and its loading type supports concurrent loading, that is, this entity only allows parallel processing acceleration and cannot be accelerated through multi-threading. Therefore, after identifying such an entity based on a type-one label, it is assigned to a type-two sub-thread for loading. The type-two sub-threads process each type-two entity in sequence according to the reading order of the type-two entities (i.e., the storage sequence), ensuring the operation consistency of multiple concurrent tasks on shared resources, thereby generating the display data of the type-two entities.
[0054] It should be understood that due to the shared resource characteristics of the type-two entities, multi-thread conflicts need to be avoided during their loading process. However, the overall efficiency can still be improved through concurrent tasks, and there may be task accumulation in the type-two sub-threads. The main thread can allocate computing resources mainly to the type-two sub-threads, that is, the resource allocation priority of the type-two sub-threads may be higher than that of the type-one sub-threads.
[0055] In some embodiments, the custom entity includes a type-three entity, and the supported loading type of the type-three entity is single-thread loading; S103 includes: allocating the type-three entity to the main thread for loading to generate the display data of the type-three entity.
[0056] Specifically, as Figure 2 shown, the custom entity can be a type-three entity, and its loading type supports single-thread loading, that is, due to strict sequence dependencies, historical state bindings, or dependencies on specific single-thread resources, this entity needs to be processed serially in a single thread to ensure logical correctness. Therefore, after identifying such an entity based on a type-one label, it is assigned to the main thread for loading, and the main thread serially loads the display data of this custom entity to avoid data conflicts or logical errors caused by multi-thread concurrency.
[0057] It should be understood that the embodiments of the present application accurately allocate tasks to the main thread, multiple type-one sub-threads, and type-two sub-threads according to the entity loading characteristics. Combining the collaborative work of the main thread, type-two sub-threads, and multiple type-one sub-threads, hierarchical management of the loading tasks is achieved. The main thread focuses on processing single-thread-dependent entities to ensure their stability and correctness; multiple type-one sub-threads accelerate the processing of independently loadable entities through a parallel mechanism, giving full play to the performance of multi-core processors; type-two sub-threads, as dedicated threads for concurrent loading, not only carry regular concurrent tasks but also serve as the default processing threads for unknown custom entities.
[0058] It should be understood that when the loading type of the custom entity is unknown, the type-two sub-threads can not only improve the processing efficiency through appropriate concurrency but also avoid the risk of resource conflicts that may be caused by using type-one sub-threads and the efficiency loss of using the main thread for processing. Therefore, through differentiated multi-thread processing and parallel processing, the overall loading time is significantly shortened.
[0059] In some embodiments, the method includes: counting the number of custom entities to be loaded in the secondary sub-threads; when the number of entities to be loaded is greater than a preset number, analyzing, based on the programming data of the unknown custom entities, the predicted loading types supported by the unknown custom entities; updating the first-class tags of the unknown custom entities according to the predicted loading types; and performing step S103 according to the updated first-class tags to allocate the unknown custom entities to corresponding entity loading threads for loading.
[0060] Herein, the number of entities to be loaded refers to the total number of custom entities that are in the queuing state and have not started to be processed, including secondary entities and / or unknown custom entities. Correspondingly, the preset number is used to determine the degree of task backlog in the secondary sub-threads, and the specific value can be flexibly set according to hardware resources, loading speed, and loading time consumption, and will not be limited herein.
[0061] Herein, the programming data of the unknown custom entities refers to the corresponding part of the code of the unknown custom entities in the secondary development code, which can be characteristic codes reflecting thread compatibility, including but not limited to data such as resource access patterns, dependency relationships, and logical structures.
[0062] Specifically, count the number of unknown custom entities waiting in the secondary sub-threads to be loaded. When the number of entities to be loaded exceeds the preset number, trigger the entity type prediction mechanism. Infer the potential loading characteristics based on the programming data of the unknown custom entities. For example, compare the programming data of the unknown custom entities with a pre-stored code template library, where the code template library stores a large number of common code forms defining dependency relationships or shared resource references between entities. Update the predicted loading type to the first-class tags, so that the unknown custom entity obtains a clear and recognizable first-class tag. The updated first-class tag will guide the execution of step S103 to allocate the entity to a matching entity loading thread.
[0063] It should be understood that the entity type prediction mechanism of the unknown custom entities is triggered by the task backlog situation of the secondary sub-threads, so as to predict the actual loading type of the entities through programming data and update the tags when there is a high task backlog, thereby making full use of the computing resources of the first-class sub-threads, avoiding resource waste caused by premature analysis, preventing performance degradation caused by task backlog in the secondary sub-threads, and realizing the effective utilization of multi-thread resources.
[0064] In some embodiments, it is possible to preferentially start processing the unknown custom entities that are at the back of the queuing state to avoid affecting the processing process of the entities at the front of the queue, and when the number of entities to be loaded is less than or equal to the preset number, it is possible to stop analyzing, based on the programming data of the unknown custom entities, the predicted loading types supported by the unknown custom entities.
[0065] In some embodiments, analyzing the predicted loading type supported by the unknown custom entity according to the programming data of the unknown custom entity includes: analyzing whether there is a loading dependency relationship according to the programming data of the unknown custom entity; if not, the predicted loading type supported by the unknown custom entity is multi-threaded concurrent loading; if so, the predicted loading type supported by the unknown custom entity is concurrent loading.
[0066] Specifically, judging the predicted loading type according to the programming data of the unknown custom entity aims to identify a type of entity that can actually be loaded concurrently in multiple threads. Therefore, it is necessary to analyze whether the programming data of the custom entity involves the reference of shared resources to distinguish between a type of entity and a second type of entity. If the analysis result shows that the unknown custom entity has no reference to shared resources, it is determined that it supports multi-threaded concurrent loading and can be allocated to a first type of sub-thread for parallel processing; if there is a characteristic of reference to shared resources, it is still retained as an unknown custom entity and processed in the second type of sub-thread. Thus, the thread allocation strategy of the unknown custom entity is dynamically optimized to improve the loading efficiency while ensuring the loading accuracy and alleviating the task accumulation in the second type of sub-thread.
[0067] It should be understood that the data and resources of the first type of entity are completely independently maintained without the need to access shared resources. Its coding structure is significantly different from that of the second type of entity, and the access to shared resources in the programming data of the second type of entity has a certain identifiability with a relatively high recognition accuracy. Therefore, the entity type prediction mechanism in practical applications is mainly used to distinguish between the first type of entity and the second type of entity, so as to improve the loading speed and realize the effective utilization of multi-threaded resources. It should be noted that the third type of entity rarely appears in the actual scenario, and the abnormal rate of its first type label is relatively low, having a limited impact on the overall loading. Therefore, it is a secondary focus in practical applications.
[0068] After the CAD drawing is completed (or the main structure is completed), the user reviews the completed part to determine whether the drawn 3D model complies with the regulations and record the parts that need to be modified. For example, when the staff of the construction unit completes a building drawing through CAD software, they will first review the building drawing internally. Specifically, the staff responsible for reviewing the drawings needs to review the 3D model on the drawing (i.e., the model used to reflect the building) to evaluate whether the drawn content complies with the relevant regulations. In addition, after the construction unit completes the review of the building drawings internally, it is also necessary to provide it to the construction drawing review agency recognized by the construction authority. Subsequently, the construction drawing review agency reviews the contents of the construction drawings involving public interests, public safety and mandatory standards for engineering construction in accordance with relevant laws and regulations. It is understandable that in order to coordinate multiple factors such as the construction / processing safety and implementation cost of the project, a multi-step review process will be involved from the generation of a 3D drawing to its implementation and application. From the perspective of CAD reviewers, a CAD reviewer may have to review dozens or even hundreds of CAD drawing files every day, and the workload involved is very large. Therefore, the review efficiency can be effectively improved by quickly loading drawings and combining them with the entity type prediction mechanism.
[0069] In some embodiments, analyzing the predicted loading type supported by the unknown custom entity according to the programming data of the unknown custom entity includes: analyzing whether the unknown custom entity has loading dependencies and shared resource references according to the programming data of the unknown custom entity; if not, the predicted loading type supported by the unknown custom entity is multi-threaded concurrent loading; if there are loading dependencies and / or shared resource references, the predicted loading type supported by the unknown custom entity is single-threaded loading.
[0070] Specifically, the programming data of the custom entity is analyzed to see whether it involves loading dependencies and shared resource references, so as to distinguish a type of entity from other custom entities. If the analysis results show that the unknown custom entity has neither loading dependencies nor shared resource references, it is determined that it supports multi-threaded concurrent loading and can be assigned to a type of sub-threads for parallel processing; if any of the above characteristics exists, its loading type is predicted to be conservative, slow processing, and high-accuracy single-thread loading.
[0071] It should be understood that when the file resource security of CAD drawings is the primary consideration, to avoid the risk of data corruption caused by abnormal loading of unknown custom entities, a low-speed and high-precision processing mode under a conservative strategy can be adopted for uncertain entities, that is, the loading type of such unknown custom entities is preset to single-threaded loading, and the security of resource access is ensured through serialized execution. Although some loading efficiency is sacrificed, it can maximize the avoidance of memory conflicts or dependency errors caused by concurrent operations.
[0072] In some embodiments, to reduce the initial configuration workload of users for a certain type of label, the default value of the thread support flag can be set to "support concurrent loading" or directly set the default value of the entity type flag to "type-two entities". At this time, for a large number of type-two entities, users do not need to complete the information of type-one labels, but only need to complete the type-one labels of a small number of type-three entities and type-one entities. At this time, even if there are a large number of unknown custom entities to be loaded in the type-two sub-threads, the entity type prediction mechanism will not be actively triggered.
[0073] Alternatively, the conservativeness can be further enhanced by adjusting the determination parameters of the entity type prediction mechanism. Exemplarily, the preset quantity is set to a first value, and the blank rate of the type-one labels is monitored in real time. When the blank rate is greater than the preset blank rate, it is determined that the type-two labels of a large number of custom entities are not set, and the preset quantity is set to a higher second value, where the first value is less than the second value. That is, the preset quantity is set to a higher threshold, and the analysis is only triggered when extreme tasks accumulate, or a stricter determination criterion is set. For example, in normal scenarios, the first code template library is used, and when the type-two labels of a large number of custom entities are not set or set abnormally, the second code template library is switched to use. The storage quantity of the first code template library is lower than that of the second code template library, so as to streamline the pre-stored code template library, accurately identify loading dependencies and shared resource references, effectively avoid misjudging type-two entities as type-one entities, and prevent the risk of resource conflicts caused by incorrect thread allocation.
[0074] The embodiment of the present application also provides a verification mechanism for type-two labels. By pre-storing type-two label feature data such as entity shape and color, the display result is automatically verified, which can not only capture display anomalies caused by incorrect thread allocation (such as incorrect concurrent loading of type-three entities that need to be processed single-threadedly), but also distinguish special effects deliberately designed by designers from real loading failures. And when an unexpected display deviation is detected, the abnormal entity is automatically transferred to the most reliable main thread for reloading, which is highly applicable to complex drawing scenarios with complex geometric structures or special rendering requirements, and while maintaining high-speed loading, ensures the accurate restoration of key design elements.
[0075] In some embodiments, the custom entity is associated with second-class tags, and the second-class tags store the expected display features of the custom entity. The method includes: based on the expected display features, verifying the display data of the custom entity to determine the matching degree between the display data and the expected display features; if the matching degree is lower than a preset matching degree, allocating the corresponding abnormal custom entity to the main thread for reloading to update the display data of the abnormal custom entity.
[0076] Among them, the second-class tags are used to store the expected display features of the entity. The expected display features can be standardized descriptions such as the geometric shape, color, texture, rendering mode, etc. of the entity, or error prompts that may occur during the entity loading process, such as a cross pattern, an image cracking pattern, a text description, etc. For example, when a designer intentionally uses a non-standard geometric deformation, the expected display feature can be the geometric shape. Another example is that in an artistic creation scenario, when a designer intentionally designs an abnormal resource retrieval, the expected display feature can be a resource retrieval failure prompt.
[0077] Specifically, obtain the display data generated after the custom entity is loaded, that is, the actually presented visual information, and compare it with the expected display features stored in the second-class tags to determine the matching degree between the two, such as the similarity quantization value in attributes such as shape and color. Then, compare the matching degree with the preset matching degree to determine whether the display result meets the expectation. Among them, the preset matching degree is used to identify abnormal display data, and corresponding thresholds can be preset according to the recognition sensitivity and the type of expected display features, such as the geometric shape similarity needs to be greater than 80%, the color similarity needs to be greater than 90%, etc., which are not limited here.
[0078] When the matching degree is lower than the preset matching degree, determine that the custom entity is an abnormal custom entity and allocate it to the main thread for reloading. It should be understood that the main thread ensures the security of resource access through single-threaded processing and can generate display data relatively slowly and with high accuracy. Therefore, the main thread is used to load the custom entity with abnormal display data, which can correct the incorrect loading caused by incorrect thread allocation.
[0079] In some embodiments, the method includes: obtaining the historical display data of the CAD drawing to be loaded, and extracting the expected display data corresponding to each custom entity from the historical display data; extracting the expected display features from the expected display data, and the expected display features include at least one of shape features, color features, or area features.
[0080] Specifically, obtain the historical display data of the CAD drawing to be loaded, that is, the correct display data stored when the CAD drawing to be loaded is successfully loaded, including the complete rendering record of each entity in the historical scene. Extract the expected display data corresponding to each or specific custom entity from the historical display data, and extract the representative expected display features from the expected display data. Thus, using the historical display data as a benchmark, the accuracy and consistency of the display results can be improved.
[0081] Among them, the shape feature refers to the geometric contour or topological structure describing the entity, such as the number of sides of a polygon; the color feature refers to the color attribute of the entity, such as RGB value, hue, saturation, etc.; the area feature refers to the size of the space occupied by the entity in the drawing, such as the area of the filled area, the projected area, etc. By comparing the matching degree between the display data generated by the current loading and the above features, it can be judged whether there is an abnormality, so as to trigger the main thread to reload to correct the deviation.
[0082] It should be understood that the verification mechanism of the second-class label is designed for possible thread allocation errors in the default concurrent loading and entity type prediction process. During the actual loading process, if the preset anomaly detection algorithm of the software detects suspected loading errors such as entity shape distortion and resource retrieval anomaly, it will not immediately transfer them to the main thread for reloading, but first trigger the secondary verification process of the second-class label. This mechanism judges whether the deviation belongs to a real loading error by comparing the current display data with the expected display features recorded in the second-class label. On this basis, the user can pre-configure the expected display features of some key or special custom entities and write them into the second-class label to accurately distinguish special design intentions from loading anomalies. For example, when a designer deliberately uses non-standard rendering or geometric deformation, it may be misjudged as an error and unnecessary intervention may occur. However, through the verification function of the second-class label, not only can the key design elements be accurately restored in complex drawing scenarios, but also the over-processing caused by misjudging deliberate design effects can be effectively avoided, improving the loading efficiency and user experience.
[0083] Please refer to Figure 3 , Figure 3 which is a schematic flowchart of another method for loading custom entities in a CAD drawing provided by an embodiment of the present application. As Figure 3 shown, an embodiment of the present application provides another method for loading custom entities in a CAD drawing, and the method includes S201 to S205.
[0084] S201. Identify custom entities according to a type of label; S203. After identifying three types of entities, allocate the identified three types of entities to the main thread in the storage order in the drawing to form a loading queue; S202. After identifying a type-one entity, a type-two entity, or an unknown custom entity, respectively perform fast loading on the type-one entity, the type-two entity, or the unknown custom entity based on the corresponding type-one sub-thread or type-two sub-thread to obtain the display data of the type-one entity, the type-two entity, or the unknown custom entity. Among them, steps S202 and S203 are executed alternatively according to the recognition result of the custom entity based on the type of label. During this process, there may be abnormal custom entities with abnormal display data, and execute step S204: Insert the abnormal custom entity into the corresponding position in the loading queue according to the storage order of the abnormal custom entity in the drawing.
[0085] After the display data of the type-one entity, the type-two entity, and the unknown custom entity are all loaded, execute step S205. Based on the main thread, sequentially load the three types of entities or the abnormal custom entities according to the loading queue to obtain the display data of the three types of entities or the abnormal custom entities. Finally, complete the loading of the entire CAD drawing.
[0086] It should be understood that the loading tasks of custom entities that support concurrent processing are preferentially loaded, and then the main thread processes the loading tasks of entities that do not support concurrent processing. Before reprocessing abnormal custom entities, they can be inserted into the corresponding position in the loading queue according to their storage positions in the drawing to ensure that the processing order of the three types of entities and abnormal custom entities by the main thread is consistent with the original design logic, and avoid dependency relationships or resource reference errors caused by out-of-order processing, thereby avoiding logical errors or display anomalies in the display data obtained by single-threaded processing.
[0087] In some embodiments, the loading tasks of various custom entities can be executed in batches. For example, multiple custom entities in the drawing are divided into a preset number of batches according to the storage order, and each batch of custom entities is processed in turn. For example, identify the custom entities in the current batch according to a type of label; after identifying three types of entities, allocate the identified three types of entities to the main thread in the storage order in the drawing to form a loading queue; after identifying a type-one entity, a type-two entity, or an unknown custom entity, respectively perform fast loading on the type-one entity, the type-two entity, or the unknown custom entity based on the corresponding type-one sub-thread or type-two sub-thread to obtain the display data of the type-one entity, the type-two entity, or the unknown custom entity in the current batch. During this process, there may be abnormal custom entities with abnormal display data, and insert the abnormal custom entity into the corresponding position in the loading queue according to the storage order of the abnormal custom entity in the drawing.
[0088] After all the display data of a certain type of entities, another type of entities, and unknown custom entities in the current batch are fully loaded, based on the main thread, the entities of the third type or the abnormal custom entities in the current batch are loaded sequentially according to the loading queue to obtain the display data of the entities of the third type or the abnormal custom entities.
[0089] In some embodiments, if the standard CAD entities support multi-threaded concurrent loading, they can also be loaded through multiple sub-threads of the first type.
[0090] In some embodiments, the task allocation of multiple sub-threads of the first type is optimized through a load balancing strategy to give full play to the parallel computing power of multi-core processors. Exemplarily, according to the number of custom entities, the entity complexity, and the load conditions of the current sub-threads of the first type, the entities of the first type that support multi-threaded concurrent loading are dynamically allocated to the idle or low-load sub-threads of the first type to ensure that the task volume among threads is relatively balanced and avoid the situation where some threads are overloaded while others are idle. Thus, the overall loading efficiency is improved by reasonably scheduling the task allocation of multiple sub-threads of the first type.
[0091] Please refer to Figure 4 , Figure 4 which is a schematic block diagram of the structure of a computer device provided by an embodiment of the present application. The computer device can be a terminal device or a server.
[0092] Exemplarily, the above method can be implemented in the form of a computer program, and this computer program can run on a computer device as shown in Figure 4 .
[0093] As shown in Figure 4 , the computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the memory can include a non-volatile storage medium and an internal memory.
[0094] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any method for loading custom entities in CAD drawings.
[0095] The processor is used to provide computing and control capabilities to support the operation of the entire computer device.
[0096] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any method for loading custom entities in CAD drawings.
[0097] The network interface is used for network communication, such as sending assigned tasks, etc.
[0098] It should be understood that the processor can be a Central Processing Unit (CPU), and the processor can also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0099] Among them, in one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps: S101, obtain the CAD drawing to be loaded. The CAD drawing includes a number of custom entities, and the custom entities are associated with a type of label, and the type of label is determined based on the loading type supported by the associated custom entity; S102, create an entity loading thread, and the entity loading thread includes a main thread, a second type of sub-thread, and multiple first type of sub-threads; For each of the custom entities, execute step S103 or S104: S103, allocate the custom entity to the corresponding entity loading thread for loading according to the type of label to generate the display data of the custom entity; S104, if the type of label is recognized as an abnormal state, allocate the corresponding unknown custom entity to the second type of sub-thread for loading to generate the display data of the unknown custom entity.
[0100] In some embodiments, the custom entity includes a first type of entity, and the loading type supported by the first type of entity is multi-threaded concurrent loading; when the processor implements S103, it is also used to implement: allocate the first type of entity to the corresponding first type of sub-thread for loading to generate the display data of the first type of entity.
[0101] In some embodiments, the custom entity includes a second type of entity, and the loading type supported by the second type of entity is concurrent loading; when the processor implements S103, it is also used to implement: allocate the second type of entity to the second type of sub-thread for loading to generate the display data of the second type of entity.
[0102] In some embodiments, the custom entity includes three types of entities, and the loading types supported by the three types of entities are single-threaded loading; when implementing S103, the processor is further configured to: allocate the three types of entities to the main thread for loading to generate display data of the three types of entities.
[0103] In some embodiments, the processor is further configured to: count the number of custom entities to be loaded in the secondary sub-threads; when the number of entities to be loaded is greater than a preset number, analyze the predicted loading type supported by the unknown custom entity according to the programming data of the unknown custom entity; update a first type of label of the unknown custom entity according to the predicted loading type; and execute step S103 according to the updated first type of label to allocate the unknown custom entity to a corresponding entity loading thread for loading.
[0104] In some embodiments, when implementing the analysis of the predicted loading type supported by the unknown custom entity according to the programming data of the unknown custom entity, the processor is further configured to: analyze whether there is a shared resource reference in the unknown custom entity according to the programming data of the unknown custom entity; if not, the predicted loading type supported by the unknown custom entity is multi-threaded concurrent loading; if so, the predicted loading type supported by the unknown custom entity is concurrent loading.
[0105] In some embodiments, the custom entity is associated with a second type of label that stores the expected display characteristics of the custom entity, and the processor is further configured to: verify the display data of the custom entity based on the expected display characteristics to determine the matching degree between the display data and the expected display data; if the matching degree is lower than a preset matching degree, allocate the corresponding abnormal custom entity to the main thread for reloading to update the display data of the abnormal custom entity.
[0106] In some embodiments, the processor is further configured to: obtain the historical display data of the CAD drawing to be loaded, and extract the expected display data corresponding to each custom entity from the historical display data; extract the expected display characteristics from the expected display data, where the expected display characteristics include at least one of shape characteristics, color characteristics, or area characteristics.
[0107] Exemplarily, the processor is configured to run a computer program stored in a memory and is further configured to implement the steps of the method for loading custom entities in a CAD drawing provided in any embodiment of the present application, which will not be elaborated here.
[0108] An embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and the computer program includes program instructions. The processor executes the program instructions to implement the steps of the method for loading a custom entity in a CAD drawing provided in any one of the embodiments of the present application.
[0109] Among them, the computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a SmartMedia Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the computer device.
[0110] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for loading custom entities in CAD drawings, characterized in that, The method includes: S101. Obtain a CAD drawing to be loaded. The CAD drawing includes a number of custom entities, and a type of label is associated with each custom entity. The type of label is determined based on the loading type supported by the associated custom entity. S102. Create an entity loading thread, which includes a main thread, a second type of sub-thread, and multiple first type of sub-threads. For each of the custom entities, perform step S103 or S104: S103. Allocate the custom entity to the corresponding entity loading thread for loading according to the type of label, so as to generate display data of the custom entity. S104. If the type of label is identified as an abnormal state, allocate the corresponding unknown custom entity to the second type of sub-thread for loading, so as to generate display data of the unknown custom entity.
2. The method according to claim 1, wherein The custom entity includes a first type of entity, and the loading type supported by the first type of entity is multi-threaded concurrent loading. S103 includes: Allocate the first type of entity to the corresponding first type of sub-thread for loading, so as to generate display data of the first type of entity.
3. The method according to claim 1, wherein The custom entity includes a second type of entity, and the loading type supported by the second type of entity is concurrent loading. S103 includes: Allocate the second type of entity to the second type of sub-thread for loading, so as to generate display data of the second type of entity.
4. The method according to claim 1, characterized in that, The custom entity includes a third type of entity, and the loading type supported by the third type of entity is single-threaded loading. S103 includes: Allocate the third type of entity to the main thread for loading, so as to generate display data of the third type of entity.
5. The method according to claim 1, wherein The method includes: Count the number of custom entities to be loaded in the second type of sub-thread. When the number of entities to be loaded is greater than a preset number, analyze the predicted loading type supported by the unknown custom entity according to the programming data of the unknown custom entity. Update the type of label of the unknown custom entity according to the predicted loading type. Execute step S103 according to the updated type of label, so as to allocate the unknown custom entity to the corresponding entity loading thread for loading.
6. The method according to claim 5, wherein The analyzing the predicted loading type supported by the unknown custom entity according to the programming data of the unknown custom entity includes: Analyze whether there is a shared resource reference in the unknown custom entity according to the programming data of the unknown custom entity. If not, the predicted loading type supported by the unknown custom entity is multi-threaded concurrent loading. If so, the predicted loading type supported by the unknown custom entity is concurrent loading.
7. The method according to any one of claims 1 to 6, characterized in that, A second type of label is associated with the custom entity, and the second type of label stores the expected display characteristics of the custom entity. The method includes: Based on the expected display characteristics, verify the display data of the custom entity to determine the matching degree between the display data and the expected display characteristics. If the matching degree is lower than a preset matching degree, allocate the corresponding abnormal custom entity to the main thread for reloading to update the display data of the abnormal custom entity.
8. The method according to claim 7, wherein The method includes: Obtain the historical display data of the CAD drawing to be loaded, and extract the expected display data corresponding to each of the custom entities from the historical display data; Extract the expected display features from the expected display data, where the expected display features include at least one of shape features, color features, or area features.
9. A computer device, characterized in that, The device includes: A memory for storing a computer program; A processor for executing the computer program and implementing the method for loading custom entities in a CAD drawing as described in any one of claims 1 to 8 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to implement the method for loading custom entities in a CAD drawing as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Storage method and device of multi-thread data
CN102446117A
Method and equipment for safety protection CAD drawing information
CN112084516A
User-defined component loading method and device, electronic equipment and storage medium
CN112905263A
Custom object loading method, system and equipment and storage medium
CN117519879A
Quick drawing response method and system and storage medium
CN117631930A