A CAD drawing processing and loading method, device, equipment and medium
By cutting and formatting the CAD source file into multiple images and loading them using the OpenSeadragon plugin, the problem of Canvas' inability to scale and modify CAD drawings without distortion is solved, enabling efficient online browsing and multi-layer display.
Patent Information
- Application Number
- CN202311265082.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2043-09-26
AI Technical Summary
In existing technologies, Canvas cannot achieve distortion-free zooming and viewing of CAD drawings, nor can it be modified on the web, especially in displaying hidden information in CAD drawings.
The CAD source file is cut into multiple initial drawings, converted into a first image in a preset format and a first feature code is added. Then, it is cut into a second image and a second feature code is added. The second image of the target area is loaded through the OpenSeadragon plugin to enable online browsing and modification.
It improves the efficiency of online CAD file browsing, provides smooth graphic viewing and multi-layer overlay functions, and enhances page response speed and information richness.
Smart Images

Figure CN117312699B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to a CAD drawing processing and loading method, device, equipment and medium. BACKGROUND
[0002] In the server end and the Web front end (terminal) of the network node, or between terminals, the display and operation of the CAD (Computer Aided Design) drawing object need to be supported by the given plug-in. At present, the Canvas object is used for the Web front end display without plug-in support of CAD. Canvas is a tag first added in HTML5, which is mainly used for real-time generation of images on a web page, and can operate the image content. In theory, Canvas can constitute a bitmap that can be operated by JavaScript.
[0003] For a bitmap, it cannot realize distortion-free scaling and viewing of the displayed drawing. In addition, for Canvas, it can only display CAD objects, but cannot modify them on the Web end. In particular, Canvas can only display CAD primitives, but cannot display more information hidden in the drawing. SUMMARY
[0004] The present application provides a CAD drawing processing and loading method, device, equipment and medium, which can improve the online browsing efficiency of CAD files.
[0005] In a first aspect, the present application provides a CAD drawing processing method, which adopts the following technical scheme:
[0006] A CAD drawing processing method includes the following steps:
[0007] Collecting a CAD source file, and cutting the source file into a plurality of initial drawings;
[0008] Converting each initial drawing into a first picture in a preset format according to a preset magnification, and then adding a first feature code to each first picture;
[0009] Cutting each first picture into a plurality of second pictures, and then adding a second feature code to each second picture;
[0010] Uploading the second picture carrying the second feature code to a server.
[0011] Further, the initial drawing is a square drawing, and if the shape of the source file is rectangular, the source file is padded to be consistent in height and width before being cut.
[0012] Further, the preset magnifications include at least one of 1x, 2x, 2 2 x, …, 2 n x, where n is an integer.
[0013] The preset format includes png format, JPEG format, dds format, PSD format, PDT format, WebP format, XMP format, GIF format, BMP format, SVG format, or TIFF format.
[0014] Further, when the preset magnification is 2 n x, the size of the first picture is 2 n (512*512)px.
[0015] Further, the cutting of each first picture into a plurality of second pictures includes:
[0016] The plurality of first pictures of different magnifications are cut into a plurality of second pictures at the size of the first picture of 1x magnification.
[0017] Further, the first feature code includes coordinates of the first picture in a first coordinate system, which is established based on the initial drawing sheet.
[0018] The second feature code includes coordinates of the second picture in a second coordinate system, which is established based on the first picture.
[0019] In a second aspect, the application provides a CAD drawing loading method, which adopts the following technical solution:
[0020] A CAD drawing loading method, which applies the CAD drawing processing method described above, includes the following steps:
[0021] Creating an OpenSeadragon plug-in interface;
[0022] Configuring the size of the target loaded picture, a set of magnification ratios, a file source, and a dynamic path;
[0023] According to the second feature code, the second picture of a preset magnification corresponding to the target area is loaded through the OpenSeadragon plug-in.
[0024] In a third aspect, the application provides a CAD drawing processing and loading device, which adopts the following technical solution:
[0025] A CAD drawing processing and loading device includes:
[0026] An input module for inputting a CAD source file and configuring the size of the target loaded picture, a set of magnification ratios, a file source, and a dynamic path;
[0027] a first cutting module, configured to cut the source file into a plurality of initial drawings;
[0028] a conversion module, configured to convert each of the initial drawings into a first picture in a preset format according to a preset magnification and add a first feature code;
[0029] a second cutting module, configured to cut each of the first pictures into a plurality of second pictures and add a second feature code;
[0030] an uploading module, configured to upload the second pictures carrying the second feature codes to a server;
[0031] a loading module, configured to load, according to the second feature codes, the second pictures of a preset magnification corresponding to a target area through an OpenSeadragon plug-in.
[0032] In a fourth aspect, the present application provides a computer device, which adopts the technical scheme as follows:
[0033] A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method of the first aspect.
[0034] In a fifth aspect, the present application provides a computer readable storage medium, which adopts the technical scheme as follows:
[0035] A computer readable storage medium, storing a computer program capable of being loaded and executed by a processor to implement any one of the methods of the first aspect.
[0036] In summary, the present application has at least one of the following beneficial technical effects:
[0037] The CAD drawing processing and loading method, device, equipment and medium provided by the application can obtain a plurality of first pictures by cutting the collected CAD source file into a plurality of drawings and performing format conversion according to a preset magnification, the first picture has a first feature code, and the first feature code is used to represent the position of the first picture in the CAD source file; through the format conversion of the preset magnification, the picture corresponding to the magnification required by the scaling of the CAD drawing can be cut out, then the first picture is cut into a plurality of second pictures, and a second feature code is added to represent the specific position of the second picture in the CAD source file, the second picture carrying the second feature code is uploaded to a server for use by a user, when the user needs to browse online, according to the picture magnification selected by the user, the second picture corresponding to the specified area of the user is preferentially loaded from the server, and the second picture near the specified area is cached, through the fragmentation processing of the CAD, the CAD graphics are all made into picture slices according to the proportion of each scaling level, and then the picture slices are spliced and restored in the browser according to the picture number. BRIEF DESCRIPTION OF DRAWINGS
[0038] Figure 1 FIG. 1 is a flowchart of a CAD drawing processing method in an embodiment of the application.
[0039] Figure 2 FIG. 2 is a flowchart of a CAD drawing loading method in an embodiment of the application. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical scheme and advantages of the application clearer, the application is further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the application and not to limit the application.
[0041] An embodiment of the application discloses a CAD drawing processing method, comprising the following steps:
[0042] S101: collecting a CAD source file and cutting the source file into a plurality of initial drawings;
[0043] In this embodiment, after the CAD source file which needs to be displayed based on Web is collected, the CAD source file needs to be preprocessed first. Optionally, the CAD source file can be equally divided into a plurality of square drawings according to the aspect ratio of the view area of the CAD source file, and then the edges of the CAD source file are filled, so that a plurality of initial drawings with the same size and consistent shape can be obtained. The cutting of the CAD source file can improve the efficiency of subsequent format conversion and magnification conversion.
[0044] S102: converting each initial drawing into a first picture in a preset format according to a preset magnification, and then adding a first feature code to each first picture;
[0045] In the embodiment, the initial drawing needs to be enlarged according to a preset magnification, and the preset magnification includes at least one of 1 times, 2 times, 2 2 times, …, 2 n times, where n is an integer; for example, each initial drawing is enlarged to 1, 2, 4, 8, 16, 32, and 64 times, assuming that the picture size corresponding to 1 time is 512*512px, the picture size corresponding to 2 times is 1024*1024px, and so on, and the picture size corresponding to 64 times is 32768*32768px. Then, the second pictures are printed according to 1, 2, 4, 8, 16, 32, and 64 times and saved in corresponding folders.
[0046] In one embodiment of the present application, the preset format of the second picture includes png format, JPEG format, dds format, PSD format, PDT format, WebP format, XMP format, GIF format, BMP format, SVG format, or TIFF format. Preferably, the present application adopts png format or jpg format to implement the above method.
[0047] S103: cutting each first picture into a plurality of second pictures, and then adding a second feature code to each second picture;
[0048] In the embodiment, the first picture can be cut into a plurality of second pictures according to a preset cutting rule. The significance of cutting in this step is to make the picture sizes under all magnifications basically consistent, so that there is no problem such as slow loading in the switching process from a low magnification to a high magnification.
[0049] Specifically, a python cutting program can be written to cut the pictures of various magnifications into a plurality of uniform size graphics through the python program; the program input source is the first picture under each magnification, and the main function of the program is to cut the pictures of various magnifications into 512*512px standard size according to the 1 times magnification size (512*512px) and save them in the corresponding magnification folder according to the file naming method of “xx_xx.png”, where xx_xx is the picture coordinate defined by the technical solution of the present application, that is, the second feature code.
[0050] In one embodiment of the present application, the first feature code includes coordinates of the first picture in a first coordinate system, and the first coordinate system is established based on the initial drawing;
[0051] The second feature code includes coordinates of the second picture in a second coordinate system, and the second coordinate system is established based on the first picture.
[0052] Wherein, since the initial drawing paper is a square drawing paper, the origin of the first coordinate system can be one of the four vertices of the initial drawing paper, and the coordinate axis of the first coordinate system can be the edge or the extension line of the edge of the initial drawing paper, and similarly, the origin of the second coordinate system can be one of the four vertices of the first drawing paper, and the coordinate axis of the second coordinate system can be the edge or the extension line of the edge of the first drawing paper.
[0053] S104: uploading the second picture carrying the second feature code to a server.
[0054] In the embodiment, the folder composed of the second pictures cut in S103 is compressed and uploaded to the server, and the server decompresses and stores the folder into a static resource database for the user to retrieve.
[0055] S105: 5, dynamically loading the second picture through the OpenSeadragon plug-in;
[0056] In the embodiment, the OpenSeadragon plug-in, i.e., a network-based high-resolution scalable image viewer, is introduced into the web front-end page, which is implemented in pure JavaScript and is suitable for desktops and mobile devices. The user can configure the base picture size, maximum and minimum zoom ratio, picture file source and dynamic path through the OpenSeadragon plug-in, and realize the dynamic picture resource loading of the view area based on the viewing ratio.
[0057] In one of the embodiments of the application, according to the user demand, under the OpenSeadragon dynamic page, svg elements such as path, text, rect and other vectorized graphic elements can be added; the added svg elements can be combined with the base map together and scaled synchronously to realize the dynamic scaling function of the entire page.
[0058] The application further discloses a CAD drawing paper processing and loading device.
[0059] A CAD drawing paper processing and loading device comprises:
[0060] An input module is configured to input a CAD source file, configure the size of a target loaded picture, a zoom ratio set, a file source and a dynamic path;
[0061] A first cutting module is configured to cut the source file into a plurality of initial drawing papers;
[0062] A conversion module is configured to convert each initial drawing paper into a first picture in a preset format according to a preset ratio and add a first feature code;
[0063] A second cutting module is configured to cut each first picture into a plurality of second pictures and add a second feature code.
[0064] uploading a second picture carrying the second feature code to a server;
[0065] loading the second picture corresponding to the target region with the preset magnification according to the second feature code through the OpenSeadragon plug-in.
[0066] The CAD drawing processing and loading device provided in the embodiment of the present application can implement any of the CAD drawing processing method and loading method described above, and the specific working process of each module in the CAD drawing processing and loading device can refer to the corresponding process in the method embodiment described above.
[0067] In several embodiments provided in the present application, it should be understood that the provided method and system can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for example, the division of a certain module is merely a logical functional division, and actual implementation can have another division manner, for example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed.
[0068] The embodiment of the present application further discloses a computer device.
[0069] The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the xx method as described above when executing the computer program.
[0070] The embodiment of the present application further discloses a computer readable storage medium.
[0071] The computer readable storage medium stores a computer program capable of being loaded and executed by a processor to implement any of the xx methods as described above.
[0072] The computer readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, device or apparatus; the program code contained in the computer readable medium can be transmitted by any appropriate medium, including but not limited to wireless, wire, optical cable, RF, etc., or any appropriate combination of the above.
[0073] In summary, in the conventional way, the CAD source file is directly uploaded for viewing the CAD file through the Web browser, which requires a computer with good hardware configuration, and has poor real-time zooming effect, slow page response speed, and no function of superimposing multiple layers. The technical solution of the present application provides a CAD drawing processing and loading method, device, equipment and medium, which cuts the collected CAD source file into multiple drawings, facilitates cutting and format and magnification conversion of the CAD source file, and users or operation and maintenance personnel can preset the conversion magnification and format of the picture through the OpenSeadragon plug-in, configure the basic picture size, maximum and minimum zoom magnification, picture file source and dynamic path; after the configuration is completed, format conversion is performed according to the preset magnification, a plurality of first pictures can be obtained, the CAD source file is lightened, and all CAD contents are pictureized; the first picture has a first characteristic code, and the first characteristic code is used to represent the position of the first picture in the CAD source file; through the format conversion of the preset magnification, the corresponding magnification picture required for the zooming of the CAD drawing can be cut out, then the first picture is cut into a plurality of second pictures, and a second characteristic code is added to represent the specific position of the second picture in the CAD source file, the second picture carrying the second characteristic code is uploaded to the server for user use, when the user needs to browse online, according to the picture magnification selected by the user, the second picture corresponding to the specified area of the user is preferentially loaded from the server, and the second picture near the specified area is cached. Through the fragmentation processing of the CAD, the CAD graphics are all made into picture slices according to the proportion of each zooming level, and then the picture slices are spliced and restored according to the picture number in the browser. Not only can smooth CAD graphic viewing be provided on the browser side, but also multiple layers can be superimposed according to the demand, so that the page information is more rich.
[0074] It should be noted that in the above embodiments, the description of each embodiment has its emphasis, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0075] The above are preferred embodiments of the present application, and are not intended to limit the protection scope of the present application. Any feature disclosed in the specification (including the abstract and the drawings) can be replaced by other equivalent or similar features, unless specifically described. That is, each feature is only an example of a series of equivalent or similar features, unless specifically described.
Claims
1. A CAD drawing processing method, characterized by, The method comprises the following steps: collecting CAD source files, cutting the source files into initial drawings; converting each initial drawing into a first picture in a preset format according to different preset magnifications, and then adding a first feature code to each first picture; cutting each first picture into second pictures, and then adding a second feature code to each second picture; uploading the second pictures carrying the second feature codes to a server; the first feature code comprises coordinates of the first picture in a first coordinate system, which is established based on the initial drawing; the second feature code comprises coordinates of the second picture in a second coordinate system, which is established based on the first picture; the method further comprises a CAD drawing loading step: creating an OpenSeadragon plug-in interface; configuring the size of a target loaded picture, a zoom magnification set, a file source and a dynamic path; loading a second picture of a preset magnification corresponding to a target area according to the second feature code through the OpenSeadragon plug-in.
2. The method of claim 1, wherein, The initial drawing is a square drawing, and if the shape of the source file is rectangular, the source file is padded to be consistent in height and width before being cut.
3. The method of claim 1, wherein, The preset magnifications include at least one of 1 times, 2 times, 2 2 times, …, 2 n times, wherein n is an integer. The preset format comprises png format, JPEG format, dds format, PSD format, PDT format, WebP format, XMP format, GIF format, BMP format, SVG format or TIFF format.
4. The method of claim 3, wherein, The preset scale is 2 n The size of the first picture is 2 n (512*512) px.
5. The method of claim 1, wherein, The cutting of each first picture into second pictures comprises: cutting a plurality of first pictures of different magnifications into second pictures in the size of a first picture of 1x magnification.
6. A CAD drawing processing and loading apparatus, characterized by comprising: The method comprises: an input module configured to input a CAD source file and configure the size of a target loaded picture, a zoom magnification set, a file source and a dynamic path; a first cutting module configured to cut the source file into initial drawings; a conversion module configured to convert each initial drawing into a first picture in a preset format according to different preset magnifications and add a first feature code; the first feature code comprises coordinates of the first picture in a first coordinate system, which is established based on the initial drawing; a second cutting module configured to cut each first picture into second pictures and add a second feature code; the second feature code comprises coordinates of the second picture in a second coordinate system, which is established based on the first picture; an uploading module configured to upload the second pictures carrying the second feature codes to a server; a loading module configured to configure the size of a target loaded picture, a zoom magnification set, a file source and a dynamic path through an OpenSeadragon plug-in according to the second feature code, and load a second picture of a preset magnification corresponding to a target area.
7. A computing device, characterized by: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the method according to any one of claims 1 to 5 when executing the program.
8. A computer-readable storage medium, characterized in that: The computer program stored in the memory can be loaded and executed by the processor to implement the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Browsing method and system of large drawings, server and computer-readable storage medium
CN108920048A