Method for reading IGES file data and converting IGES file data into XML
By reading and parsing IGES files line by line, storing entity parameters in a classified manner and retyped data content, the problems of low efficiency, poor accuracy and poor customization in the conversion of IGES files to XML files are solved, and efficient and accurate data conversion is achieved, meeting the high requirements of modern manufacturing for data exchange.
Patent Information
- Application Number
- CN202411645848.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-02-28
AI Technical Summary
The prior art has problems such as low efficiency, poor accuracy and poor customization in the conversion of IGES files to XML files, which limits the efficiency and effect of data exchange between CAD/CAM systems.
By reading and parsing IGES files line by line, storing entity parameters in a classified manner, and retype the data content, and finally outputting the XML file. This method uses JavaScript and FileReader APIs for file input and processes data by calling the parsing function by identifying segment identifiers.
It realizes efficient and accurate conversion from IGES files to XML files, provides a flexible data processing interface, meets the specific requirements of different CAD/CAM systems for data formats, and improves the utilization rate and value of data.
Smart Images

Figure CN119538870A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of data conversion and processing, and in particular to a method for reading IGES file data and converting the data into XML. Background Art
[0002] With the widespread application of CAD technology, data exchange between different systems has become an important issue. IGES (Initial Graphics Exchange Specification), as an internationally accepted standard for graphic data exchange, has been widely used for data sharing between CAD systems since its birth. However, the IGES file format is complex and contains a variety of data types and structures, making it quite difficult to directly process these data. In addition, the data representation of IGES files is relatively primitive and lacks the flexibility and scalability required for modern data exchange.
[0003] At the same time, XML, as a markup language, has gradually become an important tool for data exchange and integration due to its clear structure, easy to understand and process. XML defines the structure and content of data through tags, allowing data to be seamlessly exchanged and integrated between different systems and platforms. Therefore, converting IGES files to XML format can not only simplify the data processing process, but also improve the readability and reusability of the data.
[0004] However, although there are many data conversion tools on the market, most of them have problems such as low conversion efficiency, poor accuracy, and poor customizability when converting from IGES to XML. These problems limit the efficiency and effect of data exchange between CAD systems and cannot meet the high requirements of modern manufacturing for data exchange.
[0005] Therefore, the present invention proposes a IGES to XML conversion method, aiming to solve the deficiencies in the prior art and provide an efficient, accurate, and customizable conversion solution to meet the urgent need for data exchange in the CAD / CAM field. Through the conversion method of the present invention, users can easily convert IGES files to XML format to achieve fast and accurate data exchange and integration. Summary of the invention
[0006] The purpose of the present invention is to provide an efficient, accurate and easy-to-implement method for reading IGES file data and converting it into XML, so as to solve the problems raised in the above background technology.
[0007] To achieve the above object, the present invention provides the following technical solution: a method for reading IGES file data and converting it into XML, comprising the following steps:
[0008] S1: accept the input IGES data format file;
[0009] S2: Read and parse the input IGES data format file line by line;
[0010] S3: Classify and store the parameters of each entity;
[0011] S4: Data content reformatted;
[0012] S5: Output XML file.
[0013] In step S1, the IGES data format file is received as input, specifically, the IGES data format file is received as input by using FileReader API in the JavaScript high-level language code. After the user selects the IGES file through the Web interface, the JavaScript code reads the file through the FileReader API and stores its content as a string or binary data in the memory for subsequent processing.
[0014] In step S2, the step of reading and parsing the input IGES data format file line by line specifically includes:
[0015] The program reads the IGES file data line by line from the beginning, and calls different parsing functions to process the corresponding segment data according to the different segment identifiers (such as S, G, D, P, T, etc.) in the 73rd column of each line of data.
[0016] In step S3, each entity parameter is classified and stored, specifically including:
[0017] S301: In the directory entry segment of the file, extract the corresponding attribute information according to the different entity identifiers at the beginning of each line of data and store them into the corresponding array;
[0018] S302: In the parameter data segment of the file, the corresponding parameter information is extracted according to the different entity identifiers at the beginning of each line of data and then stored in the corresponding array.
[0019] In step S4, the data content is rearranged, specifically including:
[0020] S401: Create an XML document body;
[0021] S402: Write the content of the global segment into the XML file body;
[0022] S403: Write the contents of each entity array into the XML file body in sequence.
[0023] In step S5, the output XML file is specifically:
[0024] The XML file body after the data content is written is saved in XML file format.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] 1. The method of the present invention provides a more convenient and efficient way for data exchange between different systems, and promotes data sharing and integration in the field of CAD / CAM. By converting IGES files into XML format, different systems can read, process and analyze these data more easily, thereby improving the utilization and value of data;
[0027] 2. The present invention provides a flexible data processing interface, allowing users to customize data according to actual needs. Users can selectively extract specific entities, modify parameter values, or adjust XML structures to meet the specific requirements of different CAD / CAM systems or applications for data formats;
[0028] 3. The converted XML file has a good format and clear structure, making it very easy for user-specific software and various engineering software to extract valid data. There is no need to spend a lot of time studying the various entity type numbers and file structures of IGES files, reducing development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A flowchart of a method for reading IGES file data and converting it into XML is provided in an embodiment of the present invention.
[0030] Figure 2 This is a partial entity data diagram of the original IGES file.
[0031] Figure 3 This is a partial data diagram after conversion into XML file format.
[0032] Figure 4 This is an example of the global segment information of the IGES file.
[0033] Figure 5 This is a diagram of the data format of the directory entry segment of an IGES file. DETAILED DESCRIPTION
[0034] In order to more thoroughly explain the core concept, technical path and advantages of the present invention, the following will be based on the specific embodiments of the present invention, supplemented by drawings, and the details of the technical solution will be analyzed in detail and comprehensively. It is worth noting that these demonstrated embodiments are only part of the many possible implementations of the present invention, and are not exhaustive. The essence of the present invention lies in its concepts and principles, and the component layout and design shown in the figure and described in the text can be flexibly adjusted and optimized according to actual needs.
[0035] Therefore, the in-depth analysis of the following embodiments should not be regarded as a narrow definition of the protection scope of the present invention, but is intended to show the basic framework and potential applications of the present invention through specific examples. On the basis of following the core idea of the present invention, any new embodiment made by those skilled in the art without exceeding the scope of conventional technology should be deemed to fall within the scope of the protection requested by the present invention. In short, the breadth and depth of the present invention are far more than what is described in the text, but are open to all reasonable explorations and innovations based on the present invention.
[0036] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0037] See also Figures 1 to 5 The present invention provides a technical solution: a method for reading IGES file data and converting it into XML, specifically comprising the following steps:
[0038] S1: accept the input IGES data format file;
[0039] S2: Read and parse the input IGES data format file line by line;
[0040] S3: Classify and store the parameters of each entity;
[0041] S4: Data content reformatted;
[0042] S5: Output XML file.
[0043] In step S1, the IGES data format file is specifically accepted by using JavaScript programming language combined with FileReader API to implement file input. After the user selects the IGES file through the Web interface, the JavaScript code reads the file through the FileReader API and stores its content as a string or binary data in the memory for subsequent processing.
[0044] IGES (Initial Graphics Exchange Specification) file is the initial specification for graphic data exchange. It defines a set of formats and protocols to facilitate the exchange of 2D and 3D graphic data between different computer-aided design (CAD), computer-aided manufacturing (CAM), and computer-aided engineering (CAE) systems. The IGES standard was jointly developed by the American National Standards Institute (ANSI) and the American Industrial Standards Association (ISA) to provide a basis for the compatibility and interoperability of graphic data between different systems.
[0045] In step S2, the step of reading and parsing the input IGES file line by line specifically includes:
[0046] The program reads the IGES file data line by line from the beginning. According to the segment identifier (such as S, G, D, P, T, etc.) in the 73rd column of each line of data, different parsing functions are called to process the data of the corresponding segment. Specifically, for the global segment (G), the parsing function will extract information such as the file name and unit; for the directory entry segment (D), the parsing function will extract the attribute information of the entity; for the parameter data segment (P), the parsing function will extract the parameter information of the entity.
[0047] See Figure 4 As shown, the information of the global segment is separated by the identifier "\". The program classifies and extracts the file name, unit and other information in the global segment by identifying the "\".
[0048] In step S3, the classification and storage of each entity parameter specifically includes:
[0049] S301: In the directory entry segment of the file, extract the corresponding attribute information according to the different entity identifiers at the beginning of each line of data and store them into the corresponding array;
[0050] S302: In the parameter data segment of the file, the corresponding parameter information is extracted according to the different entity identifiers at the beginning of each line of data and then stored in the corresponding array.
[0051] The directory entry section provides a directory for each entity. A directory occupies two lines. Each directory is evenly divided into 20 fields, with 8 characters per field. For the specific data format, see Figure 5 The program stores the corresponding entity attributes into an array according to the different values of each entity field in the directory entry segment.
[0052] The data parameter segment uses the identifier "," to separate each parameter data, but for different entities, the specific data parameter storage specifications are different. You need to write a corresponding parameter extraction function for each different entity type number.
[0053] Specifically, extract the content of the data parameter segment line by line. When the line identifier "110" is encountered at the beginning, use split(",") to separate the parameters and store them in the line array, where line[1] and line[2] represent the starting coordinates of the line, and line[3] and line[4] represent the ending coordinates of the line. The data parameter extraction method for other entity types is similar. You only need to extract the parameters at the corresponding position according to the corresponding data storage specification.
[0054] In step S4, the data content is rearranged, specifically including:
[0055] S401: Create an XML document body;
[0056] S402: Write the content of the global segment into the XML file body;
[0057] S403: Write the contents of each entity array into the XML file body in sequence.
[0058] Declare a variable as the XML file body, write the contents of the global segment into the XML file body according to the XML data storage specification, and then write the contents of each entity array into the XML file body in sequence according to the XML data storage specification.
[0059] XML (Extensible Markup Language) is a markup language used to transmit and store data. It allows users to customize tags, so it has extremely high scalability. XML files use tag names to intuitively describe the meaning of data, have good self-descriptiveness, and their data is organized in a tree structure, which is suitable for representing data with complex structures. Due to its flexibility and ease of use, XML has been widely used in scenarios such as configuration files, data exchange (such as the SOAP protocol in Web services), and data storage.
[0060] In step S5, the output XML file is specifically:
[0061] The XML file body after data content is written is saved in XML file format using programming language. Specifically, the Blob object is used in conjunction with URL.createObjectURL() method in JavaScript high-level language code to output the XML file body as an XML file.
[0062] The method of the present invention provides a more convenient and efficient way for data exchange between different systems, and promotes data sharing and integration in the field of CAD / CAM. By converting IGES files into XML format, different systems can more easily read, process and analyze these data, thereby improving the utilization and value of data.
[0063] The present invention provides a flexible data processing interface, allowing users to customize data according to actual needs. Users can selectively extract specific entities, modify parameter values or adjust XML structures to meet the specific requirements of different CAD / CAM systems or applications for data formats.
[0064] The XML file converted by the present invention has a good format and a clear structure, making it very easy for user-specific software and various engineering software to extract valid data. There is no need to spend a lot of time studying various entity type numbers and file structures of IGES files, thereby reducing development costs.
[0065] The present invention relates to data conversion and processing technology, and in particular to the field of industrial graphic data exchange, a method for reading and converting IGES (Initial Graphics Exchange Specification) file data into XML (Extensible Markup Language) format is proposed. The method aims to solve the problem of data exchange between different CAD (Computer-Aided Design) systems, improve the efficiency and reliability of data exchange through the standardized XML format, and promote the further development of CAD / CAM (Computer-Aided Manufacturing) technology.
[0066] Standard IGES files include three formats: fixed-length ASCII code, compressed ASCII code and binary. The present invention provides a method for reading IGES file data and converting it into an XML file for IGES files with fixed-length ASCII codes, and relates to IGES file data processing and conversion in the field of engineering technology. Specifically, it includes receiving an IGES data format file provided by an input manufacturing execution system, reading and parsing the input file data line by line starting from the file header, storing each entity parameter according to the classification result, and then re-formatting the data content, and finally outputting the formatting result as a file in XML format. This converts the IGES file format to the XML file format. The method of the present invention has a wide range of applications, including but not limited to CAD / CAM system integration, product design data management, and engineering data services based on cloud platforms. The converted XML file has a good format and a clear structure, making it very easy for user-specific software and various engineering software to extract valid data, without having to spend a lot of time studying various entity type numbers and file structures of IGES files, thereby reducing development costs.
[0067] The above shows and describes the basic principles, main features and advantages of the present invention. Technical personnel in this industry should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only preferred examples of the present invention and are not used to limit the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A method for reading IGES file data and converting it into XML, characterized in that: The following steps are involved: S1: accept the input IGES data format file; S2: Read and parse the input IGES data format file line by line; S3: Classify and store each entity parameter; S4: Data content reformatted; S5: Output XML file.
2. The method for reading IGES file data and converting it into XML according to claim 1, characterized in that: In the step S1, the IGES data format file is accepted as input, specifically: using FileReader API to accept the IGES file as input in a code written in JavaScript high-level language.
3. The method for reading IGES file data and converting it into XML according to claim 1, characterized in that: In step S2, the step of reading and parsing the input IGES data format file line by line specifically includes: Read the IGES file data line by line from the beginning, and call different parsing functions according to the different segment identifiers in the 73rd column of each line of data.
4. The method for reading IGES file data and converting it into XML according to claim 1, characterized in that: In step S3, each entity parameter is classified and stored, specifically including: S301: In the directory entry segment of the file, extract the corresponding attribute information according to the different entity identifiers at the beginning of each line of data and store them into the corresponding array; S302: In the parameter data segment of the file, the corresponding parameter information is extracted according to the different entity identifiers at the beginning of each line of data and then stored in the corresponding array.
5. The method for reading IGES file data and converting it into XML according to claim 1, characterized in that: In step S4, the data content is rearranged, specifically including: S401: Create an XML document body; S402: Write the content of the global segment into the XML file body; S403: Write the contents of each entity array into the XML file body in sequence.
6. The method of reading IGES file data and converting it into XML according to claim 1, characterized in that: In step S5, the output XML file is specifically: The XML file body after the data content is written is saved in XML file format.