A method for image mapping and structured entity resolution based on DXF vector coordinates

By constructing a precise coordinate mapping and entity parsing mechanism, the problems of automation and accuracy in image mapping and structured parsing of DXF files are solved, realizing efficient automated processing and structured output of DXF files, which is applicable to fields such as architectural engineering design, mechanical design and industrial quality inspection.

CN121211530BActive Publication Date: 2026-02-10SHANGHAI LINGSHU INTELLIGENT TECH CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511767611.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-02-10
Estimated Expiration
2045-11-28

AI Technical Summary

Technical Problem

Existing technologies lack automated mapping mechanisms in the process of image mapping and structured entity parsing of DXF files. They cannot achieve a precise correspondence between DXF vector coordinates and image pixel coordinates, cannot parse complex entities, and rely on manual operation, which cannot meet the needs of large-scale processing.

Method used

By constructing a precise coordinate mapping and entity parsing mechanism, the DXF file is loaded using Python's ezdxf library, the boundary range of the graphics is calculated, an affine mapping relationship is established, the DXF coordinates are converted into PNG image coordinates, entity attribute information is extracted simultaneously, and structured data is output using the JSON Schema specification.

Benefits of technology

It achieves high-precision image output of DXF files, automatically parses multiple types of CAD entities, supports large-scale processing, provides unified structured data output, and is compatible with artificial intelligence and automation systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121211530B_ABST
    Figure CN121211530B_ABST
Patent Text Reader

Abstract

The application provides a kind of image mapping and structured entity analysis based on DXF vector coordinates, comprising: step 1: loading of DXF file and calculation of graphic boundary;Step 2: determination of target pixel image size;Step 3: establishment of coordinate mapping relationship;Step 4: entity analysis and coordinate conversion;Step 5: synchronous extraction of DXF entity attributes;Step 6: image rendering;Step 7: output of structured data.The application establishes an accurate coordinate affine mapping model and combines a synchronous analysis mechanism for multiple types of CAD entities to achieve high-precision visual expression and geometric semantic preservation of DXF files in image space, thereby establishing a unified bridge between image generation and structured output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer-aided design (CAD) and image processing technology, and in particular to a method for image mapping and structured entity parsing based on DXF vector coordinates. Background Technology

[0002] Currently, CAD design files widely use the DXF (Drawing Exchange Format) to store engineering drawings. The core content of this format is vector coordinate data and entity semantic information. In emerging application scenarios such as artificial intelligence, image recognition, industrial quality inspection, and automated drawing review, it is often necessary to convert DXF format CAD data into standard image formats such as PNG and simultaneously obtain the corresponding structured annotation information. However, existing technologies have significant shortcomings in this conversion and parsing process.

[0003] Existing DXF data processing technologies mainly include three methods: First, the traditional rendering method, which directly exports images through CAD software. However, the exported images lack structured information corresponding to entities, making it difficult to establish the correspondence between DXF vector coordinates and image pixel coordinates, resulting in subsequent artificial intelligence processing being unable to achieve accurate annotation or feature extraction. Second, the geometric analysis method, although some tools can parse geometric entities such as lines, circles, and text in DXF files, cannot achieve accurate mapping between entities and image space, and lacks automatic conversion capabilities. At the same time, it loses the attribute and style information of entities and cannot handle attribute inheritance relationships. Third, the manual annotation and calibration method, which aligns the image with DXF coordinates manually or semi-automatically. This method is not only inefficient but also prone to errors and cannot be adapted to large-scale batch processing scenarios.

[0004] In summary, the core problems of existing technologies are: the lack of an automated mapping mechanism between DXF vector coordinates and image pixel coordinates makes it impossible to accurately extract and synchronously locate entity information in DXF files; the support for parsing complex entities such as curves, fills, and text is incomplete; the lack of a universal structured output structure (such as JSON Schema) makes it difficult to interface with artificial intelligence and automation systems; and existing CAD tools mostly rely on manual operation, which cannot meet the needs of large-scale automatic processing. Summary of the Invention

[0005] This invention provides a method for image mapping and structured entity parsing based on DXF vector coordinates. By constructing an accurate coordinate mapping and entity parsing mechanism, it effectively overcomes the shortcomings of existing technologies.

[0006] To achieve the above objectives, the present invention adopts the following technical solution:

[0007] A method for image mapping and structured entity parsing based on DXF vector coordinates includes the following steps:

[0008] Step 1: Load the DXF file to be processed using Python's ezdxf library, parse the model space of the DXF file, and extract all geometric entities in the model space. These geometric entities include lines, arcs, curves, text, fills, and polylines. Calculate the minimum and maximum values ​​of the coordinates of all geometric entities to obtain the boundary range of the DXF graphic. The boundary range includes the minimum X-axis coordinate. Maximum X-axis coordinate minimum Y-axis coordinate and the maximum coordinate of the Y-axis ; Calculate the original width of the DXF graphic based on the stated boundary range. and original height ,in , ;

[0009] Step 2: Set the pixel width of the target output PNG image and pixel height ;according to and Calculate the horizontal scaling ratio ,according to and Calculate the ratio for vertical scaling. ,Right now , Select and The smaller value in the value is used as the final scaling ratio S to ensure that the DXF graphic in the PNG image is not distorted and is displayed completely;

[0010] Step 3: Establish an affine mapping relationship based on the differences between the DXF coordinate system and the PNG image coordinate system. The DXF coordinate system is a mathematical coordinate system with the origin at the lower left corner and the Y-axis pointing upwards, while the PNG image coordinate system is a screen coordinate system with the origin at the upper left corner and the Y-axis pointing downwards. Subsequently, the DXF coordinates of any point in the DXF graphic can be obtained through this affine mapping relationship. Convert to corresponding PNG image pixel coordinates ;

[0011] Step 4: For each type of geometric entity extracted in Step 1, parse its geometric information and convert the DXF coordinates of each geometric entity into the corresponding pixel coordinates through the affine mapping relationship established in Step 3.

[0012] Step 5: While parsing the geometric information of the geometric entities in Step 4, simultaneously extract the attribute information of each geometric entity. The attribute information includes layer, line type, color, line width, fill style, text font and text size; parse the BYLAYER attribute inheritance relationship and BYBLOCK attribute inheritance relationship of each geometric entity to ensure that the subsequent rendering results are consistent with the original DXF engineering drawing.

[0013] Step 6: Call the matplotlib rendering engine. In the PNG image pixel space set in step 2, draw each geometric entity according to the pixel coordinates converted in step 4 and the attribute information extracted in step 5, and obtain a PNG image that corresponds one-to-one with the original DXF graphic in terms of visual appearance and coordinates.

[0014] Step 7: According to the preset JSON Schema specification, organize the geometric entity types parsed in Step 4, the original DXF coordinates of each geometric entity, the pixel coordinates converted in Step 4, and the attribute information extracted in Step 5 into structured data and output them. The JSON Schema specification defines the field composition, data type, and required fields of the structured data.

[0015] In this specification, the text mentioned in step 1 includes TEXT type text and MTEXT type text, and the polyline includes LWPOLYLINE type polyline and POLYLINE type polyline.

[0016] In this specification, when calculating the minimum and maximum values ​​of the coordinates of all geometric entities in step 1, all coordinate points of each geometric entity extracted in step 1 are traversed, and the X-axis and Y-axis coordinates of each coordinate point are compared to determine... , , and .

[0017] In this specification, when transforming coordinates through affine mapping in step 3, the specific steps are as follows: , Where S is the final scaling ratio determined in step 2. The minimum X-axis coordinate obtained in step 1. The minimum Y-axis coordinate obtained in step 1. The pixel height of the PNG image set for step 2.

[0018] In this instruction manual, during step 4, when parsing geometric entities of text type, the base point coordinates and rotation angle of the text are extracted. And font size; convert the base coordinates of the text to the corresponding pixel coordinates using the affine mapping relationship in step 3, and convert the rotation angle of the text to a rotation angle adapted to the PNG image coordinate system. .

[0019] In this specification, when parsing geometric entities of fill type and polyline type in step 4, equidistant sampling is performed on polylines containing arc segments or spline segments to discretize the continuous curve into a point sequence. The sampling density of the equidistant sampling is set to 0.5 pixels per unit length by default, and the sampling density can be adjusted in the range of 0.1-1.0 pixels. When the curvature of the curve is large, the sampling step size is automatically refined to ensure that the curve formed by the discretized point sequence is smooth and without breaks.

[0020] In this specification, step 4 involves determining the closure of the point sequence after discretization of the fill-type geometric entity. If the distance between the first and last points is less than 1 pixel, it is determined to be a closed region. If the distance between the first and last points is greater than or equal to 1 pixel, the first and last points are automatically connected to form a closed region. The closed region is filled using a scan-line filling algorithm, and anti-aliasing is performed during the filling process to ensure smooth filling edges.

[0021] In this manual, when extracting the color attributes of geometric entities in step 5, the color information in the DXF file is converted into color values ​​in RGB hexadecimal format; when extracting the line width attributes, the line width value is recorded in millimeters.

[0022] In this specification, the required fields of the JSON Schema specification mentioned in step 7 include the geometric entity type, the original DXF coordinates of each geometric entity, and the pixel coordinates corresponding to each geometric entity; the JSON Schema specification supports extending custom attribute fields on the basis of preset fields, and the custom attribute fields include text font and fill mode.

[0023] In this specification, the method for image mapping and structured entity parsing based on DXF vector coordinates further includes step 8: deriving the inverse transformation formula between DXF coordinates and pixel coordinates using the affine mapping relationship established in step 3. The inverse transformation formula is... , ; Select 500 random points in the DXF graphic and verify the accuracy of coordinate mapping through forward and inverse transformations to ensure that the average error of coordinate mapping is ≤0.25 pixels; Use 16 threads to process 100 DXF files containing multiple types of geometric entities concurrently to verify the batch processing speed and ensure that the batch processing speed is more than 3.4 times faster than single-thread processing.

[0024] In summary, the present invention has at least the following beneficial effects:

[0025] Achieve high-precision image output of DXF files: It can realistically reproduce the scale and geometric shape of DXF engineering drawings in pixel space, ensuring that the image and the original drawing are consistent in visual presentation, and solving the problems of image and drawing scale imbalance and geometric information distortion in the existing technology.

[0026] Completes automated parsing and attribute extraction of CAD entities: It can fully support the parsing of various types of CAD entities such as lines, arcs, curves, text, and fills, and simultaneously extracts attribute information such as layer, line type, color, line width, fill style, text font and size. It can also correctly handle CAD attribute inheritance relationships such as BYLAYER and BYBLOCK, avoiding the defects of incomplete entity parsing and attribute information loss in existing technologies.

[0027] Establishing a precise correspondence between vector coordinates and pixel coordinates: By designing an affine mapping model, a one-to-one correspondence between DXF vector coordinates and image pixel coordinates is achieved. Moreover, this mapping is reversible and can achieve bidirectional conversion between image space and engineering coordinate space, providing a coordinate basis for subsequent positioning, annotation and other operations, and solving the problem of chaotic coordinate correspondence in existing technologies.

[0028] It provides a unified structured data output: outputting the type of all entities, the original DXF coordinates, the mapped pixel coordinates and attribute information in a standardized format such as JSON. This output structure follows a unified JSON Schema specification, has format consistency, verifiability and scalability, and can be directly adapted to subsequent tasks such as artificial intelligence model training, automatic image review and feature recognition, thus opening up the interface between DXF data and automated and intelligent systems.

[0029] Adaptable to large-scale automated processing scenarios: The entire process requires no manual intervention, realizing full automation of DXF data conversion, entity parsing, image rendering and structured output. It also supports multi-threaded concurrent processing, significantly improving processing efficiency and solving the problem of existing technologies relying on manual labor and being unable to be applied on a large scale. This expands the application scenarios and value of DXF data in fields such as architectural engineering design, mechanical design, industrial quality inspection, and geographic information systems. Attached Figure Description

[0030] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0031] Figure 1This is a schematic diagram of the image mapping and structured entity parsing method based on DXF vector coordinates involved in this invention.

[0032] Figure 2 This is a schematic diagram illustrating the entire technical process involved in this invention.

[0033] Figure 3 This is a schematic diagram of the entity parsing process involved in this invention.

[0034] Figure 4 This is a schematic diagram of the coordinate mapping and inverse transformation process involved in this invention. Detailed Implementation

[0035] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the embodiments of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.

[0036] The following disclosure provides many different implementations or examples for carrying out different structures of the embodiments of the present invention. To simplify the disclosure of the embodiments of the present invention, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the embodiments of the present invention. Furthermore, reference numerals and / or reference letters may be repeated in different examples of the embodiments of the present invention; such repetition is for simplification and clarity and does not in itself indicate a relationship between the various implementations and / or arrangements discussed.

[0037] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0038] like Figure 1 and Figure 2 As shown, this embodiment provides a method for image mapping and structured entity parsing based on DXF vector coordinates, including the following steps:

[0039] Step 1: Load the DXF file to be processed using Python's ezdxf library, parse the model space of the DXF file, and extract all geometric entities in the model space. These geometric entities include lines, arcs, curves, text, fills, and polylines. Calculate the minimum and maximum values ​​of the coordinates of all geometric entities to obtain the boundary range of the DXF graphic. The boundary range includes the minimum X-axis coordinate. Maximum X-axis coordinate minimum Y-axis coordinate and the maximum coordinate of the Y-axis ; Calculate the original width of the DXF graphic based on the stated boundary range. and original height ,in , ;

[0040] Step 2: Set the pixel width of the target output PNG image and pixel height ;according to and Calculate the horizontal scaling ratio ,according to and Calculate the ratio for vertical scaling. ,Right now , Select and The smaller value in the value is used as the final scaling ratio S to ensure that the DXF graphic in the PNG image is not distorted and is displayed completely;

[0041] Step 3: Establish an affine mapping relationship based on the differences between the DXF coordinate system and the PNG image coordinate system. The DXF coordinate system is a mathematical coordinate system with the origin at the lower left corner and the Y-axis pointing upwards, while the PNG image coordinate system is a screen coordinate system with the origin at the upper left corner and the Y-axis pointing downwards. Subsequently, the DXF coordinates of any point in the DXF graphic can be obtained through this affine mapping relationship. Convert to corresponding PNG image pixel coordinates ;

[0042] Step 4: For each type of geometric entity extracted in Step 1, parse its geometric information and convert the DXF coordinates of each geometric entity into the corresponding pixel coordinates through the affine mapping relationship established in Step 3.

[0043] Step 5: While parsing the geometric information of the geometric entities in Step 4, simultaneously extract the attribute information of each geometric entity. The attribute information includes layer, line type, color, line width, fill style, text font and text size; parse the BYLAYER attribute inheritance relationship and BYBLOCK attribute inheritance relationship of each geometric entity to ensure that the subsequent rendering results are consistent with the original DXF engineering drawing.

[0044] Step 6: Call the matplotlib rendering engine. In the PNG image pixel space set in step 2, draw each geometric entity according to the pixel coordinates converted in step 4 and the attribute information extracted in step 5, and obtain a PNG image that corresponds one-to-one with the original DXF graphic in terms of visual appearance and coordinates.

[0045] Step 7: According to the preset JSON Schema specification, organize the geometric entity types parsed in Step 4, the original DXF coordinates of each geometric entity, the pixel coordinates converted in Step 4, and the attribute information extracted in Step 5 into structured data and output them. The JSON Schema specification defines the field composition, data type, and required fields of the structured data.

[0046] In some embodiments, the text mentioned in step 1 includes text of type TEXT and text of type MTEXT, and the polyline includes polyline of type LWPOLYLINE and polyline of type POLYLINE.

[0047] In some embodiments, when calculating the minimum and maximum values ​​of all geometric entity coordinates in step 1, all coordinate points of each geometric entity extracted in step 1 are traversed, and the X-axis and Y-axis coordinates of each coordinate point are compared to determine... , , and .

[0048] In some embodiments, when transforming coordinates through an affine mapping relationship in step 3, specifically as follows: , Where S is the final scaling ratio determined in step 2. The minimum X-axis coordinate obtained in step 1. The minimum Y-axis coordinate obtained in step 1. The pixel height of the PNG image set for step 2.

[0049] In some embodiments, when parsing the geometric entity of the text type in step 4, the base point coordinates and rotation angle of the text are extracted. And font size; convert the base coordinates of the text to the corresponding pixel coordinates using the affine mapping relationship in step 3, and convert the rotation angle of the text to a rotation angle adapted to the PNG image coordinate system. .

[0050] In some embodiments, when parsing geometric entities of fill type and polyline type in step 4, equidistant sampling is performed on polylines containing arc segments or spline segments to discretize the continuous curve into a point sequence. The sampling density of the equidistant sampling is set to 0.5 pixels per unit length by default, and the sampling density can be adjusted in the range of 0.1-1.0 pixels. When the curvature of the curve is large, the sampling step size is automatically refined to ensure that the curve formed by the discretized point sequence is smooth and without breaks.

[0051] In some embodiments, in step 4, the point sequence after discretization of the fill-type geometric entity is judged for closure. If the distance between the first and last points is less than 1 pixel, it is determined to be a closed region. If the distance between the first and last points is greater than or equal to 1 pixel, the first and last points are automatically connected to form a closed region. The closed region is filled using a scan line filling algorithm, and anti-aliasing is performed during the filling process to ensure smooth filling edges.

[0052] In some embodiments, when extracting the color attributes of geometric entities in step 5, the color information in the DXF file is converted into color values ​​in RGB hexadecimal format; when extracting the line width attributes, the line width value is recorded in millimeters.

[0053] In some embodiments, the required fields of the JSON Schema specification in step 7 include the geometric entity type, the original DXF coordinates of each geometric entity, and the pixel coordinates corresponding to each geometric entity; the JSON Schema specification supports extending custom attribute fields on the basis of preset fields, and the custom attribute fields include text font and fill mode.

[0054] In some embodiments, the method for image mapping and structured entity parsing based on DXF vector coordinates further includes step 8: deriving the inverse transformation formula between DXF coordinates and pixel coordinates using the affine mapping relationship established in step 3, wherein the inverse transformation formula is... , ; Select 500 random points in the DXF graphic and verify the accuracy of coordinate mapping through forward and inverse transformations to ensure that the average error of coordinate mapping is ≤0.25 pixels; Use 16 threads to process 100 DXF files containing multiple types of geometric entities concurrently to verify the batch processing speed and ensure that the batch processing speed is more than 3.4 times faster than single-thread processing.

[0055] The technical concept of this invention is as follows:

[0056] The core of this invention lies in constructing precise coordinate transformation relationships and preserving the geometric and attribute information of entities while rendering images, thereby achieving synchronous parsing of images and vectors, as detailed below:

[0057] Step 1: Loading the DXF file and calculating the graphics boundary

[0058] This invention first uses the ezdxf library of Python (or other CAD APIs or custom parsers to adapt to different formats) to perform structured parsing of the input DXF file, extracts all entity objects using vector information in the CAD file, and calculates the minimum bounding box of the overall graphic.

[0059] 1.1 Parse the model space of the DXF file and read all geometric entities, such as lines (LINE), arcs (ARC), curves (SPLINE), text (TEXT, MTEXT), and hatches (HATCH).

[0060] 1.2 Calculate the minimum and maximum values ​​of all entity coordinates to obtain the boundary range of the DXF file:

[0061] ;

[0062] 1.3 Obtain the original width of the drawing. With height :

[0063] ; ;

[0064] 1.4 This bounding box serves as a reference for coordinate mapping, ensuring consistency in subsequent pixel coordinate transformations.

[0065] Step 2: Determining the target pixel image size

[0066] 2.1. Set the pixel width and height of the target output PNG image: ;

[0067] 2.2. Calculate the scaling ratio based on the aspect ratio of the DXF file: , ;

[0068] Under normal circumstances, to ensure that the image is not distorted, the following can be adopted: That is, scaling proportionally to fully display the graphic content. When the aspect ratio of the DXF graphic is inconsistent with the target image, proportional scaling is performed with the priority of maintaining full display.

[0069] Step 3: Establishing coordinate mapping relationships

[0070] The DXF coordinate system uses a mathematical coordinate system, with the origin located at the lower left corner and the Y-axis pointing upwards;

[0071] The PNG image uses the screen coordinate system, with the origin at the top left corner and the Y-axis pointing downwards.

[0072] To ensure consistent entity positions, this invention designs an affine mapping relationship as follows:

[0073] Let any point in DXF be: ;

[0074] The mapped pixel coordinates are: ;

[0075] The mapping formula is: , ;

[0076] in: : DXF project coordinates; Pixel image coordinates; Scaling ratio; Minimum coordinates for a DXF graphic; : The pixel height of the target image.

[0077] This mapping simultaneously performs translation (translating the DXF origin to the top left corner of the image) and Y-axis reversal, achieving a strict correspondence between DXF engineering coordinates and pixel coordinates.

[0078] Step 4: Entity Analysis and Coordinate Transformation

[0079] For different entity types in DXF, this invention performs geometric and attribute information parsing separately, and simultaneously converts their coordinates to pixel coordinates. The entity parsing process is as follows: Figure 3 As shown.

[0080] 1. Line

[0081] Original point: ;

[0082] Transition point: , respectively, are calculated using the affine formulas mentioned above.

[0083] 2. Circle, Arc, Ellipse

[0084] Original center point and radius → Mapped center point and scaled radius;

[0085] The starting and ending angles of the arc remain unchanged, and the geometric shape maintains a consistent proportion in pixel space.

[0086] 3. Text (TEXT, MTEXT)

[0087] Extract the text's base point coordinates, rotation angle, and font size;

[0088] Perform coordinate transformation on the base point while preserving text attributes;

[0089] The rotation angle is mapped using: To adapt to the image coordinate system orientation.

[0090] 4. HATCH and Polylines (LWPOLYLINE, POLYLINE)

[0091] For filled entities and polyline entities in DXF files, curve discretization and pixel-level contour reconstruction algorithms are used to achieve accurate conversion from vector data to image space.

[0092] Curve discretization: Isochronous sampling is performed on multi-segment lines containing arcs, spline segments, etc., discretizing the continuous curve into a point sequence. The default sampling density is 0.5 pixels per unit length, which can be adjusted within the range of 0.1–1.0 to balance accuracy and performance. When the curve curvature is large, the system automatically refines the sampling step size to ensure a smooth, unbroken shape.

[0093] Closed region detection and contour reconstruction: The point set is checked for closure at both ends. If the distance between the first and last points is less than 1 pixel, it is considered a closed region; otherwise, lines are automatically added to form a closed loop. Closed regions are filled using a scanline fill algorithm to achieve pixel-level contour drawing, ensuring continuous and closed edges.

[0094] Rendering and Output: The fill uses anti-aliasing to ensure smooth edges and supports multi-threaded concurrent computation (default concurrency threshold 16). The output includes two parts: pixel image and structured data, the latter recording information such as entity type, layer, color, coordinate point set, fill method, and sampling density.

[0095] Step 5: Synchronous extraction of DXF entity attributes

[0096] This invention, while parsing geometric information, also simultaneously parses and retains the entity's attribute information, including but not limited to: layer, linetype, color, lineweight, fill style, and text font and size. Furthermore, it correctly parses the inheritance relationships of CAD attributes such as BYLAYER and BYBLOCK, ensuring that the rendering results are consistent with the engineering drawings.

[0097] Step 6: PNG image rendering

[0098] By calling a rendering engine (such as matplotlib), the entity is drawn in the target pixel space according to its geometry and attribute information:

[0099] Straight lines, curves, text, and fills are strictly aligned with engineering coordinates in the pixel image;

[0100] Rendering is performed using line types, colors, etc., that correspond to the attribute information.

[0101] This process ensures a one-to-one visual and coordinate correspondence between the final PNG image and the original DXF drawing.

[0102] Step 7: Output of Structured Data

[0103] 7.1 To ensure the consistency and scalability of structured output data, this invention defines a unified JSONSchema specification to constrain the field composition, data type, and required fields of the DXF entity parsing results, including: entity type (such as LINE, CIRCLE, TEXT, etc.), original DXF coordinates, mapped pixel coordinates, and attribute information.

[0104] (1) Data Example: The output example of a single CAD entity after parsing is as follows:

[0105] {

[0106] "entity_type":"LINE",

[0107] "layer":"0",

[0108] "lineweight":-1,

[0109] "color":"#000000",

[0110] "dxf_coords":[[120.5,300.2],[600.3,450.0]],

[0111] "pixel_coords":[[50,800],[450,600]],

[0112] "linetype":"CONTINUOUS"

[0113] }

[0114] This example represents a straight line entity, which contains attribute information such as the original DXF coordinates, mapped pixel coordinates, line type, color, and line width.

[0115] (2) Schema specification definition: The above data structure follows the following schema specification:

[0116] {

[0117] "$schema":"http: / / json-schema.org / draft-07 / schema#",

[0118] "title":"DXFEntitySchema",

[0119] "type":"object",

[0120] "properties":{

[0121] "entity_type":{"type":"string","description":"Entity type, such as LINE, CIRCLE, TEXT, etc."},

[0122] "layer":{"type":"string","description":"name of the layer"},

[0123] "lineweight":{"type":"number","description":"Line weight value in millimeters"},

[0124] "color":{"type":"string","description":"Color value, RGB hexadecimal format"},

[0125] "dxf_coords":{

[0126] "type":"array",

[0127] "items":{"type":"array","items":{"type":"number"}},

[0128] "description": "List of original DXF coordinate points"

[0129] },

[0130] "pixel_coords":{

[0131] "type":"array",

[0132] "items":{"type":"array","items":{"type":"number"}},

[0133] "description": "List of mapped pixel coordinates"

[0134] },

[0135] "linetype":{"type":"string","description":"Line style, such as CONTINUOUS, DASHED, etc."}

[0136] },

[0137] "required":["entity_type","dxf_coords","pixel_coords"]

[0138] }

[0139] (3) Design Description: This schema specification defines the basic fields that each entity must contain and allows for the extension of custom attributes (such as text font, fill mode, etc.) in properties to adapt to multiple types of CAD entities. Through this standardized definition, all output data can achieve:

[0140] Format consistency: Different entity types follow the same data constraints;

[0141] Verifiability: The correctness of the structure can be automatically detected using JSON Schema validation tools;

[0142] Scalability: Supports adding new attribute fields without breaking the original structure;

[0143] AI-friendly: It facilitates direct reading and training of subsequent deep learning models.

[0144] Step 8: Verification of the invertibility and application of coordinate mapping

[0145] 8.1 Because this technique uses linear affine transformation, therefore:

[0146] ; ;

[0147] This reversible mapping ensures bidirectional transformation between image space and engineering coordinate space, enabling downstream AI recognition, drawing review, annotation, and write-back to CAD. The coordinate mapping and inverse transformation process is as follows: Figure 4 As shown.

[0148] 8.2 To verify the effectiveness of this technology, the following experiments were conducted:

[0149] Coordinate mapping error test: 500 random points were selected, and the average error was ≤0.25 pixels;

[0150] Entity resolution accuracy: In 100 DXF files containing multiple entities, the recognition rate was 100% for straight lines, 99.6% for arcs, and 98.7% for text.

[0151] Multi-threaded performance test: Under 16-thread concurrency conditions, batch processing speed is improved by 3.4 times.

[0152] The embodiments described above are for illustrative purposes only and are not intended to limit the invention. Therefore, any changes in numerical values ​​or substitutions of equivalent elements should still fall within the scope of this invention.

[0153] The above detailed description will enable those skilled in the art to understand that the present invention can indeed achieve the aforementioned objectives and has complied with the provisions of the Patent Law.

[0154] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the invention. The above descriptions are merely preferred embodiments of the invention and are not intended to limit the invention. It should be noted that any modifications, equivalent substitutions, and improvements made within the spirit and principles of the invention should be included within the scope of protection of the invention.

[0155] It should be noted that the above description of the process is for illustrative purposes only and does not limit the scope of this specification. Those skilled in the art can make various modifications and changes to the process under the guidance of this specification. However, these modifications and changes remain within the scope of this specification.

[0156] The basic concepts have been described above. Obviously, for those skilled in the art who have read this application, the above disclosure is merely illustrative and does not constitute a limitation of this application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and corrections to this application. Such modifications, improvements, and corrections are suggested in this application, and therefore, such modifications, improvements, and corrections still fall within the spirit and scope of the exemplary embodiments of this application.

[0157] Furthermore, this application uses specific terms to describe its embodiments. For example, "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic related to at least one embodiment of this application. Therefore, it should be emphasized and noted that "an embodiment," "one embodiment," or "an alternative embodiment" mentioned twice or more in different positions in this specification do not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of this application can be appropriately combined.

[0158] Furthermore, those skilled in the art will understand that aspects of this application can be described and illustrated through several patentable types or situations, including any new and useful combination of processes, machines, products, or substances, or any new and useful improvements thereof. Therefore, aspects of this application can be implemented entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or a combination of hardware and software. All of the above hardware or software can be referred to as a “unit,” “module,” or “system.” Furthermore, aspects of this application can take the form of a computer program product embodied in one or more computer-readable media, wherein computer-readable program code is contained therein.

[0159] The computer program code required for the operation of each part of this application can be written in any one or more programming languages, including object-oriented programming languages ​​such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB.NET, and Python; general programming languages ​​such as C; Visual Basic, Fortran2103, Perl, COBOL2102, PHP, and ABAP; dynamic programming languages ​​such as Python, Ruby, and Groovy; or other programming languages. This program code can run entirely on the user's computer, or as a standalone software package on the user's computer, or partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer via any network, such as a local area network (LAN) or wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service such as Software as a Service (SaaS).

[0160] Furthermore, unless expressly stated in the claims, the order of processing elements and sequences, the use of numbers and letters, or other names described in this application are not intended to limit the order of the processes and methods of this application. Although some currently considered useful embodiments of the invention have been discussed in the foregoing disclosure by way of various examples, it should be understood that such details are for illustrative purposes only, and the appended claims are not limited to the disclosed embodiments; rather, the claims are intended to cover all modifications and equivalent combinations that conform to the substance and scope of the embodiments of this application. For example, although the implementation of the various components described above can be embodied in a hardware device, it can also be implemented as a purely software solution, such as an installation on an existing server or mobile device.

[0161] Similarly, it should be noted that, in order to simplify the description of the present application and thus aid in the understanding of one or more embodiments of the invention, the foregoing description of the embodiments of the present application sometimes combines multiple features into a single embodiment, drawing, or description thereof. However, this approach of the present application should not be construed as reflecting an intention that the claimed subject matter requires more features than expressly recited in each claim. Rather, the subject of the invention should possess fewer features than in any single embodiment described above.

Claims

1. A method for image mapping and structured entity parsing based on DXF vector coordinates, characterized in that, include: Step 1: Load the DXF file to be processed, parse the model space of the DXF file, extract all geometric entities in the model space, calculate the minimum and maximum values ​​of the coordinates of all geometric entities, obtain the boundary range of the DXF graphic, and determine the original width and original height of the DXF graphic based on the boundary range. Step 2: Set the pixel space size of the target output image, including pixel width and pixel height. Calculate the horizontal scaling ratio and vertical scaling ratio respectively. The horizontal scaling ratio is the ratio of the original width of the DXF graphic to the pixel width of the image. The vertical scaling ratio is the ratio of the pixel height of the image to the original height of the DXF graphic. Select the smaller value between the horizontal scaling ratio and the vertical scaling ratio as the final scaling ratio. Step 3: Establish an affine mapping relationship based on the differences between the DXF coordinate system and the image coordinate system; Step 4: Analyze the geometric information of various geometric entities extracted in Step 1, and convert the DXF coordinates of each geometric entity into the corresponding pixel coordinates through affine mapping. Step 5: Extract the attribute information of each geometric entity and parse the inheritance relationship of the BYLAYER and BYBLOCK attributes of each geometric entity; Step 6: Call the rendering engine. In the image pixel space set in Step 2, draw each geometric entity according to the pixel coordinates converted in Step 4 and the attribute information and attribute inheritance relationship extracted in Step 5, and obtain an image that corresponds one-to-one with the original DXF graphic visuals and coordinates. Step 7: According to the preset JSON Schema specification, organize the geometric entity type, the DXF coordinates of each geometric entity, the pixel coordinates converted in Step 4, and the attribute information extracted in Step 5 into structured data, and output it together with the image obtained in Step 6.

2. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, The types of geometric entities include straight lines, arcs, curves, text, fills, and polylines. Text includes TEXT type text and MTEXT type text, and polylines include LWPOLYLINE type polylines and POLYLINE type polylines.

3. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, The DXF coordinate system is a mathematical coordinate system with the origin at the lower left corner and the Y-axis pointing upwards, while the image coordinate system is a screen coordinate system with the origin at the upper left corner and the Y-axis pointing downwards.

4. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, The specific transformation method of the affine mapping relationship in step 3 is as follows: after subtracting the minimum X-axis coordinate from the X value of the DXF coordinate, multiply it by the final scaling ratio to obtain the X coordinate of the corresponding pixel; subtract (the product of the minimum Y-axis coordinate from the Y value of the DXF coordinate and the final scaling ratio) from the pixel height of the image to obtain the Y coordinate of the corresponding pixel.

5. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, In step 4, when parsing the geometric entity of the text type, the base point coordinates, rotation angle and font size of the text are extracted. The base point coordinates are converted into pixel coordinates through the mapping relationship in step 3, and the rotation angle is adjusted to fit the image coordinate system.

6. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, In step 4, when parsing filled and polyline type geometric entities, the parts containing arc segments or spline segments are sampled at equal intervals to discrete them into a point sequence. The sampling density is set to 0.5 pixels per unit length by default.

7. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, For the discrete point sequence of filled geometric entities, the closure of the first and last points is judged: if the distance between the first and last points is less than 1 pixel, it is determined to be a closed region; otherwise, the line is automatically filled to form a closed region. The closed region is processed by the scan line filling algorithm and anti-aliasing is performed.

8. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, The attribute information includes layer, line type, color, line width, fill style, text font and size.

9. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, In step 7, the JSON Schema specification defines the data's field composition, type, and required fields. Required fields include the geometric entity type, the original DXF coordinates, and the corresponding pixel coordinates.

10. The method for image mapping and structured entity parsing based on DXF vector coordinates according to claim 1, characterized in that, It also includes step 8: deriving the inverse transformation method between DXF coordinates and pixel coordinates through the affine mapping relationship in step 3, selecting random points to verify the accuracy of coordinate mapping, and using multi-threaded concurrent processing to improve batch processing efficiency.

Citation Information

Patent Citations

  • Range image-based 3D spatial data processing method and device

    CN101533529A

  • Method for quickly drawing SVG format map according to DXF format engineering graph

    CN108009346A