Automatic annotation method of common terms in AutoCAD

Summary of the automatic labeling method of commonly used terms in AutoCAD: This paper proposes a method for automatic labeling of commonly used terms in AutoCAD using dialog boxes. In this way, various commonly used terms can be easily marked in the drawing, which provides convenience for CAD applications.
1. Introduction The annotation of Chinese characters is an important part in CAD design drawings, and it is also a relatively cumbersome and difficult part. At present, the input of Chinese characters in AutoCAD mostly uses pinyin, which is very difficult for people who are not familiar with pinyin. If you can visually display the commonly used text terms in design for designers to call, it will greatly improve work efficiency. This article studies this, and proposes a method for displaying and calling common terms with a dialog box (below), and also gives the source program for your reference. This procedure has been applied to the actual production of our hospital.


Second, the principle and method AutoCAD dialog structure contains a variety of components, such as edit_box (edit box), list_box (list box), radio_button (multiple choice button), etc., using these tools, you can develop a friendly interface utility.
The picture on the left is implemented in this way. Classify commonly used phrases and store them in different files. Open different files according to the group number driven in the multiple-select button, and read and display the file contents in the list box for designers to use. At the same time, there is an edit box, which can display the selected phrase in the edit box, so that the user can make appropriate modifications to the phrase, such as deleting or adding characters. This method has the advantage that users can easily modify or add phrases according to their needs. See # CAL.DCL and # CAL.LSP for dialog files and drivers, respectively.
Third, the method of using the program First use WPS, EDIT and other editing programs to classify and establish a phrase library (note that it needs to be stored in a plain text format), each phrase occupies one line. The program requires that the names of the phrase database files corresponding to each category such as "common terms", "drawing name", "room name" and so on are $ TXT1.DAT, $ TXT2.DAT, and $ TXT3.DAT. Except for the first file, other files can be vacant, but when the classification item is clicked, the system will prompt information about the file does not exist.
Then copy the created phrase library file and the provided program # TXT.LSP and dialog file # TXT.DCL to a directory that AutoCAD can find (any directory set by the environmental variable ACAD such as ACAD \ SUPPORT or the current directory ), Type (LOAD "#TXT") under Command: to load the program, and you can use #TXT just like other AutoCAD internal commands. You can also add the following line to the drop-down menu or on-screen menu part of the menu file used (such as ACAD.MNU): [Common Phrase] ^ C ^ C ^ P (if (null c: #txt) (load " #txt ")) #txt can later drive the program directly from the menu.
In the COMMAND: state, after typing #TXT, the system pops up a dialog box, click on the desired phrase category, and then select the desired phrase from the list box. The selected phrase will be displayed in the edit box [selected phrase]. The user can make necessary modifications to the phrase here. After clicking [OK], enter the word height and starting point according to the prompt to write the phrase into the picture.
It should be noted that in this program, the text is written into the figure with the font "HZ", and the fonts are required to be TXT.SHX and HZTXT.SHX. If these two fonts are not available in your software, you can rename the other fonts to these two fonts (requires one for English fonts and one for Chinese fonts), or modify the program to the font you have. However, it should be noted that maybe your font will have one more option when it is used to set the font, asking whether to write the text vertically. At this time, you can change the font setting sentence to: (command "STYLE" "HZ" "txt, hztxt "0 0.7 0" n "" n "" n ").
This program has been debugged on AutoCAD R12.0 FOR DOS and FOR WINDOWS versions.
(defun c: #txt (/ oldcmd olderr ok txt_tb txt dcl_id sty fp nn ht pt txterr diag init wr_txt old_nn)
; Define error handling subroutine
(defun txterr (s)
(if (and (/ = s "console break")
(/ = s "FuncTIon cancelled")
(/ = s "quit / exit abort")
)
(princ (strcat "Error:" s))
)
(if olderr (setq * error * olderr)); Restore the original system settings
(if oldcmd (setvar "cmdecho" oldcmd))
(princ)
)
; Dialog display and driver
(defun diag (/ i)
(if (> (setq dcl_id (load_dialog "#txt")) 0); load dialog file
(progn
(if (new_dialog "filetext" dcl [JX * 6] id); display dialog
(progn start_list "what"); display the phrase in the list box
(mapcar 'add_list txt_tb
)
(end_list)
(setq i 1)
(repeat nn; operation after picking the phrase classification item
(acTIon_TIle (strcat "c" (itoa i)) "(wr_txt)")
(setq i (1+ i))
)
(acTIon_tile "what" "(setq i (atoi $ value)); selected phrase
(setq txt (nth i txt_tb)) (set_tile \ "sel_ok \" txt) "
)
(action_tile "sel_ok" "(setq txt $ value)")
(action_tile "accept" "(setq ok T) (done_dialog 1) (unload_dialog dcl_id)")
(action_tile "cancel" "(unload_dialog dcl_id)")
(start_dialog)
)
(prompt "Unable to display dialog FILETEXT! Please check the contents of the dialog!")
)
)
(prompt "Unable to load dialog file # TXT.DCL! Please check if the file exists and the path is correct!")
)
)
; Initialize the program, read the phrase in the first grouping item into the table txt_tb
(defun init (/ fname fp txt1)
(setq fname (findfile "$ txt1.dat"))
(if (not fname)
(progn (princ "File $ TXT1.DAT does not exist!") (exit)); The file does not exist, then exit
)
(setq fp (open fname "r"))
(setq txt_tb '())
(while (setq txt1 (read_line fp))
(setq txt_tb (cons txt1 txt_tb))
)
(close fp)
(setq txt_tb (reverse txt_tb))
(setq old_nn 1); record index number
)
; Change the display content of the phrase in the list box
(defun wr_txt (/ fname fname1 fp txt1 i)
(setq i 1)
(while (<= i nn); determine which phrase item is hit
(if (= (get_tile (strcat "c" (itoa i))) "1")
(setq fname1 (strcat "$ txt" (itoa i) ".dat")
i nn
)
)
(setq i (1+ i))
)
(if (setq fname (findfile fname1)); Find if the file exists
(progn
(setq old_nn (atoi (substr fname1 5))); record index number
(setq fp (open fname "r"))
(setq txt_tb '())
(while (setq txt1 (read_line fp)); read each phrase in turn
(setq txt_tb (cons txt1 txt_tb))
)
(close fp)
(setq txt_tb (reverse txt_tb))
(start_list "what"); display the phrase content in the list box
(mapcar 'add_list txt_tb)
(end_list)
); progn
(progn
(alert (strcat "file" fname1 "does not exist!"))
(set_tile (strcat "c" (itoa old_nn)) "1"); restore the original record number
)
); if
)
; Start of main program
(setq olderr * error *
* error * txterr
oldcmd (getvar "cmdecho")
)
(setvar "cmdecho" 0); Command is not echoed
(setq nn 9); number of phrase classifications
(init); Initialize
(diag); Driver dialog
(if (and ok txt)
(progn
(if (or (= (setq sty (tblsearch "STYLE" "HZ")) nil); whether "HZ" font exists
(/ = (cdr (assoc 40 sty)) 0); Whether the character height is a fixed value
(/ = (getvar "TEXTSTYLE") "HZ"); Whether the current font is "HZ"
)
(command "STYLE" "HZ" "txt, hztxt" 0 0.7 0 "n" "n"); Set "HZ" font
)
(initget (+ 2 4)); the following input value must be greater than 0
(setq ht (getreal "please enter word height <500>:"))
(if (not ht) (setq ht 500))
(setq pt (getpoint "Please click the starting point of the text:"))
(command "text" pt ht 0 txt)
)
)
(setq * error * olderr); restore the original settings
(setvar "cmdecho" oldcmd)
(princ)
)
// # txt.dcl
// Called by # txt.lsp
filetext: dialog {// dialog name
label = "Commonly used phrases"; // Dialog label
: row {
: boxed_column {
label = "Index";
: radio_button {
label = "Common terms"; // select one more button
key = "c1";
value = "1"; // The initial value is "1", which means selected
}
: radio_button {
label = "Drawing name";
key = "c2";
}
: radio_button {
label = "Room name";
key = "c3";
}
: radio_button {
label = "Sanitaryware";
key = "c4";
}
: radio_button {
label = "Pipe fittings";
key = "c5";
}
: radio_button {
label = "Equipment instrument";
key = "c6";
}
: radio_button {
label = "Commonly used equipment";
key = "c7";
}
: radio_button {
label = "Structure";
key = "c8";
}
: radio_button {
label = "Other";
key = "c9";
}
}
: list_box {
label = "Phrase Content";
key = "what";
height = 15;
width = 26;
allow_accept = true; // Double click to select
}
}
spacer_1;
: edit_box {// edit box
label = "Selected phrase:";
key = "sel_ok";
}
spacer_1; // Increase the spacing
ok_cancel;
}

SDKELI has been manufacturing safety light curtains for more than 20 years. Its brand [SHANGSHOU" and [SDKELI" owns largest market share in China because of reliable quality and proper price. All the safety light curtains are type 4 with CE certificate.

Safety Light Curtain

Safety Light Curtain,Safety Curtain,Laser Safety Light Curtain,Safety Optic Light Curtain,Security Light Curtain,Press Brake Safety Light Curtains

Jining KeLi Photoelectronic Industrial Co.,Ltd , https://www.sdkelien.com

Posted on