Automatic batch filling method for attribute information of frame title bar of CAD drawingTechnical Field
The invention relates to the field of CAD frame title bar information filling methods, in particular to an automatic batch filling method for frame title bar information of CAD drawings.
Background
Because CAD has advantages of universality, usability and the like, in the power design industry, the drawing work of the design drawing is mainly completed through CAD software. At the final stage of design, frame information needs to be filled, at present, work is completed by manually filling a table, because the number of drawings in the design stage of a construction drawing is large in the power design industry, the information data of a header column of the frame is large, the manual table filling operation mode is low in efficiency and long in time consumption, the correctness is greatly influenced by human factors, and a great amount of effort is often required for a designer to repeat operation and inspection.
At present, along with the wide application of PDM software, the technology of automatically filling in frames in batches is relatively wide, but the automatic filling technology is mainly realized in an auditing stage in a PDM system, and is only aimed at a personnel signature module, so that the PDM has high price, large implementation workload and large use limitation, and can not solve the problem of automatically filling in various attribute information of a large number of drawing files when PDM management software is not used, and can only manually fill in various attribute information and personnel signatures, so that the workload is high and the work efficiency is low.
Disclosure of Invention
The invention aims to solve the technical problems and provide the technical task of perfecting and improving the prior art scheme, and provides an automatic batch filling method for the frame title bar information of the CAD drawing, aiming at reducing the filling workload of the frame title bar of the CAD drawing. For this purpose, the present invention adopts the following technical scheme.
A method for automatically filling attribute information of a title bar of a frame of a CAD drawing in batches comprises the following steps:
1) Storing various attribute information including drawing names and drawing numbers which are required to be filled in a drawing frame and a title bar of all drawings in a database table file, wherein signature blocks related to personnel names are correspondingly stored in folders according to personnel name names in dwg format through mapping relations in the database table;
2) Traversing the database table, reading drawing numbers of all drawings, and storing into a collection;
3) Traversing drawing numbers in the collection, obtaining a drawing file opening path by combining the drawing storage folder path with the drawing numbers, and opening corresponding drawings according to the drawing file path;
4) In the opened drawing, traversing all the objects of the Text type in the drawing, and if the character string content of the traversed Text object is consistent with the filling target, recording the coordinates of the traversed Text object;
5) Determining an insertion position by increasing the abscissa value according to the filling target coordinates;
6) Extracting each attribute information from a database table storing the association relation according to the drawing numbers, and storing the attribute information into a set of mapping relations;
7) Extracting attribute information in the set according to the corresponding relation, inserting corresponding attribute information at the insertion position calculated in the step 5), wherein the inserted attribute information comprises a signature block obtained according to the mapping relation, and storing and closing a current drawing;
8) And (3) detecting whether the drawing which is currently completed is the last drawing in the set, if so, ending, otherwise, returning to the step (3). Compared with the traditional manual method of manually opening the drawing to fill the title bar of the frame, the method can conveniently realize automatic filling of the title bar and the attribute in the frame in a large quantity of drawings, improves the working efficiency and filling quality of drawing design, reduces the filling workload of the title bar of the CAD drawing frame, can realize comprehensive filling of the attribute information in the title bar of the frame without using PDM software, and can effectively reduce the cost.
In the step 1), the database table file adopts an EXCEL table. The use is common, and the maintenance is simple.
In the step 1), the attribute information comprises construction units, engineering names, picture sizes, approval, design, auditing, checking, date, proportion, drawing numbers and signatures of approval, design, auditing and checking staff corresponding to the drawing numbers. And realizing comprehensive attribute information filling.
The method has the advantages that the automatic filling of the title bars and the attributes in the frames in a large quantity of drawings can be conveniently realized, compared with the traditional manual opening mode of manually opening the title bars of the frames one by one, the working efficiency and filling quality of drawing design are improved, the filling workload of the title bars of the CAD drawing frames is reduced, the comprehensive filling of the attribute information in the title bars of the frames can be realized without using PDM software, and the cost can be effectively reduced.
Drawings
FIG. 1 is a schematic flow chart of the present invention.
Detailed Description
The technical scheme of the invention is further described in detail below with reference to the attached drawings.
As shown in fig. 1, the automatic batch filling method for the attribute information of the title bar of the frame of the CAD drawing includes the following steps:
1) Storing various attribute information including drawing names and drawing numbers which are required to be filled in a drawing frame and a title bar of all drawings in a database table file, wherein signature blocks related to personnel names are correspondingly stored in folders according to personnel name names in dwg format through mapping relations in the database table;
2) Running CAD software, calling a picture frame automatic filling program, traversing a database table, importing corresponding drawings, reading drawing numbers of all the drawings, and storing into a collection;
3) Traversing drawing numbers in the collection, obtaining a drawing file opening path by combining the drawing storage folder path with the drawing numbers, and opening corresponding drawings according to the drawing file path;
4) In the opened drawing, traversing all the objects of the Text type in the drawing, and if the character string content of the traversed Text object is consistent with the filling target, recording the coordinates of the traversed Text object;
5) According to the filling target coordinates, determining an insertion position by adding an abscissa value, taking a text object named as approval as an example, obtaining coordinates (x, y) of the text object, adding the value on the x coordinate to be used as a new x coordinate x1, keeping unchanged to obtain an insertion coordinate, and then obtaining signature attribute insertion coordinates of the insertion coordinate;
6) Extracting each attribute information from a database table storing the association relation according to the drawing numbers, and storing the attribute information into a set of mapping relations;
7) Extracting attribute information in the set according to the corresponding relation, inserting corresponding attribute information at the insertion position calculated in the step 5), wherein the inserted attribute information comprises a signature block obtained according to the mapping relation, and storing and closing a current drawing;
8) And (3) detecting whether the drawing which is currently completed is the last drawing in the set, if so, ending, otherwise, returning to the step (3), and continuing to process the newly opened drawing until the traversal is completed.
In this example, the database table file takes the EXCEL table. The use is common, and the maintenance is simple.
In this example, the attribute information includes a construction unit, an engineering name, a drawing size, approval, design, audit, verification, date, proportion, drawing number, and signature of approval, design, audit, and verification personnel corresponding to the drawing number. And realizing comprehensive attribute information filling.
In this example, the programming language uses Python for CAD software for secondary development, using arrays or list containers as storage sets.
The automatic batch filling method for the attribute information of the frame title bar of the CAD drawing shown in the above figure 1 is a specific embodiment of the invention, has already demonstrated the outstanding essential characteristics and remarkable progress of the invention, and can be subjected to equivalent modification in terms of shape, structure and the like according to actual use needs under the teaching of the invention, and is within the scope of protection of the scheme.