How to do secondary development of CAD autolisp
;;;Lamp T4
(defun C:T4206()
The user enters the T4206 execution command (without any parameters) to load and immediately run the subsequent program.
(graphscr)
(setvar "cmdecho" 0)
;;;Command line display off
(setq P1(getpoint "\nPlease specify the placement location of the lamp (T4 206.5mm 6W):"))
;;;Set an insertion point P1 and return the point
(command "-INSERT" "D:/YZ_ZCAD/TK/DGT/T4206.dwg" "S" "1" P1 "0")
When executing CAD standard commands, you can add "-" (refer to CAD commands) in front of the command to execute the command directly in the command line without using the dialog box.
When the program is executed, you cannot use the dialog box to operate. You can add the "-" symbol before the command or use the variable FILEDIA to control it. There are also some special cases that can be controlled in other ways.
(setvar "cmdecho" 1)
;;;Command line display open
(princ)
;;;Conclusion
)
;;;Put the above text into LISP and save it under any English name
After saving the file, we can use AP to load the file in CAD.
;;; Execute the T4206 command to execute the insert command, (confirm the existence of the file)
As far as my personal opinion is concerned, I think VBA development is more convenient than LISP. To learn LISP, you only need to master basic knowledge, and there is no need to study in depth. LISP dialog box development (DCL) is much more complicated than VBA. However, sometimes we need to use LISP functions to execute VBA functions. In the AutoCAD help document, there is help specially provided for developers, which contains a lot of detailed content. Many editors also use resources directly from these documents. I suggest you take a look, it might help you.
CAD secondary development modification LISP
(defun c:dz (/ oce1 n1 zn h1 sxh1 p1)
(vl-load-com)
(setq oce1 (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq ms (vla-get-modelspace
(vla-get-activedocument (vlax-get-acad-object)) This line of code is used to get the object of the currently active document in AutoCAD. It uses AutoCAD's VLAX (Visual LISP ActiveX) interface, obtains the AutoCAD application object through the vlax-get-acad-object function, and then uses the vla-get-activedocument method to obtain the object of the currently active document. In this way, we can perform various operations on the current document, such as accessing its properties, modifying objects, etc. This line of code is very common in AutoCAD's LISP programming and is very
when working with document objects.)
)
(if qz
()
(setq qz """)
)
(if hz
()
(setq hz """)
)
(initget "c")
(setq nqz (getstring (strcat "\nPlease enter the prefix /c (empty): " )))
(cond
((= nqz "") (setq qz ""))
(T (if (/= nqz "")(setq qz nqz)))
)
(setq hz """)
(if (not (setq n1 (getint "\nPlease enter the starting sequence number : ")))
(setq n1 1)
)
(setq zn 1)
(if (not (setq h1 (getreal "\nPlease specify the text height : ")))
(setq h1 2.5)
)
(setq sxh1 (strcat qz (itoa n1) hz)) is a common LISP expression. In this expression, qz, n1, and hz are variables, and a new string sxh1 is created by concatenating their values. I'll explain to you exactly what this expression means. - qz is a variable representing prefix, which stores a string, such as "prefix". - n1 is an integer variable that stores a numeric value, such as 10
(setq p1 (getpoint "\nPlease specify the insertion point: "))
(while (/= p1 nil)
(setq p1 (vlax-3d-point p1))
(setq txt (vla-addtext
ms
sxh1
p1
h1
)
)
(setq
n1 (n1 zn)
sxh1 (strcat qz (itoa n1) hz)
p1 (getpoint "\nPlease specify the next insertion point: ")
)
)
(setvar "cmdecho" oce1)
(vlax-release-object ms)
(princ)
)
CAD secondary development LISP master writes a program
can be changed to the following:
(defun c:sdd (dwg)
(setq dwg (getfiled "Select path and file name" "" "Dwg" 1))
(if (wcmatch dwg "*
#-##-#:##.dwg")
(setq dwg (substr dwg 1 (vl-string-search " " dwg)))
Given a string variable `dwg`, we can use `(setq dwg (substr dwg 1 (- (strlen dwg) 4)))` to process it. The function of this line of code is to truncate the last four characters of the `dwg` string and reassign the result to the `dwg` variable. This may be done to strip file extensions from file names or other identifiers. Through this line of code, we can modify the `dwg` string so that it meets specific requirements or formats.
)
(setq dwg (strcat dwg " " (menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD HH:MM)") ".dwg"))
(command "_.saveas" ""” dwg)
(princ)
###)###The above is the detailed content of How to carry out secondary development of CAD Autolisp?. For more information, please follow other related articles on the PHP Chinese website!

This article provides practical tips for maintaining ENE SYS systems. It addresses common issues like overheating and data corruption, offering preventative measures such as regular cleaning, backups, and software updates. A tailored maintenance s

This article addresses the Windows "INVALID_DATA_ACCESS_TRAP" (0x00000004) error, a critical BSOD. It explores common causes like faulty drivers, hardware malfunctions (RAM, hard drive), software conflicts, overclocking, and malware. Trou

Article discusses editing Windows Registry, precautions, backup methods, and potential issues from incorrect edits. Main issue: risks of system instability and data loss from improper changes.

Article discusses managing Windows services for system health, including starting, stopping, restarting services, and best practices for stability.

What does the drive health warning in Windows Settings mean and what should you do when you receive the disk warning? Read this php.cn tutorial to get step-by-step instructions to cope with this situation.

This article identifies five common pitfalls in ENE SYS implementation: insufficient planning, inadequate user training, improper data migration, neglecting security, and insufficient testing. These errors can lead to project delays, system failures

This article identifies ene.sys as a Realtek High Definition Audio driver component. It details its function in managing audio hardware, emphasizing its crucial role in audio functionality. The article also guides users on verifying its legitimacy

This article addresses the failure of the Windows asio.sys audio driver. Common causes include corrupted system files, hardware/driver incompatibility, software conflicts, registry issues, and malware. Troubleshooting involves SFC scans, driver upda


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Linux new version
SublimeText3 Linux latest version

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function