Home  >  Article  >  Computer Tutorials  >  cad lisp script modification

cad lisp script modification

王林
王林forward
2024-01-12 14:15:051151browse

cad lisp script modification

(DEFUN C:J()

(PRINC "\nPlease select the annotation to be combined:)")

(SETQ S selection set (SSGET '((0 . "DIMENSION"))) m 0) is a LISP code that is used to select all entities of type "DIMENSION" in AutoCAD and store the selection results In the S selection set. The purpose of this code is to get all dimension objects.

T label number (sslength S selection set) ZS total number and 0 T aligned label 0). In this sentence, T represents the number of details that are inconsistent with the era. The number of elements in the selection set S can be calculated through the sslength function. ZS represents the total number of details. 0 represents unaligned annotations. T aligned annotations represent those that are inconsistent with the era. How many details are marked correctly?

(while(

"(setq a (entget (ssname S selection set m)) m (1 m))" This line of code is an expression in the Lisp language, used to obtain the attributes of the m-th element in the selection set S, And add 1 to the value of m.

(if (member (cdr (assoc 70 a)) '(1 33 129 161)))

(setq ZS total sum ( (cdr (assoc 42 a)) ZS total sum)) This line of code is an expression in LISP language. Its function is to update the value of the total sum of variables ZS to the current value plus the value associated with key value 42 in list a. Before executing this line of code, you need to ensure that the variables ZS total sum and list a have been defined and assigned the correct values. Through this line of code, we can dynamically update the total sum of ZS.

T alignment label (1 T alignment label)))

)

(PRINC (STRCAT "A total of " (itoa T annotation number) " annotations were selected,\nA total of " (itoa T alignment annotations) " alignment annotations participated in the addition, and the total is: " (Total number of RTOS ZS and 2) "."))

);END OF DEFUN

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)) is an AutoLISP code used to obtain the currently active AutoCAD document. It obtains the AutoCAD application object through the vlax-get-acad-object function, and then obtains the currently active document object using the vla-get-activedocument method. This code can be used in AutoCAD to operate the currently open document in the program.

)

)

(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 piece of Lisp code. Its function is to concatenate three strings to form a new string. Among them, qz, n1 and hz are variables, representing prefix, number and suffix respectively. By using the strcat function and itoa function, we can convert the number n1 to a string and concatenate the prefix and suffix with it, finally getting a new string sxh1. Such operations can be easily generated in programming

(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)

)

The above is the detailed content of cad lisp script modification. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:docexcel.net. If there is any infringement, please contact admin@php.cn delete
Previous article:How to uncompress a driveNext article:How to uncompress a drive