Graphical file format conversion method, device, equipment and storage medium
Patent Information
- Application Number
- CN202611296818.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-10-30
AI Technical Summary
然而该方式过度依赖操作人员经验,批量转换效率低下,且易出现线宽错配、极性倒置、填充遗漏等错漏,难以适配高效自动化的批量生产需求
[0008]本申请实施例提供的图形文件格式转换方法、装置、设备、存储介质及程序,通过分别设置走线层与填充层的图形命名规则,并且对DXF格式文件中的图层命名进行语义识别,识别成功后根据图层命名分别针对走线层与填充层执行不同的操作,在自动执行相关修复之后,生成对应的Gerber指令,并根据生成的Gerber指令生成Gerber文件,从而在不依赖生产人员的操作经验的同时,完成了对不规范图纸的几何修复,实现了从DXF格式文件到Gerber文件的自动化格式转换,提高了整体的生产效率。
Smart Images

Figure CN123013329A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of graphic data conversion technology, and in particular to a method, apparatus, device and storage medium for converting graphic file formats. Background Technology
[0002] In industries such as metal etching, it is necessary to convert DXF format mechanical design drawings generated by CAD software into Gerber format files required by production equipment. Current conversion methods largely rely on manual operation of specialized CAM software, requiring manual differentiation of trace and fill layers, configuration of line widths and exposure polarities. For defective drawings with breakpoints or redundant annotations, manual contour repair and filling of objects are also required. However, this method is overly dependent on operator experience, resulting in low batch conversion efficiency and a high risk of errors such as line width mismatches, polarity inversions, and fill omissions, making it difficult to adapt to the demands of efficient and automated mass production. Summary of the Invention
[0003] This application aims to provide a method, apparatus, device, and storage medium for converting graphic file formats, which can realize automated format conversion from DXF format files to Gerber files, thereby improving overall production efficiency.
[0004] The graphic file format conversion method according to the first aspect of this application includes: Obtain DXF format files; Extract the trace layer and fill layer used to generate Gerber files from DXF format files; Generate Gerber line drawing instructions based on the line segment information drawn in the routing layer; Delete redundant primitives in the fill layer, determine the distance between the endpoints of every two non-connected line segments, and merge the endpoints of the corresponding two non-connected line segments if the distance between any endpoints is less than the preset tolerance distance to generate nested closed polygons. There is at least one set of nested closed polygons. Generate a HATCH object corresponding to each set of nested closed polygons, and generate Gerber fill instructions based on the layer where the HATCH object and the outermost outline of the corresponding nested closed polygon are located. Generate a Gerber file based on Gerber line drawing instructions and Gerber fill instructions.
[0005] A graphic file format conversion apparatus according to a second aspect embodiment of this application includes: DXF format file acquisition module, used to acquire DXF format files; The layer extraction module extracts the trace layer and fill layer from the DXF format file for generating Gerber files; The Gerber line drawing instruction generation module is used to generate Gerber line drawing instructions based on the line segment information drawn in the routing layer. The nested closed polygon generation module is used to delete redundant primitives in the fill layer, determine the distance between the endpoints of every two non-connected line segments, and merge the endpoints of the corresponding two non-connected line segments if the distance between any endpoints is less than the preset tolerance distance, thereby generating a nested closed polygon. There is at least one set of nested closed polygons. The Gerber fill instruction generation module is used to generate a HATCH object corresponding to each set of nested closed polygons, and to generate Gerber fill instructions based on the layer where the HATCH object and the outermost contour of the corresponding nested closed polygon are located. The Gerber file generation module generates Gerber files based on Gerber line drawing instructions and Gerber fill instructions.
[0006] According to an embodiment of the third aspect of this application, the electronic device includes a processor and a memory storing a computer program; the computer program executed by the processor is a method for converting a graphic file format as described in the first aspect embodiment above.
[0007] According to a fourth aspect embodiment of the present application, a computer-readable storage medium stores computer-executable instructions for causing a computer to perform a graphic file format conversion method as described in the first aspect embodiment above; the computer-readable storage medium is applied in an electronic device as described in the third aspect embodiment above.
[0008] The graphic file format conversion method, apparatus, device, storage medium, and program provided in this application embodiment set graphic naming rules for the trace layer and fill layer respectively, and performed semantic recognition on the layer names in the DXF format file. After successful recognition, different operations are performed on the trace layer and fill layer according to the layer names. After automatically performing relevant repairs, corresponding Gerber instructions are generated, and Gerber files are generated according to the generated Gerber instructions. Thus, geometric repair of non-standard drawings is completed without relying on the operating experience of production personnel, realizing automated format conversion from DXF format files to Gerber files, and improving overall production efficiency.
[0009] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing this application. Attached Figure Description
[0010] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart of a graphic file format conversion method according to an embodiment of this application; Figure 2 A schematic diagram of the structure of an embodiment of the electronic device provided in this application. Detailed Implementation
[0011] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0012] In the description of this application, the use of terms such as "first," "second," etc., is for the purpose of distinguishing technical features only and should not be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated or the order of the technical features indicated.
[0013] In the description of this application, it should be understood that the orientation descriptions, such as up, down, etc., are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application.
[0014] In the description of this application, it should be noted that, unless otherwise explicitly defined, terms such as "setup," "installation," and "connection" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this application in conjunction with the specific content of the technical solution.
[0015] The technical solution of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are some embodiments of this application, not all embodiments.
[0016] like Figure 1 As shown, an embodiment of this application provides a graphic file format conversion method, including steps S100 to S600; Step S100: Obtain a DXF format file; Step S200: Extract the trace layer and fill layer from the DXF format file to generate the Gerber file; Step S300: Generate Gerber line drawing instructions based on the line segment information drawn in the routing layer. Step S400: Delete redundant primitives in the fill layer, determine the distance between the endpoints of every two non-connected line segments, and merge the endpoints of the corresponding two non-connected line segments if the distance between any endpoints is less than the preset tolerance distance to generate a nested closed polygon. There is at least one set of nested closed polygons. Step S500: Generate a HATCH object corresponding to each group of nested closed polygons, and generate Gerber fill instructions based on the layer where the HATCH object and the outermost contour of the corresponding nested closed polygon are located. Step S600: Generate a Gerber file based on the Gerber line drawing instructions and the Gerber fill instructions.
[0017] In this embodiment, by setting separate naming rules for the trace layer and the fill layer, and performing semantic recognition on the layer names in the DXF format file, different operations are performed on the trace layer and the fill layer according to the layer names after successful recognition. After automatically performing the relevant repairs, the corresponding Gerber instructions are generated, and Gerber files are generated based on the generated Gerber instructions. Thus, the geometric repair of non-standard drawings is completed without relying on the operational experience of production personnel, realizing automated format conversion from DXF format files to Gerber files, and improving overall production efficiency.
[0018] The aforementioned DXF format file is an open vector graphics data exchange format, developed and maintained by Autodesk, and widely used in the field of computer-aided design. DXF files store graphic data in ASCII text format, featuring good readability and strong compatibility. In this embodiment, the acquired DXF file originates from the output of CAD design software and contains various geometric information required for industrial design and production.
[0019] The aforementioned DXF format file can include multiple layers and multiple primitives. Layers are hierarchical structures within the DXF file used to organize and manage graphic elements. Each layer can contain multiple primitives, which are the basic units describing geometric shapes in the DXF file. In this embodiment, primitives include, but are not limited to, line segment primitives (LINE), arc primitives (ARC), polyline primitives (LWPOLYLINE), circle primitives (CIRCLE), and spline primitives (SPLINE). These primitives are used to represent different types of geometric elements: line segment primitives represent straight line segments, arc primitives represent arc segments, polyline primitives represent composite paths formed by connecting multiple line segments or arcs, circle primitives represent complete circular outlines, and spline primitives represent smooth curved outlines. For example, in the design of a circuit board border, a rectangular border is typically composed of four line segment primitives; in the design of a circular pad, the pad outline is typically represented by a circle primitive.
[0020] The Gerber file, as described above, is an open two-dimensional vector image exchange standard file, created by Gerber Inc. and now maintained by Ucamco. It is a universal data exchange specification in the industrial manufacturing field. Gerber files store layered graphics instructions as a 7-bit ASCII text stream, featuring text parsing, cross-software and cross-device compatibility, and controllable geometric precision. In this embodiment, the output Gerber file is derived from a converted DXF format file, containing various layered geometric and process information required for industrial design and production.
[0021] The aforementioned trace layer and fill layer are not native layer types in DXF format files. Trace layer and fill layer layers are industry-standard production layering formats used in Gerber files. Defining trace layer and fill layer layers in DXF format files is for the purpose of facilitating industrial production and ensuring compatibility with the format file.
[0022] The line segments mentioned above include both non-closed and closed line segments. Non-closed line segments are line-like primitives in DXF format files whose start and end coordinates do not coincide, and whose graphic outline has an opening; they lack the geometric characteristics of a closed enclosing region. Typical non-closed line segments in DXF files include single straight lines (LINE), lightweight polylines (LWPOLYLINE) with closure attributes disabled, open arcs (ARC), and open splines (SPLINE). In typical industrial design scenarios, such as PCB design, conductive traces connecting different pads and device pins are commonly represented using this type of non-closed line segment. Closed line segments are line-like primitives in DXF format files whose start and end coordinates completely coincide, or whose primitives themselves carry a closure attribute identifier, capable of enclosing a closed region, and possessing complete closed enclosing geometric characteristics. Typical closed line segments in DXF files include lightweight polylines (LWPOLYLINE), circles (CIRCLE), ellipses (ELLIPSE), closed splines (SPLINE), and closed polylines (POLYLINE) with the closure attribute enabled. A closed contour composed of multiple independent lines that are precisely connected end to end without coordinate gaps also belongs to the category of closed line segments in terms of geometric properties. In typical industrial design scenarios, such as PCB design, the outer contour of copper pour areas, the boundary of solder mask openings, the outline of pads, and the inner layer cutout areas are commonly represented by this type of closed line segment.
[0023] The Gerber line drawing commands described above are the core commands in the Gerber format used to describe linear graphics. For each primitive in the routing layer, a corresponding Gerber line drawing command is generated based on its geometry type and parameters. For example, for a line segment primitive, its start and end coordinates are mapped to line drawing commands in the Gerber format; for an arc primitive, its center coordinates, start angle, and end angle are mapped to arc line drawing commands in the Gerber format. Gerber line drawing commands typically include combinations of light source on and light source off commands. The light source on command indicates that the drawing beam is on, allowing lines to be drawn during movement; the light source off command indicates that the drawing beam is off, preventing lines from being drawn during movement. By combining these commands, the geometric information of all primitives in the routing layer can be accurately described. For example, a line segment from coordinates (100, 200) to coordinates (300, 400) can be represented in Gerber format as: first move to the start point, then draw the line to the end point.
[0024] The aforementioned redundant primitives refer to primitives in the fill layer that do not substantially contribute to the final Gerber file, including non-graphical primitives and line segments not connected to the main contour. Non-graphical primitives are annotation-type and auxiliary primitives that lack geometric attributes of the fill boundary, including but not limited to text annotations, dimension annotations, attribute definition blocks, drawing reference lines, and layer markers in DXF files. These primitives cannot participate in the construction of the closed fill contour and are not part of the processing graphics required for photoplotting production. If retained in the fill layer data, it will not only increase the data computation load for subsequent line segment traversal and endpoint calculation, but also easily be misidentified by contour recognition algorithms as line segments constituting the fill boundary, causing disordered topological relationships in the fill area. Line segments not connected to the main outline are isolated and scattered line segments that are detached from the main outline of the filled area. Their beginning and end points do not form an effective connection with the main outline line segments of the filled area. They are mostly residual lines, debugging tracks, or extra drawn line segments during the drawing process. Such line segments have no corresponding filling area semantics. If they are left in the subsequent endpoint merging step, they will interfere with the matching logic of the distance between endpoints, causing incorrect endpoint splicing, and thus generating redundant nested closed outlines. This will result in defects such as non-design intentional hollowing and graphic distortion in the final output Gerber filled area.
[0025] Auxiliary line elements typically include dimension lines, center lines, reference lines, and other elements used to assist design but not part of the actual manufacturing drawings. Text annotation elements include text elements such as labels, annotations, and descriptions. These elements play an important auxiliary role in the CAD design stage, but if not deleted when converting to Gerber format for manufacturing, they may cause the Gerber file to contain unnecessary elements, affecting manufacturing quality or causing parsing errors by manufacturing equipment. This embodiment automatically filters and deletes these redundant elements by identifying their type attributes. Specifically, by traversing all elements in the fill layer, it determines whether each element belongs to the auxiliary line element or the text annotation element. If so, it is removed from the processing queue and does not participate in subsequent conversion processes. This operation can effectively purify the data in the fill layer, providing clear input for subsequent processing.
[0026] The aforementioned preset tolerance distance is a pre-configured coordinate error threshold. This threshold can be flexibly set by the operator based on processing accuracy, DXF format file export accuracy, and plate-making equipment resolution accuracy. In typical industrial design scenarios, such as PCB stencils and circuit board processing, the preset tolerance distance can be 0.01mm. This preset tolerance distance is used to determine whether the endpoints of two independent non-closed line segments within the fill layer are virtual breaks caused by drawing gaps, rather than actual openings intended in the design. After deleting redundant primitives in the fill layer, the endpoint coordinates of all non-closed line segments within the fill layer are traversed, and the distance between the endpoints of each pair of non-connected line segments is calculated. When any endpoint distance is detected to be less than the preset tolerance distance, the two endpoints are determined to be separated endpoints caused by drawing gaps. The coordinates of the corresponding two non-connected line segment endpoints are automatically merged to eliminate the tiny opening gaps between the line segments. The merging process is continuously performed on all line segment endpoints with gaps within the fill layer until there are no separated endpoints with a spacing less than the preset tolerance distance. Nested closed polygons are generated from the continuous line segment outlines without openings, and there is at least one set of nested closed polygons.
[0027] The endpoint merging mentioned above refers to identifying and connecting geometrically adjacent but data-separated endpoints of graphic elements. In actual CAD design, a complete closed contour may consist of multiple independent line segments or arcs. These elements connect at geometric endpoints but may be independent entities in the data structure. To form a complete closed polygon from these scattered elements, it is necessary to identify endpoints with the same or similar geometric positions and connect the corresponding elements. Specifically, the endpoint merging process includes: traversing all remaining elements in the fill layer and extracting the start and end coordinates of each element; comparing the endpoint coordinates of different elements, and considering that the two endpoints can be merged when the distance between them is less than a preset threshold; constructing a continuous contour path through the endpoint connection relationships between elements; and finally forming a closed polygon structure.
[0028] The aforementioned nested closed polygons refer to a structure in which multiple closed polygons have an inclusion relationship. In circuit board design, common nested structures include: an outer copper foil area containing an inner pad / hole area, or a filled area containing an isolated via area. Such nested structures need to be correctly represented in Gerber format through polarity control. In this embodiment, by analyzing the spatial relationships between polygons, the nested hierarchy can be identified, providing a basis for subsequent polarity processing.
[0029] The HATCH object mentioned above is a special primitive type used in DXF format files to describe a filled region. A HATCH object defines a closed boundary and its internal fill pattern. By converting the nested closed polygons generated in the preceding steps into HATCH objects, standardized input can be provided for subsequent generation of Gerber fill instructions. The generation process of a HATCH object includes: using the outer closed polygon as the outer boundary of the HATCH object; using the inner closed polygon as the island boundary of the HATCH object; and setting the fill pattern to solid fill, i.e., completely filling the entire closed region. The generated HATCH object fully expresses the spatial extent and nested structure of the filled region.
[0030] The aforementioned Gerber fill instructions are instructions in the Gerber format used to describe planar fill regions. Based on the HATCH object generated in the preceding steps, the boundary contours and nested structure information of the fill region can be extracted and mapped to the corresponding Gerber fill instructions. Gerber fill instructions typically include a combination of region start instructions and region end instructions. The region start instruction marks the starting point of a fill region, and the region end instruction marks the ending point of the fill region. For fill regions with nested structures, polarity inversion is needed to control the fill effects of different levels. For example, when the outer region has normal polarity, the inner island region needs to have its polarity inverted to create a hole effect. In this embodiment, the corresponding polarity control instructions are automatically generated according to the nesting hierarchy to ensure that the fill effect meets the design requirements.
[0031] The above steps generate a Gerber file based on Gerber line drawing and Gerber fill instructions. The Gerber line drawing and fill instructions generated in the previous steps are then integrated to generate the final Gerber file according to the Gerber format specification. The integration process includes: organizing the instruction sequence according to the standard structure of a Gerber file; adding necessary header information, such as format declarations, coordinate format settings, and unit settings; arranging the line drawing instructions for the trace layer and the fill instructions for the fill layer in layer order; and adding a file end marker. In this embodiment, the generated Gerber file conforms to the RS-274X standard, which is a widely adopted Gerber format extension standard in the PCB manufacturing industry. It supports embedded aperture definitions and macro instructions, offering better compatibility and readability. Through these steps, a fully automatic conversion from DXF format to Gerber format is achieved, completing complex format mapping and data conversion without manual intervention.
[0032] In some implementations, the trace layer and fill layer are extracted from the DXF format file, including: If the layer names in the DXF format file conform to the routing layer naming rules, extract the layers in the DXF format file that conform to the routing layer naming rules as routing layer layers. If the layer names in a DXF file conform to the rules for filling layer names, extract the layers in the DXF file that conform to the rules for filling layer names as filling layer layers.
[0033] In this embodiment, by defining two types of layers in the DXF format file—trace layer layers and fill layer layers—corresponding to the Gerber file, and by performing semantic recognition on all layers in the DXF format file, layers conforming to the trace layer naming rules are defined as trace layer layers, and layers conforming to the fill layer naming rules are defined as fill layer layers. Other layers that do not conform to the trace layer naming rules and fill layer naming rules are ignored. This allows for the rapid differentiation of trace geometry and copper fill geometry within the DXF format file, achieving a one-to-one mapping between layer semantics and Gerber standard process layers. Furthermore, through standardized layer naming rules, explicit expression of layer semantic information is achieved, enabling the conversion system to accurately understand the design intent of each layer and generate the expected Gerber file. This naming-based semantic processing method, compared to traditional methods based on layer order or manual configuration, has a higher degree of automation and a lower error probability.
[0034] The aforementioned routing layer naming convention is a structured naming method that conveys the functional attributes and transformation parameters of a layer through specific naming rules and identifiers. This naming convention allows the transformation system to parse rich semantic information from the layer name, thereby guiding subsequent transformation processing. A routing layer name conforming to the routing layer naming convention includes: a first naming rule, a first polarity identifier, and a first linewidth. The first naming rule is used to identify the routing layer as a naming prefix or keyword. For example, "trace" can be used as the naming prefix for a routing layer, indicating that the layer contains routing information. The first polarity identifier specifies the polarity setting of the routing layer in the Gerber file; common polarities include 1 and 0. 1 indicates that all traces in this layer are processed with copper exposure, and 0 indicates that all traces in this layer are processed with copper removal. The first linewidth specifies the width parameter of the lines in the routing layer, which directly affects the linewidth setting of the line drawing instructions in the Gerber file. For example, a trace layer name that conforms to the naming rules can be trace_1_0.2, where trace is the first naming rule, indicating that this is a trace layer; 1 is the first polarity identifier, indicating that copper is added; 0.2 is the first line width, indicating that the line width is 0.2 mm. That is to say, all traces on this layer are processed in a way that retains copper with a line width of 0.2 mm.
[0035] The above-mentioned fill layer naming rules are a structured naming convention that conveys the functional attributes and conversion parameters of a layer through specific naming rules and identifiers. This naming convention allows the conversion system to parse rich semantic information from the layer name, thereby guiding subsequent conversion processing. A fill layer name that conforms to the fill layer naming rules includes a second naming rule and a second polarity identifier. The second naming rule is used to identify the fill layer's naming prefix or keyword. Unlike trace layers, fill layer names are usually customized according to their actual function; for example, "copper" can represent a copper foil layer, "soldermask" a solder mask layer, and "silkscreen" a silkscreen layer. The second polarity identifier is also used to specify the polarity setting of the fill layer in the Gerber file; however, the second polarity identifier specifically refers to the outermost polarity of all closed contours within the layer. For example, a fill layer name that conforms to the naming rules could be "copper_1," where "copper" is the second naming rule, indicating that this is a copper foil layer; and "1" is the second polarity identifier, indicating the addition of copper. In other words, copper is added to the outermost ring of all closed contours in this layer, and the polarity of the nested contours inside is automatically flipped layer by layer, while the polarity is processed accordingly after the flip.
[0036] In some implementations, Gerber line drawing instructions are generated based on the line segment information drawn in the routing layer, including: Get all drawn line segments within the routing layer layer; Set the light plotting aperture according to the layer name of the wiring layer; The Gerber line drawing command is generated based on the layer name of the routing layer, the line segment information to be drawn, and the light drawing aperture.
[0037] In this embodiment, after obtaining all drawn line segments within the trace layer, the photoplotting aperture is set according to the layer name of the trace layer. Based on the layer name, drawn line segment information, and photoplotting aperture, Gerber drawing instructions are generated. This enables automated mapping between the trace layer graphics in the DXF format file and the standard Gerber photoplotting parameters. Operators do not need to manually match the aperture size corresponding to different circuit layers, thus ensuring uniform and standardized output parameters for multi-layer circuit graphics. It fully preserves the original geometric information such as the coordinate trajectory and routing direction of the drawn line segments, accurately converting them into Gerber drawing instructions. This reduces problems such as line width mismatch, trace loss, and layer parameter confusion that occur during manual conversion, improving the conversion accuracy and automation level when converting DXF to Gerber files, and ensuring that the subsequent PCB photoplotting and etching processing circuit dimensions meet design requirements.
[0038] The aforementioned photoplotting aperture is the basic unit in the Gerber file used to define the line width of the circuit pattern. It is the core parameter basis for the photoplotting equipment to perform exposure and etching processes, and its parameter specifications directly correspond to the actual trace processing width in industrial production. By pre-establishing the mapping relationship between trace layer names and photoplotting aperture parameters, different layer names correspond to different aperture sizes, aperture shapes, and aperture numbers. Once the corresponding trace layer is identified, the matching photoplotting aperture parameters can be automatically retrieved based on the layer name, eliminating the need for manual configuration of line width and aperture attributes layer by layer.
[0039] The line segment information mentioned above includes both non-closed and closed line segment information. The non-closed line segment information is a set of parameters extracted from the trace layer of the DXF format file, used to fully characterize the geometric features and attributes of open lines. It is the core geometric data source for generating Gerber standard line drawing instructions. Specifically, this non-closed line segment information includes the two-dimensional coordinates of the starting point, the two-dimensional coordinates of the ending point, the coordinate sequence of intermediate inflection points, the line segment geometry type (e.g., single straight line segment, multi-segment polyline, arc segment, spline curve segment), the layer identifier to which the line segment belongs, the line segment length parameter, and the coordinate precision level. The closed line segment information is a set of parameters extracted from the trace layer and fill layer of the DXF format file, used to fully characterize the geometric features and topological attributes of closed contours. It is the core geometric data foundation for constructing nested closed polygons and generating Gerber standard fill region instructions. Specifically, the information of the closed line segment includes the vertex coordinate sequence of each closed contour, the contour geometry type (such as closed polyline, circle, ellipse, closed spline curve segment), the contour closure attribute identifier, the layer identifier to which the contour belongs, the contour enclosing area parameter, the inner and outer layer topology level identifiers, and the coordinate accuracy level.
[0040] In some implementations, deleting redundant primitives in the fill layer includes: Get all primitives within the fill layer; Delete non-graphical elements within the fill layer; Delete line segments within the fill layer that are not connected to the main outline.
[0041] In this embodiment, by first acquiring all primitives within the fill layer and then deleting non-graphical primitives and line segments not connected to the main contour, the graphic dataset of the fill layer can be effectively purified. This eliminates interference from irrelevant information on closed contour recognition, significantly improving the computational efficiency and recognition accuracy of subsequent contour gap closure processing and fill graphic conversion. After two levels of redundant primitive cleaning, only valid contour line segments constituting the fill area are retained within the fill layer. This reduces the computational complexity of subsequent endpoint merging and nested closed polygon generation, improves the success rate and graphic restoration accuracy of converting the fill layer in the DXF format file to Gerber fill instructions, effectively reduces processing defects such as fill area misalignment and redundant etched graphics caused by redundant primitive interference, and ensures the final graphic accuracy.
[0042] In some implementations, a Gerber fill instruction is generated based on the layer containing the HATCH object and the outermost contour of the corresponding nested closed polygon, including: Read the geometry data of the HATCH object; Based on the geometric data of the HATCH object and the layer name of the layer containing the outermost contour of the corresponding nested closed polygon, the Gerber fill instruction is generated according to the flipping rules. The flipping rules include: Obtain all contours of nested closed polygons from the outside in; The polarity of the outermost contour of the nested closed polygon is determined by the layer name of the layer in which the outermost contour of the nested closed polygon is located. Based on the polarity of the outermost contour, the polarity is flipped once for each nested contour.
[0043] In this embodiment, nested levels are automatically detected by semantic recognition of layer names, and the outline polarity of closed nested polygons is intelligently flipped. This allows for the differentiation of fill layers for different process types and the automatic setting of the initial polarity of the corresponding outermost outline, adapting to process specifications in various production scenarios. Furthermore, for closed nested polygons with multi-layered nesting structures (outer fill boundaries, inner hollow areas, nested island outlines, etc.), the rule of flipping polarity layer by layer from the outside in accurately restores the nested fill logic of the HATCH object in the DXF format file, which involves "outer fill, inner hollow, alternating layers." This completely preserves the topological relationship of the original design and significantly reduces errors such as polarity reversal and mistaken conversion of hollow areas into fill areas when manually processing complex nested outlines. Furthermore, by combining the geometric data of the HATCH object with the semantic recognition of the layer name to generate Gerber fill instructions, it ensures that the geometric coordinates and nesting shape of the fill area are completely consistent with the original design, and also ensures that the output polarity parameters meet the processing requirements of photoplotting production. This can effectively reduce the workload of manually checking polarity, reduce production defects such as scrapped photoplotting films, reversed etched patterns, and stencil opening deviations caused by incorrect polarity configuration, and significantly improve the automation and graphic accuracy of converting the fill layer of DXF format files to Gerber files.
[0044] In some implementations, the following steps are included before reading the geometry data of the HATCH object: When a nested closed polygon already has a native HATCH object, the geometric data of the native HATCH object is preserved.
[0045] In this embodiment, by preserving the geometric data of the nested closed polygon when it already has a native HATCH object, the fill attributes and contour information originally defined in the design of the DXF format file can be reused first. This avoids repeatedly performing line segment splicing and contour reconstruction calculations on graphics that already have complete fill semantics, effectively simplifying the data processing flow of the fill layer and improving the efficiency of format conversion. Moreover, the native HATCH object comes with precise inner and outer contour coordinates, nested topological relationships, and fill boundary definitions. Its geometric accuracy is completely consistent with the original design data. Based on this, Gerber fill instructions can be generated, avoiding deviations such as boundary deformation and hierarchical disorder that may occur during the process of merging scattered line segment endpoints and reconstructing contours with tolerance fitting. This ensures that the shape and nesting logic of the fill area are highly consistent with the original design.
[0046] In some implementations, before generating the Gerber fill instruction based on the layer containing the HATCH object and the outermost contour of the corresponding nested closed polygon, the following steps are also included: If the generation of a nested closed polygon fails and no native HATCH object exists, a temporary HATCH object is generated for the closed polyline.
[0047] In this embodiment, by generating a temporary HATCH object for the closed polyline when nested closed polygon generation fails and a native HATCH object does not exist, the processing gap in abnormal scenarios can be effectively filled, significantly improving the fault tolerance and scene adaptability of the format conversion method. Furthermore, the generated temporary HATCH object can be directly connected to the unified processing chain for subsequent layer polarity determination, nested level flipping, and Gerber fill command generation, without the need to build an additional independent conversion branch. This avoids the problem of directly losing the fill area due to contour reconstruction failure, thus eliminating the need for manual rework to repair graphic defects in the DXF source file. This effectively reduces the requirements for the drawing standardization of the source file, adapts to fill layer data exported from different CAD software and with different drawing qualities, ensures the success rate of fill graphic conversion and geometric restoration accuracy, reduces manual intervention costs, and improves the automation and production adaptability of DXF format files to Gerber files.
[0048] This application embodiment also provides a graphic file format conversion device, including: DXF format file acquisition module, used to acquire DXF format files; The layer extraction module extracts the trace layer and fill layer from the DXF format file for generating Gerber files; The Gerber line drawing instruction generation module is used to generate Gerber line drawing instructions based on the line segment information drawn in the routing layer. The nested closed polygon generation module is used to delete redundant primitives in the fill layer, determine the distance between the endpoints of every two non-connected line segments, and merge the endpoints of the corresponding two non-connected line segments if the distance between any endpoints is less than the preset tolerance distance, thereby generating a nested closed polygon. There is at least one set of nested closed polygons. The Gerber fill instruction generation module is used to generate a HATCH object corresponding to each set of nested closed polygons, and to generate Gerber fill instructions based on the layer where the HATCH object and the outermost contour of the corresponding nested closed polygon are located. The Gerber file generation module generates Gerber files based on Gerber line drawing instructions and Gerber fill instructions.
[0049] The graphic file format conversion device in this embodiment is based on the aforementioned graphic file format conversion method. By setting separate naming rules for the trace layer and fill layer, and performing semantic recognition on the layer names in the DXF format file, different operations are performed on the trace layer and fill layer according to the layer names after successful recognition. After automatically performing the relevant repairs, corresponding Gerber instructions are generated, and a Gerber file is generated based on the generated Gerber instructions. This completes the geometric repair of non-standard drawings without relying on the operational experience of production personnel, achieving automated format conversion from DXF format files to Gerber files and improving overall production efficiency.
[0050] like Figure 2 As shown, this application embodiment also provides an electronic device, including: a processor 210 and a memory 220 storing a computer program; When processor 210 executes a computer program, it implements the graphic file format conversion method described above. The electronic device provided in this application embodiment can implement each process of the above-described graphic file format conversion method embodiment and achieve the same beneficial effects. To avoid repetition, it will not be described again here.
[0051] This application also provides a computer-readable storage medium storing computer-executable instructions that are executed by a processor or control module, causing the processor to perform the graphic file format conversion method described in the above embodiments, for example, the method described above.
[0052] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0053] The functional blocks shown in the above structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. The programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM, floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0054] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0055] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0056] The above are merely specific embodiments of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A method for converting graphic file formats, characterized in that, include: Obtain DXF format files; Extract the trace layer and fill layer used to generate the Gerber file from the DXF format file; Based on the line segment information drawn in the wiring layer, a Gerber line drawing command is generated. Redundant primitives in the fill layer are deleted, the distance between the endpoints of every two non-connected line segments is determined, and if the distance between any two endpoints is less than a preset tolerance distance, the corresponding two non-connected line segment endpoints are merged to generate a nested closed polygon. There is at least one set of nested closed polygons. Generate a HATCH object corresponding to each group of nested closed polygons, and generate a Gerber fill command based on the HATCH object and the layer where the outermost contour of the corresponding nested closed polygon is located. The Gerber file is generated based on the Gerber line drawing instructions and the Gerber fill instructions.
2. The graphic file format conversion method according to claim 1, characterized in that, The step of extracting the trace layer and fill layer from the DXF format file includes: If the layer name in the DXF format file conforms to the routing layer naming rules, the layer in the DXF format file that meets the routing layer naming rules is extracted as the routing layer layer; If the layer name in the DXF format file conforms to the fill layer name rule, the layer in the DXF format file that satisfies the fill layer name rule is extracted as the fill layer layer.
3. The graphic file format conversion method according to claim 1, characterized in that, The step of generating Gerber line drawing instructions based on the line segment information drawn in the routing layer includes: Obtain all drawn line segments within the aforementioned wiring layer; Set the photoplotting aperture according to the layer name of the wiring layer; The Gerber line drawing command is generated based on the layer name of the routing layer, the line segment information to be drawn, and the light drawing aperture.
4. The graphic file format conversion method according to claim 1, characterized in that, The step of deleting redundant primitives in the fill layer includes: Get all primitives within the filled layer; Delete non-graphical primitives within the filled layer; Delete the line segments in the fill layer that are not connected to the main outline.
5. The graphic file format conversion method according to claim 1, characterized in that, The step of generating Gerber fill instructions based on the HATCH object and the layer containing the outermost contour of the corresponding nested closed polygon includes: Read the geometric data of the HATCH object; Based on the geometric data of the HATCH object and the layer name of the layer where the outermost contour of the nested closed polygon is located, the Gerber fill instruction is generated according to the flip rule; The flipping rules include: Obtain all contours of the nested closed polygon from the outside in; The polarity of the outermost contour of the nested closed polygon is determined by the layer name of the layer in which the outermost contour of the nested closed polygon is located; Based on the polarity of the outermost contour, the polarity is flipped once for each nested contour.
6. The graphic file format conversion method according to claim 5, characterized in that, Before reading the geometry data of the HATCH object, the following is also included: If the nested closed polygon already has a native HATCH object, the geometric data of the native HATCH object is retained.
7. The graphic file format conversion method according to claim 1, characterized in that, Before generating the Gerber fill instruction based on the HATCH object and the layer containing the outermost contour of the corresponding nested closed polygon, the method further includes: If the nested closed polygon generation fails and no native HATCH object exists, a temporary HATCH object is generated for the closed polyline.
8. A graphic file format conversion device, characterized in that, include: DXF format file acquisition module, used to acquire DXF format files; The layer extraction module is used to extract the trace layer and fill layer for generating Gerber files from the DXF format file. The Gerber line drawing instruction generation module is used to generate Gerber line drawing instructions based on the line segment information drawn in the routing layer. The nested closed polygon generation module is used to delete redundant primitives in the fill layer, determine the distance between the endpoints of every two non-connected line segments, and merge the corresponding two non-connected line segment endpoints when any of the endpoint distances is less than a preset tolerance distance to generate a nested closed polygon. There is at least one set of nested closed polygons. The Gerber fill instruction generation module is used to generate a HATCH object corresponding to each group of nested closed polygons, and generate Gerber fill instructions based on the HATCH object and the layer where the outermost contour of the corresponding nested closed polygon is located. The Gerber file generation module is used to generate the Gerber file according to the Gerber drawing instructions and the Gerber fill instructions.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory storing a computer program; the computer program executed by the processor is to implement the graphic file format conversion method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the graphic file format conversion method as described in any one of claims 1 to 7; the computer-readable storage medium is used in the electronic device as described in claim 9.
