A bill of materials based UG Open Grip batch attribute system and method
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2026-08-11
AI Technical Summary
[0002]日常工作中,存在多种版本的UG并行工作,我们加工的零件包含的属性通常超过10种,在早期的UG版本日常需要添加/编辑属性时需要手动点开多层菜单,添加/找到对应的属性,再点击确定键并保存,手续繁杂,填写麻烦
[0027] The implementation method of this invention is flexible, relatively simple, clear in process, efficient in batch processing, and has a clear code structure that is easy to adjust. It reduces the working time and labor intensity of designers. At the same time, this method can be completed by any person with simple training, which facilitates the maintenance of UG part models in the later stage.
Smart Images

Figure BDA0004638098410000071 
Figure BDA0004638098410000081
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of batch processing attributes, and specifically relates to a UGOpenGrip batch processing attribute system and method based on a detail table. Background Technology
[0002] In daily work, multiple versions of UG are often used concurrently. The parts we process typically contain more than 10 attributes. In earlier versions of UG, adding / editing attributes required manually opening multiple menus, finding the corresponding attribute, clicking the OK button, and saving—a cumbersome and time-consuming process. Newer versions of UG allow entering various attributes into tables, but it still requires manually opening UG to add them. Whether filling in directly or copying and pasting, searching for the corresponding content in the attributes of various filenames is still a tedious task for designers.
[0003] Whether in the early, middle or late stages of design, being able to automatically fill in / delete / edit part attributes in batches is a labor-saving and easy task for designers. Designers only need to maintain the parts list. Summary of the Invention
[0004] The technical problem solved by this application is to overcome the shortcomings of the prior art and provide a batch processing attribute system and method based on a detail table for UGOpenGrip, which can quickly realize batch processing of UG attribute-related operations.
[0005] The technical solution provided in this application is as follows:
[0006] Firstly, a UGOpenGrip batch processing attribute system based on a detail table is provided, including:
[0007] The detail table generation module generates a detail table with m rows and n columns based on the part name and attributes. The m rows represent m parts, and the n columns include part name, string variable name and multiple attributes, i≤n-2;
[0008] The declaration module declares the variable dimension, variable number i, and character length in the format of string variables. The variable dimension is 1 or 2, and the variable number i corresponds to the number of attributes to be written.
[0009] The initialization module assigns values to string variables containing character length and variable dimensions based on the details table, thus obtaining the initialized string variables;
[0010] The execution module opens the UG part corresponding to the part name in a certain row of the m-row n-column detail table array, performs attribute processing on the part using the initialized string variable, saves the part with the attribute processing, and closes the part; repeats m times, that is, writes the m*i attribute values contained in the m-row n-column array at once;
[0011] The detail table generation module, declaration module, initialization module, and execution module are based on the UG OpenGrip scripting language that comes with UG to generate the program. By running the program, the corresponding UG component attribute actions are executed on the m rows and n columns array contents at once.
[0012] Optionally, the attribute is selected from drawing code, material, specification, material specification, material specification standard, material grade, material technical conditions, production type, heat treatment, surface treatment, surface roughness, or remarks.
[0013] Optionally, the variable dimension is determined as follows: when the above attribute i > 1 in the n columns of the m-row n-column array, the variable dimension is 2; when i ≤ 1, the variable dimension is 1.
[0014] Optionally, the action of processing the attribute of the initialized string variable on the part includes: writing, deleting and / or replacing the attribute of the initialized string variable on the part.
[0015] Optionally, the stages of the schedule generation module, declaration module, initialization module, and execution module generating programs based on the UG OpenGrip scripting language included with UG can be implemented on a computer without UG software installed.
[0016] Optionally, the detailed list generation module, declaration module, initialization module, and execution module generate a program based on the UG OpenGrip scripting language that comes with UG, which is then used for the processing and execution stage. This only requires that the computer used for the processing and execution stage has UG software that can open the parts installed.
[0017] Optionally, the schedule format is Excel, CSV, and / or Word; the schedule generation module, declaration module, initialization module, and execution module are based on the UG OpenGrip scripting language provided by UG and the processing methods include Word document processing, Excel table processing, and / or Python programming processing.
[0018] Secondly, a UGOpenGrip batch processing attribute method based on a detail table is provided, using any one of the 6 above-described UGOpenGrip batch processing attribute systems based on a detail table, including:
[0019] S1: Generate a detailed table with m rows and n columns based on the component names and attributes of the parts. The m rows represent m parts, and the n columns include component names, string variable names, and multiple attributes.
[0020] S2: Declare the variable dimension, number of variables i, and character length in the format of a string variable;
[0021] S3: Assign values to string variables containing character length and variable dimensions based on the details table to obtain the initialized string variables;
[0022] S4: Execute, open the UG part corresponding to the part name in a certain column of the m-row n-column detail table array, perform attribute processing on the part with the initialized string variable, save the part to disk and close the part;
[0023] S5: Repeat step S4 m times to obtain the m*i attribute values contained in the m-row-n-column array written at once.
[0024] Optionally, in step S4, any attribute in the m-row, n-column detail table array is batch-processed during execution.
[0025] Optionally, in step S4, the m-row, n-column detail table array can be divided into multiple batches, and different attribute processing can be performed in each batch in order.
[0026] In summary, this application includes at least the following beneficial technical effects:
[0027] The implementation method of this invention is flexible, relatively simple, clear in process, efficient in batch processing, and has a clear code structure that is easy to adjust. It reduces the working time and labor intensity of designers. At the same time, this method can be completed by any person with simple training, which facilitates the maintenance of UG part models in the later stage. Detailed Implementation
[0028] This application discloses a UGOpenGrip batch attribute processing system based on a detail table, which can quickly implement UG attribute-related operations. The underlying logic of the batch attribute processing method is the UGOpenGrip scripting language built into UG itself. The implementation method of batch processing is not limited to Python programming, Excel software, or Word software. The basic detail table can be an Excel file, a CSV file, etc. This invention follows the basic principle of a framework, matching business logic with scripts, and can be changed at any time according to needs, which can significantly reduce the requirements for personnel coding skills.
[0029] A batch attribute system for UGOpenGrip based on a detail table, comprising:
[0030] The detail table generation module generates a detail table with m rows and n columns based on the part name and attributes. The m rows represent m parts, and the n columns include part name, string variable name and multiple attributes, i≤n-2;
[0031] The declaration module declares the variable dimension, variable number i, and character length in the format of string variables. The variable dimension is 1 or 2, and the variable number i corresponds to the number of attributes to be written.
[0032] The initialization module assigns values to string variables containing character length and variable dimensions based on the details table, thus obtaining the initialized string variables;
[0033] The execution module opens the UG part corresponding to the part name in a certain row of the m-row n-column detail table array, performs attribute processing on the part using the initialized string variable, saves the part with the attribute processing, and closes the part; repeats m times, that is, writes the m*i attribute values contained in the m-row n-column array at once;
[0034] The detail table generation module, declaration module, initialization module, and execution module are based on the UG OpenGrip scripting language that comes with UG to generate the program. By running the program, the corresponding UG component attribute actions are executed on the m rows and n columns array contents at once.
[0035] This invention also provides a batch processing attribute method, the method comprising:
[0036] Based on a detailed table (i.e., an array of m rows and n columns), a UG OpenGrip scripting language program is generated according to preset rules. By running the program, the corresponding UG component attribute actions are executed on the contents of the m rows and n columns array in one go.
[0037] The array consists of m rows and n columns. Each row contains the filename of the part and several attributes, such as drawing code, material, specifications, material specifications, material specification standards, material grade, material technical conditions, production type, heat treatment, surface treatment, surface roughness, and remarks. Each of the n columns corresponds to the specific content of the above attributes.
[0038] The preset rule consists of three parts: declaration, initialization, and execution. The declaration, initialization, and the content of the n-column array are interconnected. The declaration is a string variable containing the variable dimension, variable number i, and character length. In this method, the dimension is 1 or 2. When m > 1 in the m x n array, the dimension is 2. The variable number i corresponds to the number of attributes to be written, i ≤ n - 2. The initialization part assigns values to the string variable containing the character length and variable dimension, and the content is the content of the corresponding m x n array. The execution part opens the UG part corresponding to the filename in a certain column of the m x n array, writes the initialized string variable to the part, saves the part, and closes the part.
[0039] The attribute batch processing method repeats m times according to preset rules, thus obtaining m*i attribute values contained in an m-row n-column array at once.
[0040] The method only requires that UG software capable of opening parts be installed on the computer during the processing stage. Optionally, the version of UG software is not limited, including but not limited to UG8.0 and UG12.0.
[0041] Optionally, the rule generation stage of the method can be implemented on a computer without UG software installed;
[0042] Optionally, the component attribute actions of the method include, but are not limited to, execution methods such as writing attributes, deleting attributes, and replacing attributes;
[0043] Optionally, the method can batch process any attribute in an m-row n-column array;
[0044] Optionally, the method can perform attribute action batch processing for UG parts under different directories;
[0045] Optionally, the batch processing methods are arranged into multiple batches, and the execution order of the attribute methods in each batch is determined, including: filtering and arranging the m-row n-column array into multiple batches, and executing different attribute methods in each batch in batch order;
[0046] Optionally, the method is based on multiple detail table formats, including but not limited to Excel and CSV;
[0047] Optionally, the method rule generation program can have multiple processing methods, including but not limited to Word document processing, Excel spreadsheet processing, Python programming processing, etc.
[0048] The implementation method for writing UGOpenGrip part attributes is as follows:
[0049] When executing the steps, during the action of writing the initialized string variable to the part's attributes:
[0050] If you write several attributes in multiple component files, that is, multiple lines of declaration and assignment statements, and then repeat the statements thereafter, here's an example:
[0051] 1. Part One
[0052] 2. STRING / String variable m(2,i,30)
[0053] 3.DATA / string variable m, 'attribute i', attribute i
[0054] 4. Part Two
[0055] 5. FETCH / PART, Part Name m
[0056] 6. ASATT / PART, string variable m
[0057] 7. FILE / PART
[0058] 8. FTERM / PART
[0059] 9. Part Three
[0060] 10. HALT
[0061] The string array names, attributes, and component codes corresponding to the components in the example are shown in the table below, with further extensions:
[0062] Table 1. Relationship between component and string array names and attribute values
[0063] A B C D I Component Name String variable name Attribute 1 Attribute 2 attribute i 1 Component Name 1 String variable name 1 Attribute 11 Attribute 21 Attribute i1 2 Part Name 2 String variable name 2 Attribute 12 Attribute 22 attribute i2 ... ... ... ... ... ... m Component name m string variable name m Attribute 1m Attribute 2m attribute im
[0064] The method for deleting a single part attribute in UGOpenGrip is as follows:
[0065] When executing the steps, if the initialized string variable is used to delete the attribute of the part:
[0066] The following is an example of deleting part attributes using UGOpenGrip:
[0067] FETCH / PART, Part Name m
[0068] DLATT / PART, attribute i
[0069] FILE / PART
[0070] FTERM / PART
[0071] Read each line of Table 1 one by one, generate the corresponding statement for each line, merge the statements and add HALT to get the final batch import attribute program.
[0072] Example 1: Generating a UGOpenGrip scripting language program based on a bill of quantities: Using Python programming
[0073] Python reads Table 1 line by line according to the format of Part 1 and Part 2, generating the corresponding Part 1 and Part 2 statements for each line. The two parts are then merged and finally the third part HALT is added to obtain the final batch import attribute program.
[0074] 1) Create new documents for Part 1 and Part 2; these will serve as template files for subsequent procedures. Part 3 will be a single file containing only the sentence "HALT," intended for use when merging files later.
[0075] The first part of the content is as follows, and the file name is Part 1.doc
[0076] STRING / {{string variable m}}(2,i,30)
[0077] DATA / {{string variable m}},'attribute i',{{attribute i}}
[0078] The second part is as follows, and the file name is Part Two.doc
[0079] FETCH / PART, {{part name m}}
[0080] ASATT / PART, {{string variable m}}
[0081] FILE / PART
[0082] FTERM / PART
[0083] 2) Create a file list F1 for Part 1 and a file list F2 for Part 2. These are collections of files subsequently generated for Part 1 and Part 2, with the templates being Part 1.doc and Part 2.doc from number 1). The statements are as follows:
[0084] F1 = DocxTemplate('Part 1.doc')
[0085] F2 = DocxTemplate('Part Two.doc')
[0086] 3) Obtain information for each column from the details table and create a list for each column.
[0087] grade = pd.read_excel(zpath + 'Details Table')
[0088] The following is a list of component names, string variables, and attributes. Its purpose is to allow the program to assign the corresponding contents of the list to the contents of the curly braces {{}} in the first and second parts of the sequence number 1).
[0089] Component name = grade['component name'] (corresponding to the title in Table 1)
[0090] The string variable is set to grade['string variable'] (corresponding to the heading in Table 1).
[0091] Attribute m = grade['attribute m'] (corresponding to the title in Table 1)
[0092] 4) Traverse the details table, retrieve the contents of the list in sequence 3), and assign values to the contents of {{}} in the template file shown in sequence 1).
[0093]
[0094]
[0095] 5) Start the Word object application
[0096] word=win32.gencache.EnsureDispatch('Word.Application')
[0097] 6) Create a new merged document
[0098] 7) Merging documents
[0099] 8) Retrieve the contents of the merged document
[0100] doc=output.Range(output.Content.Start,output.Content.End)
[0101] output.SaveAs('grx') # Save the output.
[0102] output.Close()
[0103] After generating the .grs file directly, it is compiled and linked into .grx by UGGrip. Then, open UG and press CTRL+G to open the corresponding .grx file to complete the run. After testing, the debugging and running were successful.
[0104] Example 2: Generating UGOpenGrip scripting language programs based on detail tables: Creating batch processing programs using Excel.
[0105] Batch grouping can also be achieved using Excel without Python. The function in a single spreadsheet is as follows:
[0106] 1) The declaration section is as follows, where CHAR(10) is a newline character.
[0107] ="STRING / "&string variable name m&"(2,i,130)"&CHAR(10)&"DATA / "&A3&",'attribute 1','"&attribute 1m&"',$"&CHAR(10)&"attribute 2','"&attribute 2m&"',$"&CHAR(10)&"'attribute 3','"&attribute 3m&"',$"&CHAR(10)&"'attribute i','"&attribute im&"'"
[0108] 2) The following execution statement part
[0109] ="FETCH / PART,'"&B3&"'"&CHAR(10)&"ASATT / PART,"&Part name m&CHAR(10)&"FILE / PART"&CHAR(10)&"FTERM / PART"
[0110] 3) HALT
[0111] Copy and paste the contents of 1, 2, and 3 into a blank Notepad and save it as a grs file. Then compile and link it into a grx file using UGGrip. Set the starting position in UG to the folder location of the part to be modified. Then open UG and press CTRL+G to open the corresponding grx file to complete the process. After testing, the debugging and running were successful.
[0112] Example 3: Generating UGOpenGrip scripting language programs based on detail tables: Using word fields to create batch processing programs.
[0113] The above methods can directly merge documents using Word fields. Alternatively, you can use the includetext field (CTRL+F9), merge the documents, and then press SHIFT+F9 to complete the process. The specific steps are as follows:
[0114] Part One
[0115] STRING / <<string variable name m>>(2,i,130)
[0116] DATA / <<string variable name m>>,'attribute i','<<attribute im>>',$
[0117] 'attribute j', '<<attribute jm>>'
[0118] In the "Mail" menu, under the "Start Mail Merge" section, select "Choose Recipients" and then "Use Existing List." Choose your data source and locate the Excel spreadsheet you want to link. The spreadsheet should not be open at this point. Next, click "Insert Merge Field" in the "Write and Insert Field" section. Position the text according to the corresponding column name in the spreadsheet. Note that the array symbols in the list must follow the rules and cannot be numbers. Also, avoid using excessively long characters in the spreadsheet. Click the "Preview Results" section to view the results. In the "Finish" section, under "Complete and Merge," select "Single Edit Document." Press CTRL+A to copy the Word content and paste it into Notepad.
[0119] Part Two
[0120] FETCH / PART,'<<part name m>>'
[0121] ASATT / PART, <<string variable name m>>
[0122] FILE / PART
[0123] FTERM / PART
[0124] In the "Mail" menu, under the "Start Mail Merge" section, select "Select Recipients" and then "Use Existing List." Choose your data source and locate the Excel spreadsheet you want to link; the spreadsheet should not be open at this point. Next, click "Insert Merge Field" in the "Write and Insert Field" section, placing the text in the corresponding column name in the spreadsheet. Click the "Preview Results" section to view the results. In the "Finish" section, under "Complete and Merge," select "Single Edit Document." Press CTRL+A to copy the Word content and paste it into Notepad. Merge the two parts and finally add the third part, "HALT," to obtain the final batch import property program.
[0125] The program in this notepad is saved as grs, compiled and linked into grx by UGGrip, and the starting position in UG is set to the folder location of the part to be modified. Then, open UG and press CTRL+G to open the corresponding grx file to run it. After testing, it was successfully debugged and ran.
[0126] The present application has been described in detail above with reference to specific embodiments and exemplary examples; however, these descriptions should not be construed as limiting the present application. Those skilled in the art will understand that various equivalent substitutions, modifications, or improvements can be made to the technical solutions and implementation methods of the present application without departing from the spirit and scope of the present application, and all such modifications and improvements fall within the scope of the present application. The scope of protection of the present application is determined by the appended claims.
[0127] The contents not described in detail in this application specification are common knowledge to those skilled in the art.
Claims
1. A UGOpenGrip batch processing attribute system based on a detail table, characterized in that, include: The detail table generation module generates a detail table with m rows and n columns based on the part name and attributes. The m rows represent m parts, and the n columns include part name, string variable name and multiple attributes, i≤n-2; The declaration module declares the variable dimension, variable number i, and character length in the format of string variables. The variable dimension is 1 or 2, and the variable number i corresponds to the number of attributes to be written. The initialization module assigns values to string variables containing character length and variable dimensions based on the details table, thus obtaining the initialized string variables; The execution module opens the UG part corresponding to the part name in a certain row of the m-row n-column detail table array, performs attribute processing on the part using the initialized string variable, saves the part with the attribute processing, and closes the part; repeats m times, that is, writes the m*i attribute values contained in the m-row n-column array at once; The detail table generation module, declaration module, initialization module, and execution module are based on the UG OpenGrip scripting language that comes with UG to generate the program. By running the program, the corresponding UG component attribute actions are executed on the m rows and n columns array contents at once.
2. The UGOpenGrip batch processing attribute system based on a detail table according to claim 1, characterized in that: The attributes are selected from drawing code, material, specification, material specification, material specification standard, material grade, material technical conditions, production type, heat treatment, surface treatment, surface roughness, or remarks.
3. The UGOpenGrip batch processing attribute system based on a detail table according to claim 1, characterized in that: The method for determining the variable dimension is as follows: when the above attribute i > 1 is contained in n columns of an m-row n-column array, the variable dimension is 2; when i ≤ 1, the variable dimension is 1.
4. The UGOpenGrip batch processing attribute system based on a detail table according to claim 1, characterized in that: The action of processing the attributes of the part using the initialized string variable includes: writing, deleting and / or replacing the attributes of the part using the initialized string variable.
5. The UGOpenGrip batch processing attribute system based on a detail table according to claim 1, characterized in that: The stages of generating the detailed list module, declaration module, initialization module, and execution module based on the UG OpenGrip scripting language included with UG can be implemented on a computer without UG software installed.
6. The UGOpenGrip batch processing attribute system based on a detail table according to claim 1, characterized in that: The detailed list generation module, declaration module, initialization module, and execution module generate the program based on the UG OpenGrip scripting language that comes with UG, which is then used for the processing and execution stage. Only UG software that can open the parts needs to be installed on the computer used for the processing and execution stage.
7. The UGOpenGrip batch processing attribute system based on a detail table according to claim 1, characterized in that: The detailed table format is Excel, CSV, and / or Word; The detail table generation module, declaration module, initialization module, and execution module are based on the UG OpenGrip scripting language provided by UG and generate programs that can process Word documents, Excel spreadsheets, and / or Python programming.
8. A batch processing attribute method for UGOpenGrip based on a detail table, characterized in that, Using a UGOpenGrip batch processing attribute system based on a detail table as described in any one of claims 1-6, comprising: S1: Generate a detailed table with m rows and n columns based on the component names and attributes of the parts. The m rows represent m parts, and the n columns include component names, string variable names, and multiple attributes. S2: Declare the variable dimension, number of variables i, and character length in the format of a string variable; S3: Assign values to string variables containing character length and variable dimensions based on the details table to obtain the initialized string variables; S4: Execute, open the UG part corresponding to the part name in a certain column of the m-row n-column detail table array, perform attribute processing on the part with the initialized string variable, save the part to disk and close the part; S5: Repeat step S4 m times to obtain the m*i attribute values contained in the m-row-n-column array written at once.
9. The UGOpenGrip batch processing attribute method based on a detail table according to claim 8, characterized in that: In step S4, batch processing is performed on any attribute in the m-row, n-column detail table array.
10. The UGOpenGrip batch processing attribute method based on a detail table according to claim 8, characterized in that: In step S4, the m-row, n-column detail table array can be divided into multiple batches, and different attribute processing can be performed in each batch in the order of the batches.
Citation Information
Patent Citations
Method for making feature modeling system on the basis of extensive markup language (XML) in unigraphics (UG) environment
CN103761357A
Excel data importing method and device, equipment and storage medium
CN117236307A