Secondary development of AutoCAD

Secondary development of AutoCAD

The secondary development of AutoCAD mainly involves the following:
(1) Write various user-defined functions and form several LISP, ARX, VLX or ADS files, as well as some DCL files.
(2) Create a menu file that meets your requirements. Generally, you can add your own content in the original AutoCAD menu file. For the AutoCAD2000 version, you can also add some menu files, and then add them to the system through interactive methods.
(3) Add some content to the system's ACAD.LSP or similar files for various initialization operations, such as loading some files immediately at startup.
(4) Set some paths through the system dialog box. These operations install applications on other AutoCAD systems after the successful development of the program, especially when a large number of installations are required, a lot of tedious work such as file retrieval, content addition and deletion, subdirectory creation, file copying, system settings, etc. Automatically, the entire secondary development program is embedded in the system without human intervention, which will greatly improve work efficiency. To this end, the author has developed a set of automatic installation program with VC ++, so that the manual operation that originally required five or six minutes can be completed automatically in less than ten seconds.
1. Basic Ideas The entire installation procedure follows the following ideas:
1) First obtain the installation path of the AutoCAD2000 system of the machine;
2) Find the menu file AutoCAD2000 \\ support \\ acad.mnu, open the file and add the content to be added to the end;
3) Find the LISP file AutoCAD2000 \\ support \\ acad2000doc.lsp, open the file and add the content to be added to the end;
4) Create a pre-named subdirectory and copy in all files formed by secondary development;
5) Give a message box to inform the installation success, if there are problems, it will inform the installation failure.
It should be pointed out that the following statement must be included in the content added to acad2000doc.lsp:
(Command "_menu" (strcat (getvar "menuname") ".mnu")), the purpose is to force the execution of the menu file loading command, compile and load the modified acad.mnu file.
In addition, there is an assignment statement in the content added to acad2000doc.lsp, which will give the global path name of the subdirectory containing all the secondary development generated files to be created to a global variable for the secondary development program to call when needed. Avoid the trouble of interactively setting the path in the AutoCAD environment.
Second, the implementation method and key functions To obtain the installation path of AutoCAD2000, you need to use the relevant functions of the WINDOWS system registry.
First open the registry through the RegOpenKey function:
HKEY hKey;
LONGret = RegOpenKey (HKEY_LOCAL_MACHINE, "Software \\ Autodesk \\ AutoCAD \\ R14.0 \\ ACAD-1: 804", & hKey);
The first parameter HKEY_LOCAL-MACHINE is the predefined primary key handle in the registry, the second parameter is the content of the subkey under HKEY_LOCAL_MACHINE in the registry, and the third parameter hKey will return a subkey handle for the next key value query . If the function runs successfully, it will return a long integer ERROR_SUCCESS.
Next, use the RegQueryValueEx function to perform key value query:
DWORD dwType = REG_SZ;
BYTE szData [100];
DWORD dwSize = sizeof (szData);
If (ret = ERROR_SUCCESS)
ret = RegQueryValueEx (hKey, "AcadLocaTIon", 0, & dwType, szData, & dwSize);
The first parameter hKey is the subkey handle to be queried obtained by the RegOpenKey function; the second parameter "AcadLocaTIon" is the key value name to be queried; the third parameter is a reserved item, and 0 is required; the fourth parameter is key value data Type; the sixth parameter is the key value buffer capacity; the most important is the fifth parameter szData. The key value result to be queried will be brought back by it. The key value is the installation path of AutoCAD2000.
The relationship between the primary key, subkey, key name, and key value in the registry mentioned above can be found by the WINDOWS series registry by the following methods: Click "Start"-"Run"-add to "regedit" "----" OK "----" HKEY_LOCAL_MACHINE "----" Software "----" Autodesk "----" Autocad "----" R15.0 "----" ACAD-1: 804 "----" AcadLocaTIon "----" e: \ autocad2000 ". The key value "AcadLocaTIon" corresponds to the key value "e: \ autocad2000", which is the installation path of AutoCAD2000, and the content may be different on different machines.
If the key-value query function runs successfully, it will return the long integer ERROR_SUCCESS.
The path name brought back by szData and the known path name can be combined into a full path to open the menu file acad.mnu to add content:
char szRootName [100] = \\ support \\ acad.mnu;
if (ret = ERROR_SUCCESS)
1strcat ((char *) szData, szRootName);
Now the full path of acad.mnu is installed in szData, the following operation will open the file and add the content:
HANDLE hfile = CreateFile ((char *) szData, GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
If (hfile! = INVALID_HANDLE_VALUE)
{
if (0xFFFFFFFF! = SetFilePointer (hfile, 0, NULL, FILE_END))
{
char szBuf [1000] = "*** POP12 ** CAM [& CAM] [-> basic parameters] [chuck origin] ^ c ^ cchuck_datam [tool change origin] ^ c ^ ctool_datam [<-blank parameter] ^ c ^ cstock [Work Step Design] ^ c ^ csteps [Simulation Processing] ^ c ^ csimulation [Code Generation] ^ c ^ cgen_code [Code Save] ^ c ^ ccode_save [Process Save] ^ c ^ csave_inf [Process Load] ^ c ^ cload_inf [-> tool management] "Create new knife" ^ c ^ ccreate_new_tool [<-tool magazine addition and deletion] ^ c ^ ctool_manage ";
DWORD dwWrite = 0;
BRet = WriteFile (hfile, szBuf, Lstrlen (szBuf), & dwWrite, NULL);
If (! BRet) Printerror ();
}
CloseHandle (hfile);
}
In the above operation, use the CreateFile function to open the file. The SetFilePointer function moves the pointer to the end of the file. The string array szBuf contains the content to be added. It is written by the WriteFile function, and PrintError is a self-edited error handling function.
In the same way, you can find the acad2000doc.lsp file and add the content.
The following operation will create a subdirectory named "C: \ hkcam" and copy all the files in the directory where the program is prepared in advance:
Cstring nam1, nam2;
BOOL bCreate = CreateDirectory ("C: \\ hkcam", NULL); // Create subdirectory
CfileFind finder; // Create class object
BOOL b Working = finder.FindFile ("*. *"); // Use class function to search all files
While (b Working) // Cycle search and file copy
{
b Working = finder.FindNextFile ();
nam1 = finder.GetFileName (); // Get the file name
nam2 = "c: \\ hkcam \\";
nam2 = nam2 + nam1; // compose the full path
BOOL bCopy = CopyFile (nam1, nam2, FALSE); // File copy
}
After all operations are successful, inform with a message box:
MessageBox (NULL, "The installation was successful, please press the OK button to continue", "Installation result", MB_OK);
The entire program is created with MFC static link library. All the above content can be written into a source file, which is called Append.cpp here. In order to make the final execution file as small as possible, all unnecessary content in the program framework should be deleted. For this reason, only the Append.cpp, Append.rc, and StdAfx.cpp items are kept in the source file; the Append.h, Resource.h, and StdAfx.h items are only in the header file. The only derived class defined is class CappendApp: public CwinApp, placed in Append.h.
3. Conclusion In the VC ++ environment, the installation path of the AutoCAD system is obtained by using the registry operation function of the WINDOWS system, so as to find and rewrite the AutoCAD related files; create subdirectories and copy into various secondary development formation files, thus implementing AutoCAD Automatic connection and embedding of secondary development program and AutoCAD system. The program in this article has been verified by practice and can be used for automatic installation of AutoCAD secondary development programs.

BLPS laser safety protective device is designed for personal safety used on hydraulic bender.
The dynamic test technology it used has passed the Type 4 functional safety assessment by TUV, and get the national invention patent. The product reaches the advanced technological level of similar products.
BLPS laser safety device provides protection zone near the die tip of the bender to protect fingers and arms of the operator in close to the upper mold die tip. It is the most effective solution so far to preserves the safety and productivity of the bender.

Press Brake Protection

Press Brake Protection,Laser Safety Guard Device,Laser Guarding Device,Press Brake Laser Guard,Press Brake Guarding Systems,Press Brake Guarding

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

Posted on