A method, apparatus, electronic device, medium, and program product for batch intelligent processing of CAD drawing catalogs.
By parsing CAD drawing filenames using parameter configuration and deep learning models, the system automatically locates and increments the version number to generate a mapping file, solving the problems of low efficiency and high error rate in CAD drawing management and achieving automated batch intelligent processing and version management.
Patent Information
- Application Number
- CN202511197548.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-08-26
AI Technical Summary
In engineering design, there are a large number of CAD drawings with repetitive content. Designers need to manually search and replace them, which leads to low efficiency and high error rate, and there is a lack of batch processing methods.
By combining parameter configuration with a deep learning model, the system parses CAD drawing file names, automatically locates and increments the version number, generates mapping files, supports multiple text replacement modes, and achieves batch intelligent processing of drawing directories.
It improves the efficiency and standardization of drawing management, reduces the error rate, adapts to drawing management scenarios in multiple industries, and enhances the flexibility and automation of version management.
Smart Images

Figure CN120745565B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data processing technology, specifically relating to a method, device, electronic equipment, medium, and program product for batch intelligent processing of CAD drawing catalogs. Background Technology
[0002] Currently, CAD drafting software is being used more and more widely in engineering design. The division of different disciplines within a single project is increasing, and different drawings are used within the same discipline to distinguish and represent the unit project or a single implementation detail drawing. Therefore, the number of drawings for a single project is increasing, and most drawings contain repetitive content, requiring designers to repeatedly create the same information.
[0003] Currently, designers can only perform search and replace operations within the same drawing. There is no method for batch search and replace between drawing file names or different drawings; all operations are done manually. This consumes a lot of time and effort during the design process and has a high error rate. Summary of the Invention
[0004] To address this issue, the present invention provides a method, apparatus, electronic device, medium, and computer program product for batch intelligent processing of CAD drawing catalogs, thereby solving the aforementioned technical problems.
[0005] This invention provides a method for batch intelligent processing of CAD drawing catalogs, comprising the following steps:
[0006] Step S100: Receive parameter configuration file, the parameters including filename separator, version fragment index, version generation type, and version increment rule;
[0007] Step S101: Based on the parameters, parse the original DWG file name. If the parsing is successful, split it into multiple parts according to the delimiter and locate the target version part according to the version fragment index. If the parsing fails, input the original DWG file name into the pre-trained deep learning model and output the target version part.
[0008] Step S102, based on the version generation type, performs an increment calculation of the version number corresponding to the target version part, including: when the version generation type is an ASCII uppercase version, extracting the letter suffix of the target version part and incrementing it in ASCII code order; when the version generation type is a numeric version, extracting the numeric sequence of the target version part and incrementing it while maintaining the original number of digits;
[0009] Step S103: Reorganize the DWG file name based on the incrementing version number to obtain a new file name, copy the original DWG file to a new path and name it with the new file name, and generate a mapping file that records the correspondence between the old and new file names.
[0010] In another aspect, this application also provides a batch intelligent processing device for CAD drawing catalogs, comprising:
[0011] The parameter receiving module is used to receive parameter configuration files, the parameters of which include file name separator, version fragment index, version generation type, and version increment rule;
[0012] The parsing module is used to parse the original DWG file name based on the parameters. If the parsing is successful, it splits the file into multiple parts according to the delimiter and locates the target version part according to the version fragment index. If the parsing fails, the original DWG file name is input into the pre-trained deep learning model, and the target version part is output.
[0013] The version number increment module is used to perform version number increment calculation corresponding to the target version part based on the version generation type, including: when the version generation type is an ASCII uppercase version, extracting the letter suffix of the target version part and incrementing it in ASCII code order; when the version generation type is a numeric version, extracting the numeric sequence of the target version part and incrementing it while maintaining the original number of digits;
[0014] The filename update and save module is used to reorganize the DWG file name based on the incrementing version number to obtain a new file name, copy the original DWG file to a new path and name it with the new file name, and generate a mapping file that records the correspondence between the old and new file names.
[0015] In another aspect, this application also provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a batch intelligent processing method for a CAD drawing catalog as described above.
[0016] In another aspect, this application provides a computer-readable storage medium having stored thereon computer program instructions that can be executed by a processor to implement a batch intelligent processing method for a CAD drawing catalog as described above.
[0017] Another aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements a batch intelligent processing method for a CAD drawing catalog as described above.
[0018] This invention combines parameter configuration with a deep learning model to achieve intelligent batch processing of CAD drawing catalogs, effectively solving the problems of low efficiency and high error rate of manual operation. It supports standardized and non-standardized filename parsing, accurately locates and increments version numbers, and generates mapping files to ensure version traceability. It provides multiple text replacement modes to adapt to different modification needs while preserving the original format. The overall process is automated, significantly improving batch processing efficiency, reducing error rates, and adapting to drawing management scenarios across multiple industries, enhancing the standardization and flexibility of version management. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0020] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0021] Figure 1 This is a flowchart of a batch intelligent processing method for CAD drawing catalogs provided in an embodiment of the present invention.
[0022] Figure 2 This is a flowchart for parsing the original DWG file name, provided as an embodiment of the present invention.
[0023] Figure 3 A schematic diagram of the BiLSTM-CRF model architecture provided in an embodiment of the present invention.
[0024] Figure 4 This is a schematic diagram of the structure of a batch intelligent processing device for CAD drawing catalogs provided in an embodiment of the present invention.
[0025] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] This application proposes a batch intelligent processing method for CAD drawing catalogs. The technical solution of this application will be described in detail below with reference to various embodiments.
[0028] like Figure 1 As shown, this embodiment of the invention discloses a batch intelligent processing method 100 for CAD drawing catalogs, including the following method steps:
[0029] Step S100: Receive parameter configuration file, the parameters including filename separator, version fragment index, version generation type, and version increment rule.
[0030] In some embodiments, for example, the parameter configuration file adopts JSON format and contains four types of parameters, which correspond to the core rules for filename parsing and version number generation, as specifically defined below:
[0031] The filename separator (ver_part_split) is used to split the characters or strings in the original filename to adapt to the splitting methods in different naming rules. For example, "-", such as the separator in "BA04751S1-D0109-01", "_", such as in "Part_v03_RevA", and "v", such as in "Filev1.2", etc.
[0032] The version fragment index (ver_part_index) is used to specify the position of the version fragment to be updated in the array (starting from index 0) after the file name is split and each part is stored as an array.
[0033] For example, after splitting "BA04751S1-D0109-01" by "-", index 1 corresponds to "D0109" and index 2 corresponds to "01". is a non-negative integer, and optionally, it is checked whether it exceeds the length of the array after splitting the filename (to avoid index out-of-bounds errors).
[0034] The version generation type (ver_gen_type) defines the type of the version number and determines the subsequent increment logic. For example, "ASCII_UPPERCASE" (ASCII uppercase version, such as "D0109A" or "RevB") and "NUMBER" (numeric version, such as "-01" or "v03").
[0035] The version increment rule (ver_increment_rule) is used to refine the increment method of the version number, serving as a supplementary rule for the version generation type. For example, for the ASCII uppercase letter version: {"cycle":true} (specifies that "Z" is incremented and then reset to "A", document S1 logic); for the numeric version: {"pad_length":2} (specifies that the numeric increment is padded with 2 zeros, such as "01" → "02", document S1 logic).
[0036] Step S101: Based on the parameters, parse the original DWG file name. If the parsing is successful, split it into multiple parts according to the delimiter and locate the target version part according to the version fragment index. If the parsing fails, input the original DWG file name into the pre-trained deep learning model and output the target version part.
[0037] In some embodiments, when the original filename conforms to a preset naming rule, it is parsed using the parameters (separator, version fragment index) received in step S100, such as... Figure 2 As shown, the specific steps include:
[0038] Step S200 involves filename preprocessing, including removing file extensions and filtering special characters. Removing the file extension specifically involves stripping the ".dwg" suffix from the original DWG filename, retaining only the main naming part (e.g., "BA04751S1-D0109-01.dwg" becomes "BA04751S1-D0109-01"). Filtering special characters involves removing invalid characters (such as spaces and special symbols) from the filename to ensure the splitting logic is not affected.
[0039] Step S201: Split the filename according to the delimiter. Specifically, according to the "filename delimiter (ver_part_split)" parameter, split the preprocessed filename into multiple fragments to form an array. For example, if the filename is "BA04751S1-D0109-01" and the delimiter is "-", then the array obtained after splitting is: ["BA04751S1","D0109","01").
[0040] Step S202, target version partial location, specifically, extracting the corresponding segment from the split array according to the "version fragment index (ver_part_index)" parameter, as the target version part to be updated. The indexing rule uses an array index starting with 0 (i.e., the first element's index is 0, the second is 1, and so on). For example, if the index is 1, the target version part "D0109" is located from the array ["BA04751S1","D0109","01"].
[0041] Step S203: Determine whether the parsing was successful. Specifically, if the length of the split array is greater than the version fragment index (e.g., if the index is 1, the array length must be at least 2), and the located target version part conforms to the basic format of the "version generation type (ver_gen_type)" parameter (e.g., the ASCII uppercase version must contain uppercase letters, and the numeric version must contain a sequence of numbers), then the parsing is considered successful, and the target version part is output; otherwise, proceed to step S204.
[0042] In some embodiments, when parameter-based parsing fails (e.g., delimiter mismatch, index out of bounds, version fragment format abnormality), a pre-trained deep learning model (BiLSTM-CRF) is triggered to perform parsing. Common failure scenarios include:
[0043] After splitting by the delimiter, the length of the array is less than the version fragment index (e.g., the index is 2, but the array contains only 2 elements).
[0044] The located fragment does not match the version generation type (e.g., the type is "ASCII_UPPERCASE", but the fragment has no uppercase letters).
[0045] The file name lacks an explicit separator (e.g., "Electrical Diagram 202305A"), causing the splitting logic to fail.
[0046] Step S204: Input the original DWG file name into the pre-trained deep learning model and output the target version part.
[0047] For example, such as Figure 3 As shown, the pre-trained deep learning model is the sequence labeling model BiLSTM-CRF. The input is the character sequence of the CAD file name, and the output is the version fragment label corresponding to each character (e.g., numeric version, ASCII uppercase version, non-version fragment). The overall structure is divided into an input layer, an embedding layer, a BiLSTM layer, and a CRF layer.
[0048] The input layer converts the original DWG file name into a character sequence that the model can process; the embedding layer receives the character sequence output by the input layer and converts discrete characters into continuous embedding vectors; the BiLSTM layer receives the embedding vectors, processes them through forward LSTM and backward LSTM layers, and fuses the processing results, outputting the probability that each character is predicted as a version fragment label; the CRF layer constrains the label probabilities output by the BiLSTM, and selects the optimal label sequence that conforms to the transition rules from the label probabilities output by the BiLSTM to obtain the target version part.
[0049] Specifically, the BiLSTM-CRF model works collaboratively through a four-layer structure to automatically identify and locate the target version portion in the original DWG filename. The specific implementation process is as follows:
[0050] 1. Input Layer: Character sequence conversion and preprocessing, used to convert the original DWG filename into a character-level sequence that the model can process, removing irrelevant information and standardizing the format. Specifically, this includes:
[0051] File name cleaning: Remove the ".dwg" suffix from file names, for example, "BA04751S1-D0109A.dwg" → "BA04751S1-D0109A", to eliminate interference from file format in parsing;
[0052] Character splitting: Split the cleaned filename into a sequence of individual characters, for example, "D0109A" → ['D','0','1','0','9','A'];
[0053] Length standardization: By padding with zeros (for short filenames) or truncating (for long filenames), all sequences are standardized to a fixed length, such as 30 characters, to meet the model's requirement for consistency in input dimensions.
[0054] Output: A fixed-length character sequence (e.g., ['D','0','1','0','9','A','','',...], where '' is the padding character).
[0055] 2. Embedding Layer: A vector representation of discrete characters, used to convert discrete characters into continuous low-dimensional embedding vectors, capturing the semantic relationships between characters, such as the inherent relationships between the digits "0-9" and the uppercase letters "AZ". Specifically, it includes:
[0056] Character encoding: Assign a unique integer index to all characters appearing in the training set, such as letters, numbers, separators "-", "_", etc. (e.g., "D"→5, "0"→10, "-"→20).
[0057] Vector mapping: Using a trainable embedding matrix, for example, with a dimension of "total number of characters × embedding dimension", the integer index of each character is mapped to a multidimensional embedding vector;
[0058] Semantic learning: During model training, the embedding matrix is dynamically updated through backpropagation, making the vector distance between semantically similar characters closer, such as "8" and "9", "Y" and "Z", providing meaningful input for subsequent feature extraction;
[0059] Output: The sequence of embedding vectors for each character, for example, [vector D, vector 0, vector 1, ..., vector A].
[0060] 3. BiLSTM Layer: Extraction and fusion of contextual features, used to capture the contextual dependencies of character sequences through a bidirectional LSTM network, predicting the probability that each character belongs to a "version segment". Specifically, it includes:
[0061] Forward LSTM processing: Traverse the embedded vector sequence from left to right (e.g., from "D" to "A") to capture the influence of the preceding text on the current character (e.g., the appearance of "D" suggests that the following may be a numeric version).
[0062] Reverse LSTM processing: Traverse the embedding vector sequence from right to left (e.g., from "A" to "D") to capture the influence of the following text on the current character (e.g., the appearance of "A" suggests that the preceding text may be a sequence of numbers).
[0063] Feature fusion: The output vectors of the forward and backward LSTMs are concatenated bit by bit to form a feature vector containing complete contextual information (for example, the feature of the character "0" contains information of "D" on the left and "1" on the right).
[0064] Label probability prediction: The fused feature vector is converted into a label probability distribution through a fully connected layer, such as the probability that the current character belongs to the label "B-NUM", "I-ASCII", or "O". Version fragment labels are annotated in IOB format, such as B-ASCII "ASCII uppercase version start", I-ASCII "ASCII uppercase version middle", B-NUM "numeric version start", I-NUM "numeric version middle", and O "non-version fragment".
[0065] Output: The probability of each character corresponding to each version of the fragment tag, for example, [B-NUM:0.8,I-NUM:0.1,...,O:0.05].
[0066] 4. CRF Layer: This layer filters the optimal label sequence and imposes constraints on the label probabilities output by the BiLSTM, ensuring that the predicted label sequence conforms to logic (e.g., "B-ASCII" can only be followed by "I-ASCII" or "O"), ultimately determining the target version. Specifically, it includes:
[0067] The transition probability matrix is defined as follows: By training, reasonable transition rules between labels are learned (e.g., the probability of B-NUM→I-NUM is high, and the probability of B-ASCII→B-NUM is low), to avoid unreasonable sequences such as "the middle label of the numeric version directly connects to the starting label of the alphabetical version".
[0068] Optimal sequence selection: The Viterbi algorithm is used, which combines the label probability and transition probability matrix output by BiLSTM to select the highest-scoring sequence from all possible label sequences, such as [O,B-NUM,I-NUM,I-NUM,I-NUM,B-ASCII]. The implementation process will be described in detail below and will not be repeated here.
[0069] Target version extraction: Based on the optimal tag sequence, merge consecutive version fragments of the same type (e.g., merge B-NUM to I-NUM into "0109", merge B-ASCII into "A"), and combine with the version generation type (e.g. "ASCII_UPPERCASE") to determine the final target version part (e.g. "A").
[0070] Output: A unique target version part (e.g., "A" or "0109" in "D0109A").
[0071] In some embodiments, the optimal sequence selection process using the Viterbi algorithm is as follows:
[0072] Obtain the probability of each character in the output of the BiLSTM layer corresponding to each label (e.g., B-NUM, I-NUM, B-ASCII, O, etc.), and the label transition probability matrix predefined in the CRF layer (records the probability of transition between different labels, such as the high probability of B-NUM to I-NUM and the low probability of B-ASCII to B-NUM).
[0073] For the first character in the sequence, combine the initial probability of each label (usually uniformly distributed) with the label probability of that character output by BiLSTM to calculate the initial score and record the optimal path corresponding to each label;
[0074] Starting from the second character, for each possible label of each character, iterate through all the labels of the previous character, combine the best score of the previous label, the transition probability between the current label and the previous label, and the label probability of the current character to calculate the cumulative score of the current label, and retain the highest score and the corresponding path.
[0075] After processing all characters, select the label with the highest score for the last character, trace back the path recorded throughout the entire iteration process, and obtain the complete label sequence from the first to the last character (e.g., [O,B-NUM,I-NUM,I-NUM,I-NUM,B-ASCII]). This sequence is the optimal sequence that meets the label transition rule and has the highest matching degree with the BiLSTM prediction result.
[0076] Optionally, in some embodiments, the training process of the BiLSTM-CRF model is briefly described as follows:
[0077] Training data preparation: Collect historical CAD file names (including standardized and non-standardized cases), remove the ".dwg" suffix, and label the version fragments according to the IOB format, such as B-ASCII "ASCII uppercase version start", I-ASCII "ASCII uppercase version middle", B-NUM "Number version start", I-NUM "Number version middle", and O "Non-version fragment".
[0078] Data preprocessing: The labeled filenames are split into character sequences, with uniform length (padding with zeros or truncating), and the characters are mapped to integer indices to form the feature sequence and label sequence for model input.
[0079] Model initialization: Build a network structure including an input layer, an embedding layer, a BiLSTM layer, and a CRF layer, and initialize the embedding matrix, LSTM weights, and CRF transition probability matrix.
[0080] Training iteration: Taking the feature sequence as input and the labeled data as the target, the model parameters are optimized through backpropagation.
[0081] The embedding layer learns the vector representation of characters and captures character relationships;
[0082] The BiLSTM layer optimizes label probability prediction through bidirectional feature extraction;
[0083] The CRF layer learns label transfer rules to improve the rationality of sequence labeling.
[0084] The difference between the predicted label and the true label is calculated using the cross-entropy loss function, and the loss is minimized by gradient descent.
[0085] Model evaluation and optimization: Use the validation set to evaluate the model performance (e.g., accuracy, F1 score), adjust network parameters (e.g., embedding dimension, number of LSTM units) until the model can stably recognize version fragments in different filename formats, and finally save the trained model for actual parsing tasks.
[0086] Step S102, based on the version generation type, performs an incremental calculation of the version number corresponding to the target version part, including: when the version generation type is an ASCII uppercase letter version, extracting the letter suffix of the target version part and incrementing it in ASCII code order; when the version generation type is a numeric version, extracting the numeric sequence of the target version part and incrementing it while maintaining the original number of digits.
[0087] In some embodiments, for example, the “Version Generation Type (ver_gen_type)” parameter is read first to determine whether the type of the current target version part is “ASCII uppercase version” or “numeric version”, and the increment rule of the corresponding type (such as ASCII code order, number of zero padding digits, etc.) is loaded.
[0088] In some embodiments, when the target version portion is an ASCII uppercase version (e.g., a fragment containing the suffix "AZ"), the following steps are performed:
[0089] Letter suffix extraction: Separate the prefix (non-letter part) and letter suffix (uppercase letters only) from the target version portion. For example, scan backward from the end of the target segment and extract consecutive uppercase letters (AZ) as the suffix, with the remaining part as the prefix (usually containing numbers or fixed identifiers). For example, in the target version portion "D0109A", the prefix is "D0109" and the letter suffix is "A"; in the target segment "X300YZ", the prefix is "X300" and the letter suffix is "YZ" (multi-letter suffix).
[0090] Letter increment calculation: For single-letter suffixes, increment according to the ASCII code value. If the current letter is "Z", it is reset to "A". For example, "A" → "B", "Y" → "Z", "Z" → "A". For multi-letter suffixes, increment starting from the last letter. If the last letter is "Z", carry over (similar to decimal carry rules). After the previous letter is incremented, subsequent "Z"s are reset to "A". For example, "AZ" → "BA" (last "Z" → "A", previous "A" → "B"); "ZZ" → "AA" (all "Z"s are reset).
[0091] Target version part reorganization: Replace the original suffix with the incremented letter suffix and recombine it with the prefix to form a new target version part. For example, prefix "D0109" + original suffix "A" → incremented suffix "B" → new target part "D0109B"; prefix "X300" + original suffix "YZ" → incremented suffix "ZA" → new target part "X300ZA".
[0092] In some embodiments, when the target version portion is a digital version (e.g., a fragment containing a digital sequence), the following steps are performed:
[0093] Numeric sequence extraction: Identify the numeric sequence and prefixes (such as separators and fixed identifiers) in the target version part. For example, in the target version part "-01", the prefix is "-" and the numeric sequence is "01"; in the target segment "v03", the prefix is "v" and the numeric sequence is "03"; in the target segment "Rev04", the prefix is "Rev" and the numeric sequence is "04".
[0094] Incremental number calculation: Convert the number sequence (string type) to an integer and add 1 (e.g., "01" → 1 → 2, "03" → 3 → 4); based on the number of digits in the original number sequence (e.g., "01" is 2 digits, "003" is 3 digits), pad the incremented number with zeros to ensure the number of digits remains unchanged. For example, the original number "01" (2 digits) → increments to 2 → pads with zeros to "02"; the original number "003" (3 digits) → increments to 4 → pads with zeros to "004".
[0095] Target version part reorganization: The incremented and padded number sequence replaces the original number part and is recombined with the prefix to form a new target version part. For example, prefix "-" + original number "01" → incremented number "02" → new target part "-02"; prefix "Rev" + original number "04" → incremented number "05" → new target part "Rev05".
[0096] Step S103: Reorganize the DWG file name based on the incrementing version number to obtain a new file name, copy the original DWG file to a new path and name it with the new file name, and generate a mapping file that records the correspondence between the old and new file names.
[0097] In some embodiments, the target version part is replaced with an incremented new version number based on the original filename to generate a complete new filename. Specifically, firstly, the original filename is split and restored by calling the array based on the delimiter split in step S101 (for example, the original filename "BA04751S1-D0109-01" is split into ["BA04751S1","D0109","01"]); if the original parsing relies on a deep learning model (in the case of parsing failure in step S101), the start and end positions of the original version fragment in the filename are located by the label sequence labeled by the model (for example, in "Electrical Diagram 202305A", "202305" is located in the 3rd to 8th characters).
[0098] Next, replace the target version part by replacing the position corresponding to the version fragment index in the split array with the new version number incremented in step S102. For example, "D0109" corresponding to index 1 is replaced with "D0110" after incrementing. If it is a model parsing scenario, directly replace the original version fragment with the incremented version number in the character sequence of the original file name. For example, "202305" is replaced with "202306".
[0099] Finally, concatenate the new filename, re-concatenate the replaced array according to the original delimiter, for example, ["BA04751S1","D0110","01"] → "BA04751S1-D0110-01"; add the file extension ".dwg" to form a complete new filename, for example, "BA04751S1-D0110-01.dwg".
[0100] In some embodiments, regarding file copying and storage in a new path, for example, the original DWG file is copied to a specified new path and named with a new filename to ensure that the physical file and version number are updated in sync.
[0101] Specifically, firstly, the new path configuration and validation includes reading the system's preset new file storage path, such as ". / output / version iteration / ", and allowing users to customize the path through parameters; validating the path's validity by checking if the path exists, and automatically creating it if it does not exist (e.g., by calling the os.makedirs function), and ensuring write permissions are available.
[0102] Next, the file copying process is performed, including calling a file operation interface (such as Python's shutil.copy2) to copy the original file (e.g., ". / source / BA04751S1-D0109-01.dwg") to the new path; during copying, file metadata (e.g., creation time, modification time) is preserved to ensure that the new file is completely identical to the original file in content (only the filename is different).
[0103] Finally, the new file name includes naming the copied file in the new path with the new file name reorganized in step S103 (e.g., ". / output / version iteration / BA04751S1-D0110-01.dwg").
[0104] In some embodiments, regarding the mapping file, for example, a JSON-formatted mapping file is created to record the correspondence between old and new filenames, thereby enabling version tracking.
[0105] Specifically, the mapping file is stored by default in the same directory as the new file path and named "filename_mapping.json" (e.g., ". / output / version iteration / filename_mapping.json"). If it is the first time processing, the JSON structure is initialized as an array ([]). If it already exists, the existing content is read to prepare for incremental updates.
[0106] Create a dictionary object for each processed file, containing `old_filename` (the original filename, including the full path) and `new_filename` (the new filename, including the full path); for example, the JSON format is:
[0107] {
[0108] "old_filename":". / source / BA04751S1-D0109-01.dwg",
[0109] "new_filename":". / output / version iteration / BA04751S1-D0110-01.dwg"
[0110] }
[0111] The newly generated dictionary object is appended to the array of mapped files to ensure that all file relationships processed in the batch are recorded; after writing, the file integrity is verified to avoid loss of mapping relationships due to disk errors.
[0112] In some embodiments, the parameter configuration file further includes text content replacement parameters, which are used to replace text in the DWG file with the new file name. The replacement operation includes: precise replacement mode, which performs full matching and replacement based on the target text and the replacement text; fuzzy replacement mode, which performs partial replacement based on the text fragment containing the target text; and attribute replacement mode, which matches and replaces attribute values in the block attributes according to the attribute prompt information.
[0113] For example, the text replacement parameters are stored in a JSON-formatted configuration file, containing both common and specific parameters for different replacement patterns:
[0114] Common parameters: replacement mode (type, e.g., exact replacement "exact", fuzzy replacement "fuzzy", attribute replacement "attr"), case sensitivity (caseSensitive, value is true / false), operation scope (e.g., single-line text "text", multi-line text "mtext", all "all", this parameter is not required for attribute replacement mode).
[0115] Specific parameters: precise / fuzzy replacement, including target text and replacement text;
[0116] Attribute replacement: Attribute prompt, target value, and replacement value.
[0117] In some embodiments, the exact replacement mode (type="exact") is a full match replacement. Exact replacement is suitable for strictly matching and replacing specific text (e.g., standardized terms, fixed identifiers). The exact replacement mode performs a full match replacement between the target text and the replacement text. Specifically, the replacement parameters include the target text, the replacement text, the range, and case sensitivity. Text objects are filtered based on the range, all entities matching the range are traversed, and the target text is replaced with the replacement text based on the case sensitivity.
[0118] Specifically, the precise replacement process includes:
[0119] Iterate through text objects of a specified type in a DWG file based on the scope parameter: scope="text": only process single-line text (TEXT entity); scope="mtext": only process multi-line text (MTEXT entity); scope="all": process both single-line and multi-line text.
[0120] Perform an exact match on the content of each text object (text.content or mtext.text): if caseSensitive=true: only match content that is exactly the same as the target character sequence (e.g., "ABC" only matches "ABC", not "abc"); if caseSensitive=false: ignore case matching (e.g., "ABC" can match "abc" and "AbC").
[0121] Replace all successfully matched text content with "replacement" while preserving the original text format: font (e.g., "SimSun" or "Arial"), font size (e.g., 3.5mm), color, rotation angle, and other attributes remain unchanged; for example, if the single-line text "Design Unit: Company A" (SimSun, 3mm) matches target="Design Unit: Company A", it will be replaced with "Design Unit: Company B" (still SimSun, 3mm).
[0122] In some embodiments, the fuzzy replacement mode (type="fuzzy") replaces fragments containing target text. Fuzzy replacement is suitable for batch correction of text containing specific keywords (e.g., uniformly changing "old standard" to "new standard"). The fuzzy replacement mode performs partial replacement based on text fragments containing target text. Specifically, the replacement parameters include target text, replacement text, range, and case sensitivity. The target text is preprocessed to form a matching pattern. Text objects are filtered based on the range, all entities matching the range are traversed, and the target text is replaced with the replacement text based on the case sensitivity and the matching pattern.
[0123] Specifically, wildcards are added before and after target to form a matching rule that "contains target text" (e.g., target="project" → matching pattern is "*project*").
[0124] Filter text objects by the scope parameter, extract the content and check if it contains the target: if caseSensitive=true: only match fragments that contain the target and are case-sensitive (e.g., "Project A" matches "New Project A Planning").
[0125] If caseSensitive=false: Matches fragments containing target (ignoring case) (e.g., "Project" matches "newproject").
[0126] Replace only the part of the text that matches the target, leaving the rest of the content unchanged and preserving the format: for example, in the multi-line text "Project Planning Manual", target="Project" → replace with replacement="New Project" → the result is "New Project Planning Manual";
[0127] If the target appears multiple times in the text (e.g., "Project 1 and Project 2"), then all instances will be replaced (e.g., "New Project 1 and New Project 2").
[0128] In some embodiments, the attribute replacement mode (type="attr") is a precise replacement mode for block attributes. Attribute replacement is used to modify the value of a specific attribute in a block (e.g., drawing number, design date). In the attribute replacement mode, attribute values are matched and replaced according to attribute hint information in the block attributes. Specifically, the replacement parameters include attribute hint information, target value, replacement value, range, and case sensitivity. All blocks in the CAD file are traversed, attribute objects are located based on the attribute hint information, and it is determined whether the current value of the attribute object matches the target value. The current value of the matching attribute object is then updated to the replacement value.
[0129] Specifically, it iterates through all blocks in the DWG file and matches the attribute definitions using the prompt parameter (e.g., prompt="drawing name" → locates the attribute whose prompt message is "drawing name").
[0130] Check if the current value of the located attribute (attribute.value) matches the target. The matching rules are the same as exact replacement: caseSensitive=true: strict matching (for example, target="site plan V1" only matches the attribute with the value "site plan V1"); caseSensitive=false: ignore case matching (for example, target="v1" can match "V1" "v1").
[0131] Replace the successfully matched attribute value with a replacement, keeping the attribute's position and style unchanged in the block: for example, if the current value of the "Drawing Number" attribute of a block is "D0109", it will be replaced with "D0110", and the insertion point (X, Y coordinates) and alignment (e.g., centering) of the attribute will remain unchanged.
[0132] Figure 4 A batch intelligent processing device 400 for CAD drawing catalogs is shown. This device embodiment is similar to... Figure 1 Corresponding to the illustrated method embodiments, this device can be specifically applied to various electronic devices. Specifically, it includes:
[0133] The parameter receiving module 401 is used to receive a parameter configuration file, wherein the parameters include file name separator, version fragment index, version generation type, and version increment rule;
[0134] The parsing module 402 is used to parse the original DWG file name based on the parameters. If the parsing is successful, it splits the file into multiple parts according to the delimiter and locates the target version part according to the version fragment index. If the parsing fails, the original DWG file name is input into the pre-trained deep learning model and the target version part is output.
[0135] The version number increment module 403 is used to perform version number increment calculation corresponding to the target version part based on the version generation type, including: when the version generation type is an ASCII uppercase letter version, extracting the letter suffix of the target version part and incrementing it in ASCII code order; when the version generation type is a numeric version, extracting the numeric sequence of the target version part and incrementing it while maintaining the original number of digits;
[0136] The filename update and save module 404 is used to reorganize the DWG file name based on the incrementing version number to obtain a new file name, copy the original DWG file to a new path and name it with the new file name, and generate a mapping file that records the correspondence between the old and new file names.
[0137] Based on the same inventive concept, this application also provides an electronic device. The method corresponding to the electronic device can be the method in the foregoing embodiments, and its problem-solving principle is similar to that method. The electronic device provided in this application includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the methods and / or technical solutions of the foregoing embodiments of this application.
[0138] The electronic device can be a user device, or a device formed by integrating user devices and network devices through a network, or it can be an application running on the aforementioned devices. The user device includes, but is not limited to, various terminal devices such as computers, mobile phones, tablets, smartwatches, and smart bands. The network device includes, but is not limited to, network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets, and can be used to implement some processing functions when setting an alarm clock. Here, the cloud consists of a large number of hosts or network servers based on cloud computing. Cloud computing is a type of distributed computing, consisting of a virtual computer composed of a group of loosely coupled computer sets.
[0139] Figure 5 The diagram illustrates the structure of an apparatus suitable for implementing the methods and / or technical solutions in the embodiments of this application. The apparatus 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes based on a program stored in a read-only memory (ROM) 502 or a program loaded from a storage portion 508 into a random access memory (RAM) 503. The RAM 503 also stores various programs and data required for system operation. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0140] The following components are connected to I / O interface 505: input section 506 including keyboard, mouse, touch screen, microphone, infrared sensor, etc.; output section 507 including cathode ray tube (CRT), liquid crystal display (LCD), LED display, OLED display, etc., and speakers, etc.; storage section 508 including one or more computer-readable media such as hard disk, optical disk, magnetic disk, semiconductor memory, etc.; and communication section 509 including network interface card such as LAN (local area network) card, modem, etc. Communication section 509 performs communication processing via a network such as the Internet.
[0141] In particular, the methods and / or embodiments in this application can be implemented as computer software programs. For example, the embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. When the computer program is executed by the central processing unit (CPU) 501, it performs the functions defined in the methods of this application.
[0142] Another embodiment of this application provides a computer-readable storage medium having computer program instructions stored thereon, which can be executed by a processor to implement the methods and / or technical solutions of any one or more embodiments of this application described above.
[0143] Specifically, this embodiment may employ any combination of one or more computer-readable media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0144] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0145] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0146] The flowcharts or block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of devices, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-specific system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0147] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a device claim may also be implemented by a single unit or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any specific order.
Claims
1. A method for batch intelligent processing of CAD drawing catalogs, characterized in that, Includes the following steps: Step S100: Receive parameter configuration file, the parameters including filename separator, version fragment index, version generation type, and version increment rule; Step S101: Based on the parameters, parse the original DWG file name. If the parsing is successful, split it into multiple parts according to the delimiter and locate the target version part according to the version fragment index. If the parsing fails, input the original DWG file name into the pre-trained deep learning model and output the target version part. Step S102, based on the version generation type, performs an increment calculation of the version number corresponding to the target version part, including: when the version generation type is an ASCII uppercase version, extracting the letter suffix of the target version part and incrementing it in ASCII code order; when the version generation type is a numeric version, extracting the numeric sequence of the target version part and incrementing it while maintaining the original number of digits; Step S103: Reorganize the DWG file name based on the incrementing version number to obtain a new file name, copy the original DWG file to a new path and name it with the new file name, and generate a mapping file that records the correspondence between the old and new file names; The deep learning model is specifically a BiLSTM-CRF model, which includes an input layer, an embedding layer, a BiLSTM layer, and a CRF layer. The input layer converts the original DWG file name into a character sequence that the model can process. The embedding layer receives the character sequence output by the input layer and converts the discrete characters into continuous embedding vectors; The BiLSTM layer receives the embedding vector, processes the embedding vector through a forward LSTM layer and a backward LSTM layer, and fuses the processing results. The output layer outputs the probability of predicting each character as a version fragment tag. The CRF layer constrains the label probabilities output by the BiLSTM, and selects the optimal label sequence that conforms to the transition rules from the label probabilities output by the BiLSTM to obtain the target version part.
2. The method for batch intelligent processing of CAD drawing catalogs according to claim 1, characterized in that, The parameter configuration file also includes text content replacement parameters. Based on the text replacement parameters, the text in the DWG file with the new file name is replaced. The replacement operation includes: precise replacement mode, which performs full matching and replacement based on the target text and the replacement text; fuzzy replacement mode, which performs partial replacement based on the text fragment containing the target text; and attribute replacement mode, which matches and replaces attribute values in the block attributes according to the attribute prompt information.
3. The method for batch intelligent processing of CAD drawing catalogs according to claim 2, characterized in that, The precise replacement mode performs a full match and replacement based on the target text and the replacement text. Specifically, the replacement parameters include the target text, the replacement text, the range, and the case sensitivity. Based on the range, text objects are filtered, all entities that match the range are traversed, and the target text is replaced with the replacement text based on the case sensitivity.
4. The method for batch intelligent processing of CAD drawing catalogs according to claim 2, characterized in that, The fuzzy replacement mode performs partial replacement based on text fragments containing the target text. Specifically, the replacement parameters include the target text, the replacement text, the range, and the case sensitivity. The target text is preprocessed to form a matching pattern. Text objects are filtered based on the range. All entities that match the range are traversed. The target text is replaced with the replacement text based on the case sensitivity and the matching pattern.
5. The method for batch intelligent processing of CAD drawing catalogs according to claim 2, characterized in that, The attribute replacement mode matches and replaces attribute values in the block attributes according to the attribute prompt information. Specifically, the replacement parameters include attribute prompt information, target value, replacement value, range, and case sensitivity. All blocks in the CAD file are traversed, the attribute object is located based on the attribute prompt information, it is determined whether the current value of the attribute object matches the target value, and the current value of the matching attribute object is updated to the replacement value.
6. A batch intelligent processing device for CAD drawing catalogs, characterized in that, include: The parameter receiving module is used to receive parameter configuration files, the parameters of which include file name separator, version fragment index, version generation type, and version increment rule; The parsing module is used to parse the original DWG file name based on the parameters. If the parsing is successful, it splits the file into multiple parts according to the delimiter and locates the target version part according to the version fragment index. If the parsing fails, the original DWG file name is input into the pre-trained deep learning model, and the target version part is output. The version number increment module is used to perform version number increment calculation corresponding to the target version part based on the version generation type, including: when the version generation type is an ASCII uppercase version, extracting the letter suffix of the target version part and incrementing it in ASCII code order; when the version generation type is a numeric version, extracting the numeric sequence of the target version part and incrementing it while maintaining the original number of digits; The filename update and save module is used to reorganize the DWG file name based on the incrementing version number to obtain a new file name, copy the original DWG file to a new path and name it with the new file name, and generate a mapping file that records the correspondence between the old and new file names; The deep learning model is specifically a BiLSTM-CRF model, which includes an input layer, an embedding layer, a BiLSTM layer, and a CRF layer. The input layer converts the original DWG file name into a character sequence that the model can process. The embedding layer receives the character sequence output by the input layer and converts the discrete characters into continuous embedding vectors; The BiLSTM layer receives the embedding vector, processes the embedding vector through a forward LSTM layer and a backward LSTM layer, and fuses the processing results. The output layer outputs the probability of predicting each character as a version fragment tag. The CRF layer constrains the label probabilities output by the BiLSTM, and selects the optimal label sequence that conforms to the transition rules from the label probabilities output by the BiLSTM to obtain the target version part.
7. An electronic device, characterized in that, include: At least one processor; and a memory communicatively connected to the processor; wherein, The memory stores instructions that can be executed by the processor to enable the processor to perform the method of any one of claims 1-5.
8. A computer-readable medium having computer program instructions stored thereon, characterized in that, The computer program instructions can be executed by a processor to implement the method as described in any one of claims 1-5.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Chinese named entity recognition system, method and equipment based on multi-scale features and medium
CN120409476A
Identifying entities in electronic medical records
US10740561B1