LISP Functions

The following is the contents of the LISP® functions available in ZWCAD®. The functions are listed alphabetically.

In this chapter, each listing contains a brief description of the function's use and a function syntax statement showing the order and the type of arguments required by the function.

Note that any functions, variables, or features not described here or in other parts of the documents are not officially supported and are subject to change in future releases.

Note that the value returned by some functions is categorized as unspecified. This indicates you cannot rely on using the value returned from this function.

Topics in this section:

  • Operators
  • A Functions
  • B Functions
  • C Functions
  • D Functions
  • E Functions
  • F Functions
  • G Functions
  • H Functions
  • I Functions
  • L Functions
  • M Functions
  • N Functions
  • O Functions
  • P Functions
  • Q Functions
  • R Functions
  • S Functions
  • T Functions
  • U Functions
  • V Functions
  • W Functions
  • X Functions
  • Z Functions


Operators

Topics in this section:

  • + (add)
  • - (subtract)
  • * (multiply)
  • / (divide)
  • = (equal to)
  • /= (not equal to)
  • < (less than)
  • <= (less than or equal to)
  • > (greater than)
  • >= (greater than or equal to)
  • ~ (bitwise NOT)
  • 1+ (increment)
  • 1- (decrement)


(+)(Addition operator)

(+ number1 number2 ...)

Add all these numbers together.

This function returns the sum of all numbers. You can use real numbers or integers. Adding all integer numbers returns an integer number. When there is a combination of real numbers and integers, the result is a real number.

Examples

Code | Result
(+ 10 20) | 30
(+ 10 2 3) | 15
(+ 2.3 2.4) | 4.70000
(+ 5 ) | 5
(+ ) | 0


(-)(Subtraction operator)

(- number1 number2 ...)

Subtract all following numbers from the first number.

This function returns the difference between the numbers. When you have only two numbers, the function subtracts number2 from number1. If there are more than two numbers, subtract the sum of the second through the last number (number2 through numberN) from the first, number1.

Examples

Code | Result
(- 30 20) | 10
(- 1.3 2.4) | -1.10000
(- 60 -10 50) | 20
(- 3) | -3
(- ) | 0


(*)(Multiplication operator)

(* number1 number2 ...)

Multiply all numbers together.

The multiply function returns the product of all numbers. You can use real numbers or integers.

Multiplying all real numbers returns a real number. The same is true for integers; multiplying all integers returns an integer. However, when there is a combination of real numbers and integers, the result is a real number.

Examples

Code | Result
(* 2 9) | 18
(* 1.3 2.4) | 3.12000
(* 60 -10 50) | -30000
(* 3) | 3
(* ) | 0


(/)(Division operator)

(/ number1 number2 ...)

Divide the first number by the following numbers.

This function returns the quotient between the two numbers. If you have two numbers, divide number1 by the number2. If there are more than two numbers, divide the number1 by the product of all the following numbers.

You can use real numbers or integers. Dividing all real numbers returns a real number. The same is true for integers; dividing all integers returns an integer. However if there is a combination of real numbers and integers, the integers are recognized as real, and the result is a real number.

Examples

Code | Result
(/ 4 2) | 2
(/ 5.8 2) | 2.90000
(/ 60 -10 3) | -2
(/ 3) | 3
(/ ) | 0

Note

A decimal point must be prefixed by a digit.


(=)(Equal to operator)

(= item1 item2 ...)

Return T if they're the same.

This function tells you whether two (or more) items are equal:

  • If they are equal, the result is a T (true).
  • If not, this function returns nil (false).

If the function contains more than two items, this function returns T (true) when each item on the right is equal to the item on its left. The items can be numbers or strings.

Examples

Code | Result
(= 20 20) | T
(= 5.0 5 5.0) | T
(= "ZWCAD" "zwcad") | nil
(= 4 3.9) | nil
(= "Hello" ) | T

Note

Don't confuse the = function with the equal function. Here's the difference: The = function compares numbers and strings; the equal function compares lists.

Both = and equal perform comparisons; neither performs the "equals" function you might expect from arithmetic, such as 1 + 2 = 3. In LISP, that service is provided by the setq function.

Tell me about...

(eq statement1 statement2)

(equal statement1 statement2 [tolerance])


(/=)(Not equal to operator)

(/= item1 item2 ...)

The two aren't equal.

This function tells you if two items are not equal:

  • If item1 does not equal item2, this function returns a T (true).
  • If the two items are equal, this function returns nil (false).

When more than two items are given, each item must be different to return a T. The items can be numbers or strings.

Examples

Code | Result
(/= 2.4 2.4 2.4) | nil
(/= "ME" "me") | T
(/= "*" "*") | nil
(/= -6 -6) | nil
(/= 7) | T

Note

Comparison statements (such as = (equal to operator) and < (less than operator) are typically used together with conditional statements, such as if...then, while, and cond. The comparisons let you test a pair of conditions (for example, does i= 0) to know when to exit the conditional (for example, while i > 0).


(<)(less than operator)

(< item1 item2 ...)

The first is less than the others.

The less-than function returns a T (true) or a nil (false):

  • If the item1 is less than item2 (and so on), this function returns a T.
  • If item2 is less or equal to the first, this function returns nil.

If this function contains more than two items, the function returns T when each item to the right is less than the item on its left. The items can be numbers or strings.

Examples

Code | Result
(< 23 35 ) | T
(< "a" "A") | nil
(< -7 -5) | T
(< 1 1 9) | nil
(< 7) | T

Note

This function is the opposite of the >=(Greater Than or Equal To operator) function.


(>)(less than or equal to operator)

(<=)(less than or equal to operator)

(<= item1 item2 ...)

The first is less than or equal to the others.

This function is the less-than or equal-to operator:

  • If item1 is less than or equal to item2, this function returns a T (true).
  • If item1 is greater than item2, this function returns nil (false).

If this function contains more than two items, the function returns T when each item to the right is less-than or equal to the item on its left. The items can be numbers or strings.

Examples

Code | Result
(<= 23 35 ) | T
(<= "a" "A") | nil
(<= -7 -5) | T
(<= 1 1 9) | T
(<= 7) | T

Note

This function is the opposite of the > (Greater Than operator) function.


(>=)(greater than operator)

(> item1 item2 ...)

The first is greater than the others .

The greater-than function displays a T (true) or a nil (false):

  • If the first item is greater than the second item (and so on), this function returns a T.
  • If the second item is greater than or equal to the first, this function returns nil.

If this function contains more than two items, the function returns T when each item to the right is greater than the item to its left. The items can be numbers or strings.

Examples

Code | Result
(> 45 27 ) | T
(> "A" "B") | nil
(> -3 -15) | T
(> 90 23 9) | T
(> 17) | T

Note

This function is the opposite of the <= (Less Than or Equal To operator) function.


(>=)(greater than or equal to operator)

(>= item1 item2 ...)

The first is greater than or equal to the others.

This function is the greater-than or equal-to operator:

  • If item1 is greater than or equal to item2, this function returns a T (true).
  • If it is less than, this function returns nil (false).

If this function contains more than two items, the function returns T when each item to the right is greater-than or equal to the item on its left. The items can be numbers or strings.

Examples

Code | Result
(>= 45 27 ) | T
(>= "A" "B") | nil
(>= -3 -15) | T
(>= 90 90 9) | T
(>= 17) | T

Note

This function is the opposite of the < (Less Than operator) function.


(~)(bitwise NOT)

(~ number)

Apply the 1s compliment.

This function returns the bitwise NOT of a number. The number must be an integer.

Examples

Code | Result
(~ 20) | -21
(~ -3) | 2
(~ 0) | -1


1+(increment)

(1+ number)

Add 1 to the number.

This function adds 1 to the number. You can use a real number or an integer. This function takes exactly one argument.

Examples

Code | Result
(1+ 0) | 1
(1+ 3.9 ) | 4.90000
(1+ -5) | -4

Note

This function is useful as an increment counter.


1-(increment)

(1- number)

Subtract 1 from the number.

This function subtracts 1 from the number. You can use a real number or an integer. This function takes exactly one argument.

Examples

Code | Result
(1- 0) | -1
(1- 7.6) | 6.60000
(1- -12) | -13

Note

This function is useful as an decrement counter.


A Functions

Topics in this section:

  • abs
  • acad_colordlg
  • acad_helpdlg
  • acad-pop-dbmod
  • acad-push-dbmod
  • acad_strlsort
  • acad_truecolorcli
  • acad_truecolordlg
  • action_tile
  • add_list
  • alert
  • alloc
  • and
  • angle
  • angtof
  • angtos
  • append
  • apply
  • arx
  • arxload
  • arxunload
  • ascii
  • assoc
  • atan
  • atof
  • atoi
  • atom
  • atoms-family
  • autoload


abs

(abs number)

Specify that number's distance from 0 (zero), disregarding direction (positive or negative).

This function returns the absolute value of the number. You can use a real number or an integer. This function takes exactly one argument.

Examples

Code | Result
(abs 0) | 0
(abs -12) | 12
(abs 7) | 7

Note

Use this function to convert a negative number to a positive number, or to ensure the number is positive.

When you need to make sure a number is negative, first apply the abs function, and then subtract the number from 0.


acad_colordlg

(acad_colordlg color-number [flag])

Display the Select Color dialog box.

This function displays the Color dialog box. This function returns the color number that the user selects from the dialog box .

The function accepts two optional arguments:

Argument | Meaning | Example | Range
color-number | Color Number | 1 | 0 - 256
flag | Flag | nil | nil or true (which is the same as not using the flag)

Note

  • The color-number argument lets you provide a default color. When clrno is 0, the default is BYBLOCK; when clrno is 256, the default is BYLAYER.
  • When nil, the dialog box disables the BYBLOCK and BYLAYER buttons.

Examples

Code | Result
(acad_colordlg 5) | Displays dialog box with color 1 (blue) selected as the default.
(acad_colordlg 1 nil) | Displays dialog box with color 1 (red) selected as the default, and the BYBLOCK and BYLAYER buttons are disabled.

Note

The first eight color numbers have the following meanings:

Number | Color
1 | Red
2 | Yellow
3 | Green
4 | Cyan (light blue)
5 | Blue
6 | Magenta (pink)
7 | White
8 | Gray


acad_helpdlg

(acad_helpdlg helpfile [topic])

Display the Help dialog box.

This function displays the ZWCAD help window.

Examples

Code | Result
(acad_helpdlg "ZwHelp.exe" "") | Displays dialog box with "ZwHelp.exe"

Tell me about...

(help [filename [topic [flag]]])


acad-pop-dbmod

Restores the value of the DBMOD system variable to the value that was most recently stored with acad-push-dbmod.


acad-push-dbmod

Stores the current value of the DBMOD system variable.


acad_strlsort

(acad_strlsort list)

Sort strings in alphabetical order.

This function sorts the list of strings in alphabetical order. The list contains one or more strings, which have been previously defined or returned with the quote (') function.

Examples

Code | Result
(acad_strlsort "one" "two" "three") | ("one" "three" "two")
(acad_strlsort "c" "d" "b" "a") | ("a" "b" "c" "d")

Note

The ' (quote) prefix is actually a LISP function that prevents another LISP function from evaluating the list.


acad_truecolorcli

Prompts for colors at the command line.


acad_truecolordlg

Displays the ZWCAD color selection dialog box with tabs for index color, true color, and color books.


action_tile

(action_tile key expression)

Respond when the user clicks a dialog box tile.

This function assigns the expression to evaluate when the user selects the tile referenced by key. Both expression and key are strings; key is case-sensitive. Expression is typically another LISP function; key refers to the tile. This function operates on tiles that are user-selectable elements of a dialog box, such as radio buttons, check boxes, or buttons.

The expression refers to the tile, using the following arguments:

Argument | Meaning
$value | Current value
$key | Tile name
$data | Application specific data
$reason | Callback reason
$x | Image x-coordinate
$y | Image y-coordinate

Examples

Code | Result
(action_tile "xpt" x_coord) | nil

Note

  • The expression assigned by action_tile overrules the default action of the dialog box (which is assigned via the new_dialog function) and the tile's action attribute.

  • The command function cannot be called by action_tile.


add_list

(add_list string)

Add some text to an existing dialog box string.

This function adds (or replaces) a string in the currently active dialog box. This function must follow the start_list function, which determines:

  • which string is affected;

  • whether the string is added to or replaces another string;

Examples

Code
(setq tmp '("china"))
(start_list "DCL")
(add_list tmp)
(end_list)

Note

You also use this function when creating list boxes and drop-down list boxes in DCL. For examples using this function in conjunction with DCL, see list_box and popup_list (drop-down list box).

Tell me about...

(start_list key [operation [index]])

(end_list)


alert

(alert string)

Display this alert for the user.

This function displays a dialog box with your string (a custom message) and the OK button. To display more than one line of text, use the new-line character (\n) in the string. to separate lines of text.

Examples

Code | Result
(alert "ZWCAD2023") | ZWCAD2023
(alert "Welcome") | Welcome

Note

Since all dialog boxes must accommodate small, 640 x 480-pixel displays, it's a good idea to keep the alert text brief and to the point.


alloc

(alloc integer)

Set the memory segment size for LISP.

This function sets the number of segments (a measurement of memory) for LISP operations, as specified by integer. The function returns the amount of memory previously allocated, as shown by the examples below.

Examples

Code | Result
(alloc 234) | 514
(alloc 28) | 234
(alloc 65) | 28

Tell me about...

(expand integer)


acad_colordlg

and

(and expression ...)

Apply the logical AND.

This function performs a logical AND to the expression that precedes it. If both statements return T (true), the and function returns T. If either or both of the statements returns nil (false) the and function returns nil.

Examples

Code | Result
(and 3.9 nil) | nil
(and 3.9 "hello" 0) | T
(and 2 -5) | T
(and 8.7) | T
(and) | T


angle

(angle point1 point2)

Determine the angle between these points.

This function returns the angle between point1 and point2 in the current UCS. The first point determines the line parallel to the x-axis. When point2 is plotted and connected to point1, the resulting angle is returned in radians.

Examples

Code | Result
(angle '(8 9) '(3 8)) | 3.33899
(angle '(4 8.7 6) '(5 8 9)) | 5.67246
(angle '(0 0) '(0 0)) | 0.000000

Note

  • This function is different from the getangle function. Getangle prompts the user to select two points defining an angle.

  • LISP always measures all angles in radians. Use the following LISP function to convert degrees to radians:


angtof

(angtof string [mode])

Change this angle to a real number.

This function converts a string that contains an angle to a real number in radian format. The optional mode specifies the format of the "number" in the string:

Mode Value | String format
0 | Decimal degrees
1 | Degrees-minutes-seconds
2 | Grad
3 | Radian
4 | Surveyor's units

Note

This command fails if the text of the string is not recognizable as an angle measurement.

Examples

Code | Result
(angtof "89") | 1.55334
(angtof "44" 3) | 0.0177028
(angtof "73" 2) | 1.14668

Note

  • The backslash denotes that there is a quote within the string. When LISP sees the second quote, it knows this is the end of the string.

  • The angtof function is the opposite of the angtos function.

Tell me about...

(angtos angle [mode [precision]])


angtos

(angtos angle [mode [precision]])

Convert this absolute angle to a string, relative to angbase.

The angtos function converts the angle in radians to strings. This is similar to the rtos function, but angtos converts angles to strings rather than converting numbers to strings. The optional mode argument (0 through 4) selects the format of the string:

Mode | Description | Example
0 | Decimal degrees | 360d
1 | Deg-min-sec | 47d29'15"
2 | Grad | 132g
3 | Radian | 6.28r
4 | Surveyor's units | N 82d W

Note

The optional precision argument allows you to select the number of places after the decimal point. The range is from 0 to 15.

Examples

Code | Result
(angtos 0.45 0 3) | "25.783"
(angtos 0.45 1 3) | "0.45r"
(angtos 0.45 3 3) | "25d46'59\""

Tell me about...

(angtof string [mode])


append

(append list1 list2 ...)

This function adds list2 to list1. The list2 element is a list of a single item. You can append multiple lists.

Examples

Code | Result
(append '(a) '(b)) | (A B)
(append '(1) '("one" "two")) | (1 "one" "two")


apply

(apply function list)

Make list do what func says.

This function performs a function to the list. The first argument, function, is either a pre-defined or user-defined function with a quote (') preceding it. The second argument must be a list. This function is useful when building a list dynamically.

Examples

Code | Result
(apply '+ '(7 9)) | 16
(apply 'abs '(-2)) | 2


arx

Returns a list of the currently loaded ObjectARX applications.


arxload

Loads an ObjectARX application.


arxunload

Unloads an ObjectARX application.


acad_colordlg

ascii

(ascii string)

Convert the first character of str to ASCII.

This function converts the first character of the string to its numerical ASCII code.

Examples

Code | Result
(ascii "b") | 98
(ascii "T") | 84
(ascii "*") | 42


assoc

(assoc item list)

Find the first matching item in the list.

This function finds and returns the first sublist in list whose first element matches the association item. The list may contain dotted pairs from the cons and entget functions.

Examples

Code | Result
(setq al '((name circle) (color red) (radius 4.7263))) (assoc 'color al) | (COLOR RED)
(setq al '((name circle) (color red) (radius 4.7263))) (assoc 'high al) | nil

Note

This function is often used in conjunction with the dotted pairs returned by the cons and entget functions.


atan

(atan number1 [number2])

Calculate the arctangent.

This function returns the principle arc tangent of the quotient number1 divided by number2. If number2 is not supplied, it is assumed to be 1.0, thus returning the principle arctan of number1. The value returned is always between -pi/2 and pi/2 radians.

Examples

Code | Result
(atan 8) | 1.44644
(atan 9.6) | 1.46700
(atan -4) | -1.32582


atof

(atof string)

Convert the string to a real number.

This function converts a string into a real number. This command returns 0.000000 if the text of the string is not recognizable as a number.

Examples

Code | Result
(atof "8") | 8.00000
(atof "-5") | -5.00000.
(atof "a") | 0.000000


atoi

(atoi string)

Convert the string to an integer.

The atoi function converts a string into an integer. If the string contains numbers after the decimal point, it truncates them. This command returns 0 if the text of the string is not recognizable as a number.

Examples

Code | Result
(atoi "7.9") | 7
(atoi "-9.3") | -9
(atoi "a") | 0

Tell me about...

(itoa integer)


atom

(atom item)

Determines whether an item is a single atom or not .

Generally, an atom is considered a number or a variable. More specifically, it is anything other than a list. The atom function tests item to see if it is an atom. If item is a list, a nil is returned. If it is not a list, a T is returned.

Examples

Code | Result
(atom 's) | T
(atom 3) | T
(atom '(x y z)) | nil


acad_colordlg

atoms-family

(atoms-family format [symbol1 symbol2 ...])

This function lists all the pre-defined and user-defined functions in the current session. The format argument specifies how the information is returned. Format is an integer value of 0 or 1.

Argument | Meaning
color-number | Color Number
flag | Flag

The optional argument [symbol1symbol2 ...] is a list of strings representing symbols. It is used to confirm whether the function names are defined in the current session. If symbol1, symbol2, ... are defined, LISP returns the symbols as strings, depending on the format chosen. If one is not defined, a nil is returned in place of the symbol.

Examples

Code | Result
(atoms-family 0 '("PLOTTERMANAGER" "LSNEW" "xyz")) | (PLOTTERMANAGER LSNEW nil)
(atoms-family 1 '("BLOCK" "REDRAW" "CDR")) | ("BLOCK" "REDRAW" "CDR")


autoload

(autoload application list)

Automatically load the LISP application when one of its commands is used.

This function returns associates a list of command names with an application name. Then, when the user types a command name, ZWCAD searches for and loads the associated LSP file.

Examples

Code
(autoload "example" '("test1" "test2"))

Note

  • ZWCAD loads the example.lsp.
  • Test1 and Test2 are command name by user define.


B Functions

Topics in this section:

  • boole
  • boundp


boole

(boole function integer1 integer2 ...)

Apply the bitwise Boolean function.

This function applies the bitwise Boolean function. The function argument is an integer between 0 and 15; it represents the 16 possible Boolean functions in two variables. Each bit of integer1 is paired with the corresponding bit of integer2.

The following shows the Boolean truth table:

integer1 | integer2 | function
1 | 1 | 1
1 | 0 | 2
0 | 1 | 4
0 | 0 | 8

The following values of function are the AND, XOR, OR, and NOR Boolean operators:

Function | Operation | Resulting bit is 1 when
1 | AND | Both input bits are 1.
6 | XOR | Only one of the two input bits is 1.
7 | OR | Either or both of the input bits are 1.
8 | NOR | Both input bits are 0 (1's complement).

Examples

Code | Result
(boole 1 2 3) | 2
(boole 6 9 7) | 14
(boole 8 8 9) | -10


boundp

(boundp item)

Determine whether an item has a value.

The boundp function determines if item has a corresponding value bound to it. If item does have a value bound to it, LISP returns T. If not, or if item is bound to nil, a nil is returned.

Examples

Code | Result
(setq x 8 y nil) (boundp y) | nil
(setq a 7.9 b 6) (boundp b) | T

Note

The boundp function is the opposite of the null function.

Tell me about...

(atoms-family format [symbol1 symbol2 ...])


C Functions

Topics in this section:

  • caddr
  • cadr
  • car
  • cdr
  • chr
  • client_data_tile
  • close
  • command
  • cond
  • cons
  • cos
  • cvunit


caddr

(caddr list)

Get the third item of the list.

This function takes a list apart and returns the third element of the list. For example, if you had a list of points such as (1 2 3), the caddr function would return the third element of the list, or 3.

Examples

Code | Result
(caddr '(5 3 6)) | 6
(caddr '(8 9 str)) | STR
(caddr '(4 9)) | nil


cadr

(cadr list)

Get the second item of the list.

This function takes a list apart and returns the second element of the list. For example, if you had a list of points such as (1 2 3), the cadr function would return the second element of the list, or 2.

Examples

Code | Result
(cadr '(5 7 9)) | 7
(cadr '(a (b))) | (B)
(cadr '(2)) | nil


acad_colordlg

car

(car list)

Get the first item of the list.

This function takes a list apart and returns the first element of the list. For example, if you had a list of points such as (1 2 3), the car function would return the first element of the list, or 1.

Examples

Code | Result
(car '(8 9 5)) | 8
(car '((a b) c)) | (A B)
(car '()) | nil


cdr

(cdr list)

Get everything in the list except the first item.

This is the secondary function for taking a list apart. Like the car function, this function returns a portion of the string. This portion includes the second element of the list, along with any remaining elements. For example, if your list contained the points (5 3 1), then using the cdr function would return(3 1).

Examples

Code | Result
(cdr '(9 5 8)) | (5 8)
(cdr '("one" "two")) | ("two")
(cdr '(9)) | nil


chr

(chr integer)

Convert this integer to ASCII.

The chr function converts an ASCII code into the corresponding character. The ASCII code is an integer.

Examples

Code | Result
(chr 68) | "D"
(chr 95) | "_"
(chr 56) | "8"


client_data_tile

(client_data_tile key data)

Associate data with a dialog box tile.

This function associates user-defined data with a dialog box tile. The key specifies the tile; key is a case-sensitive string. The data is a string that specifies the data, which can be referred as $data.


close

(close file-descriptor)

Close an open file.

This function closes access to a file that has been previously opened with the open function. Strictly speaking, it is not necessary to close files, since ZWCAD does that when it exits. However, for good housekeeping, it's a good idea to use the close function.

The file-descriptor argument represents the file descriptor assigned when the file was opened using the open function. The file descriptor remains after the file is closed but is not valid.

Examples

Code | Result
(setq file (open "InstallLog.log" "r")) (close file ) | nil

Note

The file-descriptor must be assigned to a symbol using setq, so the symbol must be used with the close function as the file-descriptor.


command

(command cmd [arguments] ...)

Carry out this ZWCAD command.

With this function, you can use any ZWCAD command within a LISP program. Any of the arguments that follow will be used for that command. Any input needed should be stored as variables using setq. Points should be assigned to variables after using the function getpoint.

Some commands continue past the points you have specified. To exit from a command, type a space within quotes to represent an Enter, thus ending the command.

Examples

Create a line.

Code
(setq pt1 '(2.0 3.0 0.0) pt2 '(7.0 9.0 0.0))
(command "line" pt1 pt2 "")

Create a circle.

Code
(setq pt1 '(2.0 3.0 0.0) radius "5.0")
(command "circle" pt1 radius )

Tell me about...

(vl-cmdf [arguments] ...)


cond

(cond (statement1 result1 ...) ...)

Do it, if it's true.

This function is a commonly used conditional in LISP. If statement1 evaluates to true, any functions that follow within that block are performed, and the result of the last function is returned.

  • If statement1 evaluates to nil, LISP continues to statement2. If true, it follows the same procedure.

  • If false (or nil), LISP continues to search for a true statement.

  • If no true statements are found, a nil is returned.

  • If there are no result functions in the block, the result of the condition is returned.

Examples

If the NUM is set to 289, this returns "Severe".

Code
(setq NUM 289)
(cond
((> NUM 200 ) (alert "Severe"))
((> NUM 100 ) (alert "Very High"))
((> NUM 50 ) (alert "High"))
((> NUM 25 ) (alert "Medium"))
)


cons

(cons item list)

Add this item to the beginning of the list.

This function constructs a new list using separate elements. This function also enables you to create a dotted pair, used by ZWCAD to access entity data. A dotted-pair is created only when the function is used to join two individual items together in the form (cons item item).

The first argument, item, is the item which will be added to the beginning of the list.

The item may be a list itself, but will still be treated in the list as a single item.

Examples

Code | Result
(cons '5 '6c) | (5 . 6C)
(cons 'one '(two three)) | (ONE TWO THREE)


cos

(cos angle)

Calculate the cosine.

This function returns the cosine of an angle. The angle must be in radian form, and the result is a real number.

Examples

Code | Result
(cos 56.9) | 0.938915
(cos 0) | 1.00000
(cos -43) | 0.555113


cvunit

(cvunit value from to)

Convert this unit to that unit.

This function converts the value from one type of measurement to another. The value is the number you want to convert. The from and to arguments convert from one unit to another.

For example, (cvunit 10 "hour" "day") converts from hours to days). If the two units of measurement are incompatible, a nil is returned.

The units of measurements are found in the zwcad.unt file.

Examples

Code | Result
(cvunit 1 "m" "cm") | 100.000
(cvunit 8 "day" "hour") | 192.000
(cvunit 1 "minute" "second") | 60.0000

Note

Points (or lists of numbers) can be converted, too, as shown by the above examples.


D Functions

Topics in this section:

  • defun
  • defun-q
  • dictadd
  • dictnext
  • dictremove
  • dictrename
  • dictsearch
  • dimx_tile
  • dimy_tile
  • distance
  • distof
  • done_dialog
  • dos_adminp
  • dos_attrib
  • dos_chdir
  • dos_chkdsk
  • dos_clipboard
  • dos_computer
  • dos_copy
  • dos_date
  • dos_delete
  • dos_dir
  • dos_dirp
  • dos_dirtree
  • dos_drive
  • dos_drives
  • dos_drivetype
  • dos_execute
  • dos_exewait
  • dos_filedate
  • dos_filep
  • dos_filesize
  • dos_filesys
  • dos_getdir
  • dos_getstring
  • dos_mkdir
  • dos_orderlist
  • dos_pwdir
  • dos_splitpath
  • dos_subdir
  • dos_time
  • dos_username


defun

(defun [c:] name ([arg1 arg2 ...] / [local-var1 local-var2 ...]) expression)

Create a LISP function.

When you write a LISP file, the file itself is not actually the function. Rather, one LISP file contains one or more functions (or programs) that are all available when the file is loaded with the load function.

The name of a function must be defined in the first statement using the defun function. This function is the first actual command within the program. It begins with an open parenthesis, which closes at the end of the program.

The defun function is followed by the name of your function or program. Once a name is selected, you have a few choices:

  • First, you can do nothing by adding ( ). This indicates that any variables used in the program are global, meaning they don't lose their value once the program ends. For example, the variable A defined as 12 would be 12 for any other program in the LISP file as well:

    (defun newfunc ( )

    ...

    )

  • Another option is to make all variables local to the program. For instance, if you defined N to equal 15, it would be 15 only for this particular program while it is running. To show that the variable is local, precede it with a forward slash (/) after the name of the program:

    (defun newfunc ( / N)

    ...

    )

  • Sometimes you may want to pass an argument to the program. This means that the variable will be assigned a value from outside of the currently running program. Place these variables before the slash:

    (defun newfunc (A / N)

    ...

    )

Once your function is defined with all its variables, you can choose to use the C: option. Prefixing the C: to the function name enables the command name to be entered without parenthesis at the command prompt of ZWCAD. This makes it look like any other ZWCAD command such as Line, Arc, and Circle.

(defun C:newfunc ( A / N)

...

)

Note

The C: has nothing to do with your computer's C: drive. In LISP, it is short for "command" and tells ZWCAD to treat the LISP function like an ZWCAD command. Following the lists of variables, the expression that will make up the body of the program must be entered before the closing parenthesis.

Examples

Code | Result
(defun newfunc ( )...) | May use global variables.
(defun newfunc (var1 var2). . . ) | Newfunc receives two outside values.
(defun newfunc (/ var1 var2). . . ) | Newfunc has two local variables.


defun-q

(defun-q [c:] name ([arg1 arg2 ...] / [local-var1 local-var2 ...]) expression)

Create a LISP function as a list.

If the user need that this function can create a LISP function as a list structure .

Note

The defun-q function is equivalent to defun function .

Tell me about...

(defun [c:] name ([arg1 arg2 ...] / [local-var1 local-var2 ...]) expression)


acad_colordlg

(acad_colordlg color-number [flag])

Display the Select Color dialog box.

This function displays the Color dialog box. This function returns the color number that the user selects from the dialog box or nil when the user clicks the Cancel button.

The function accepts two optional arguments:

Argument | Meaning | Example | Range
color-number | Color Number | 1 | 0 - 256
flag | Flag | nil | nil or true (which is the same as not using the flag)

NOTES

    • The color-number argument lets you provide a default color. When clrno is 0, the default is BYBLOCK; when clrno is 256, the default is BYLAYER.
    • When nil, the dialog box disables the BYBLOCK and BYLAYER buttons.

Examples

Code | Result
(acad_colordlg 1) | Displays dialog box with color 1 (red) selected as the default.
(acad_colordlg 1 nil) | Displays dialog box with color 1 (red) selected as the default, and the BYBLOCK and BYLAYER buttons are disabled.

Note The first eight color numbers have the following meanings:

Number | Color
1 | Red
2 | Yellow
3 | Green
4 | Cyan (light blue)
5 | Blue
6 | Magenta (pink)
7 | Black
8 | Gray

Tell me about...

(command cmd [arguments] ...)

(getvar sysvar)

(help [filename [topic [flag]]])

(setvar sysvar value)


dictadd

(dictadd ename symbol newobj)

Add a nongraphical object to a dictionary.

The dictadd function adds an object (newobj) to a dictionary (ename), where symbol is the key name of the object being added to the dictionary. Each symbol must be a unique name that does not already exist in the dictionary. Each object added to a dictionary must be unique to that dictionary.

Examples

Add a record to dictionary table.

Code
(setq dict (list '(0 . "DICTIONARY")'(100 . "AcDbDictionary")))
(setq new_name (entmakes dict)) (setq nmdict (namedobjdict )) (setq newdict
(dictadd nmdict "NEW_DICTIONARY" new_name ))

Add the Xrecord object to the dictionary.

Code
(setq datalist (append (list '(0 . "XRECORD") '(100 . "AcDbXrecord"))
'((1 . "new_data") (10 1. 2. 3.) (70 . 33))))

(setq new_name (entmakex datalist))
(dictadd newdict "NEW_DATA_RECORD" new_name)

Tell me about...

(dictnext ename [rewind])

(dictremove ename symbol)

(dictrename ename oldsym newsym)

(dictsearch ename symbol [setnext])

(namedobjdict)


dictnext

(dictnext ename [rewind])

Find the next item in a dictionary.

The dictnext function searches a dictionary (ename) to find the next item in the dictionary. If the parameter rewind is present and is not nil, the dictionary is rewound and the first entry in it is retrieved.

Examples

Returns entity name of FIRST_DATA_RECORD

Code
(setq dict (list '(0 . "DICTIONARY")'(100 . "AcDbDictionary")))

(setq new_name (entmakes dict)) (setq nmdict (namedobjdict )) (setq newdict (dictadd nmdict "NEW_DICTIONARY" new_name )) (setq datalist (append (list '(0 . "XRECORD") '(100 . "AcDbXrecord")) '((1 . "new_data") (10 1. 2. 3.) (70 . 33))))

(setq new_name (entmakex datalist)) (dictadd newdict "FIRST__DATA_RECORD" new_name) (setq new_name (entmakex datalist)) (dictadd newdict "SECOND_DATA_RECORD" new_name) (cdr (car (dictnext newdict)))

Returns entity name of SECOND_DATA_RECORD

Code
(cdr (car (dictnext newdict)))

Rewinds and so returns entity name of FIRST_DATA_RECORD

Code
(cdr (car (dictnext newdict T)))

Tell me about...

(dictadd ename symbol newobj)

(dictremove ename symbol)

(dictrename ename oldsym newsym)

(dictsearch ename symbol [setnext])

(namedobjdict)


dictremove

(dictremove ename symbol)

Remove an item from a dictionary.

The dictremove function searches a dictionary (ename) to remove an item symbol.

Examples

Removes the record from dictionary and returns the entity name which is removed from dictionary table.

Code
(setq dict (list '(0 . "DICTIONARY")'(100 . "AcDbDictionary")))

(setq new_name (entmakes dict)) (setq nmdict (namedobjdict )) (setq newdict (dictadd nmdict "NEW_DICTIONARY" new_name )) (setq datalist (append (list '(0 . "XRECORD") '(100 . "AcDbXrecord")) '((1 . "new_data") (10 1. 2. 3.) (70 . 33))))

(setq new_name (entmakex datalist)) (dictadd newdict "NEW_DATA_RECORD" new_name) (dictremove nmdict "NEW_DICTIONARY")

Tell me about...

(dictadd ename symbol newobj)

(dictnext ename [rewind])

(dictrename ename oldsym newsym)

(dictsearch ename symbol [setnext])

(namedobjdict)


dictrename

(dictrename ename oldsym newsym)

Rename a dictionary entry.

The dictrename function renames an item (oldsym) to a new name (newsym) in a dictionary (ename). If either oldsym is not present in the dictionary, or ename is invalid, or newname is invalid, or newsym is already present in the dictionary, dictrename returns nil.

Examples

Renames the record and returns the new name set in the record.

Code
(setq dict (list '(0 . "DICTIONARY")'(100 . "AcDbDictionary")))

(setq new_name (entmakes dict)) (setq nmdict (namedobjdict )) (setq newdict (dictadd nmdict "NEW_DICTIONARY" new_name )) (setq datalist (append (list '(0 . "XRECORD") '(100 . "AcDbXrecord")) '((1 . "new_data") (10 1. 2. 3.) (70 . 33))))

(setq new_name (entmakex datalist)) (dictadd newdict "NEW_DATA_RECORD" new_name) (dictrename nmdict "NEW_DICTIONARY" "NEW_NAME_DICTIONARY")

Tell me about...

(dictadd ename symbol newobj)

(dictnext ename [rewind])

(dictremove ename symbol)

(dictsearch ename symbol [setnext])

(namedobjdict)


dictsearch

(dictsearch ename symbol [setnext])

Search a dictionary for an item.

The dictsearch function searches a dictionary (ename) for an item specified by a string (symbol). If the parameter setnext is present and not nil, the dictnext entry counter is adjusted so the following dictnext call returns the entry after the one returned by this dictsearch call.

Examples

Searches the record and returns the record if found.

Code
(setq dict (list '(0 . "DICTIONARY")'(100 . "AcDbDictionary")))

(setq new_name (entmakes dict)) (setq nmdict (namedobjdict )) (setq newdict (dictadd nmdict "NEW_DICTIONARY" new_name )) (setq datalist (append (list '(0 . "XRECORD") '(100 . "AcDbXrecord")) '((1 . "new_data") (10 1. 2. 3.) (70 . 33))))

(setq new_name (entmakex datalist)) (dictadd newdict "NEW_DATA_RECORD" new_name) (dictsearch nmdict "NEW_DICTIONARY" )

Tell me about...

(dictadd ename symbol newobj)

(dictnext ename [rewind])

(dictremove ename symbol)

(namedobjdict)


dimx_tile

(dimx_tile key)

Determine the x-dimension of a dialog box tile.

This function, together with dimy_tile function, returns the dimensions of the tile with the name key. The x,y dimensions are typically used by other dialog box functions, such as vector_image.

Examples

Code
(dimx_tile "image")

Note

  • The dimension returned is one less than the size, since the dimension begins at 0. Thus, for the example above, the size of the tile is 16 x 16.

  • The key is a case-sensitive string.


dimy_tile

(dimy_tile key)

Determine the y-dimension of a dialog box tile.

This function, together with dimx_tile function, returns the dimensions of the tile with the name key. The x,y dimensions are typically used by other dialog box functions, such as vector_image.

Examples

Code
(dimy_tile "image")

Note

  • The dimension returned is one less than the size, since the dimension begins at 0. Thus, for the example above, the size of the tile is 16 x 16.

  • The key is a case-sensitive string.


distance

(distance point1 point2)

Determine the distance between two points.

The distance function returns the distance between two points. Point1 and point2 are the x,y or x,y,z coordinates of the point.

Examples

Code | Result
(distance '(0 9 7) '(8 7 6)) | 8.30662
(distance '(3.4 5.7) '(4.3 9.6)) | 4.00250
(distance '(3.4 5.7 9.6) '(4.3 9.6)) | 4.00250


distof

(distof string [mode])

Convert a string to a real number.

This function converts a string that contains a real number to a real number (distof is short for DIStance TO Floating point). The distof is opposite the rtos function. The optional mode specifies a number format, like the rtos function:

Argument | Meaning
1 | Scientific.
2 | Decimal.
3 | Engineering: feet and decimal inches.
4 | Architectural: feet and fractional inches.
5 | Fractional.

Examples

Code | Result
(distof "2.3698E001") | 23.6980
(distof "2'-5.25\"" 3) | 29.2500

Note

The backslash denotes that there will be a quote within the string. Once LISP sees the second quote, it knows it's the end of the string.


done_dialog

(done_dialog [flag])

Dismiss that dialog box.

This function terminates a dialog box. It returns the x,y coordinates of the dialog box's position, which can be used by the start_dialog function to place the dialog in the same position.

Flag is an alternative return code that is returned by the start_dialog function; you can use this flag for any purpose you desire. When flag has a value greater than 1, the value is returned by the start_dialog function. Otherwise, the start_dialog function returns as follows:

Returns | Meaning
0 | User clicked Cancel.
1 | User clicked OK

Examples

Code
(setq dlg (start_dialog))
(done_dialog dlg)


dos_adminp

(dos_adminp)

Determines whether the current user has administrator rights. This is done by confirming membership in the local Administrators group.

Parameters

n/a

Returns

T if the current user is member of the local Administrators group.
nil if not a member of the local Administrators group, or on error.

Example

Code | Result
(dos_adminp) | T


dos_attrib

(dos_attrib [filespec [bits]])

Returns file attributes, or sets file attributes to the value described by bits.

Parameters

filespec
The desired file or files. filespec can contain wildcard characters ("*" and "?"). If filespec is not supplied, it is assumed to be *.*.
bits
A bit-coded integer identifying the desired file attributes to set. Specify more than one file attribute by adding the following bit values:

0 (bit 0) | Normal
1 (bit 1) | Read-only
2 (bit 2) | Hidden
4 (bit 3) | System
8 (bit 4) | Archive

Returns

An association list containing the filenames and the attribute bits if successful.
nil on error.

Example

Code | Result
(dos_attrib "D:\\Program Files\\ZWCAD 2012\\ZWCAD.exe") | (("ZWCAD.exe" . 8))
(dos_attrib "C:\\Program Files\\ZWCAD 2012\\ZWCAD.exe" 1) | (("ZWCAD.exe" . 1))


dos_chdir

(dos_chdir path)

Changes the current directory to the specified directory. This function can change the current directory on any drive; it cannot be used to change the current drive. Use dos_drive to change the current drive.

Parameters

path
A string containing an existing path.

Returns

A string containing a qualified path to the current directory if successful.
nil on error.

Example

Code | Result
(dos_chdir "\\Program Files\\ZWCAD 2012\\Sample\\") | "C:\\Program Files\\ZWCAD 2012\\Sample\\"
(dos_chdir "..\\Support\\") | "C:\\Program Files\\ZWCAD 2012\\Support\\"


dos_chkdsk

(dos_chkdsk [drive])

Returns drive space statistics for the current drive or for the specified drive. Use the rtos function to convert the return values to strings if necessary.

Parameters

drive
The drive name (for example, C:, D:). If not specified, the current drive is used.

Returns

A list of three real numbers indicating the total disk space, used disk space, and free disk space in MB if successful.
nil on error.

Example

Code | Result
(dos_chkdsk) | (1.047527e+011 1.012878e+011 3.464913e+009)
(dos_chkdsk "C:") | (1.047527e+011 1.012878e+011 3.464913e+009)


dos_clipboard

(dos_clipboard [string])

Returns or sets a string of text in the Windows clipboard.

Parameters

string
A string of text to set in the Windows clipboard.

Returns

The string if successful.
nil on error.

Example

Code | Result
(dos_clipboard "Hello World!") | "Hello World!"
(dos_clipboard) | "Hello World!"


dos_computer

(dos_computer [name])

Returns or sets the computer name of the current system. The name is established at system startup, when it is initialized from the Windows Registry. Changes to the computer name take effect the next time the system is started.

Parameters

name
The computer name.

Returns

A string identifying the computer name if successful.
nil on error.

Example

Code | Result
(dos_computer) | "C"
(dos_computer "ZWCAD") | "ZWCAD"


dos_copy

(dos_copy source destination)

Copy one or more files from dir or drive to another.

Parameters

source
Source files. Source can contain wildcard characters("*" and "?").

destination
Destination dir or file.

Returns

T if successful.
nil on error.

Example

Code | Result
(dos_copy "C:\\Drawings\\test1.dwg" "C:\\Drawings\\test2.dwg") | T
(dos_copy "C:\\Drawings\\test1.dwg" "C:\\Temp\\") | T
(dos_copy "C:\\Drawings\\*.dwg" "C:\\Temp\\") | T


dos_date

(dos_date [date])

Returns the current system date or changes the current system date to one specified.

Parameters

date
A list of numbers specifying the year (1970 to 10000), month (1 to 12), and day (1 to 31).

Returns

A list of numbers identifying the current year, month, and day if successful.
nil on error.

Example

Code | Result
(dos_date) | (2012 10 1)
(dos_date '(2012 12 1)) | (2012 12 1)


dos_delete

(dos_delete filespec)

Deletes existing files.

Parameters

filespec
The desired file or files. filespec can contain wildcard characters ("*" and "?").

Returns

T if successful.
nil on error.

Example

Code | Result
(dos_delete "C:\\Temp\\test.dwg") | T
(dos_delete "C:\\Temp\\*.dwg") | T


dos_dir

(dos_dir [filespec [format]])

Returns a list of files in a directory. The function is very similar the command prompt's DIR command.

Parameters

filespec
The desired file or files. filespec can contain wildcard characters ("*" and "?"). If filespec is not specified, all files (*.*) in the current directory are returned.
format
The format of the filenames returned. The default value is 0. The allowable values are as follows:

0 | None.
1 | Sorted alphabetically, ascending.
2 | Sorted alphabetically, descending.
3 | Sorted by date, ascending.
4 | Sorted by date, descending.
5 | Sorted by size, ascending.
6 | Sorted by size, descending.

Returns

A list of filenames if successful.
nil on error.

Example

Code | Result
(dos_dir) | ("adbf.rdb" "adbps.rdb" "admhoops.dll" "admhusk.dll" "admicon.dll" "atl100.dll" "bigfont.ini" "brkline.dwg" "CustomAction.dll" "dbghelp.dll" "dwfcore_wt.1.7.0.dll" "dwftk_wt.7.7.0.dll" "filter.nfl" "FnpCommsSoap.dll" "FNP_Act_Installer.dll" "fpdfsdk.dll" "hoops1700_vc90.dll" "hppcf.rdb" "ICSharpCode.SharpZipLib.DLL" "LocalTrial_ZWCAD2023_TRIAL.asr" "LspAppUtils.zrx" "ManagedWrapper.DLL" "MathExpr.dll" "mfc100.dll" "mfc90.dll" "mfc90u.dll" "MFCMIFC80.dll" "Microsoft.VC90.CRT.manifest" )
(dos_dir "z*.dll" 2) | ("ZwExceptView.dll" "ZwDrawPict.dll" "ZwDraw.dll" "ZwDialogBox.DLL" "ZwDescT.dll" "ZwDbg.dll" "ZwDatabaseMgd.DLL" "ZwDatabase.dll" "ZwCxImage.dll" "ZwConstruct.dll" "ZwColour.dll" "ZwCodeVer.dll" "ZwCmdsEx.dll" "ZwCmds.dll" "ZwcadRibbonStyle.dll" "ZWCADFNP.dll" "ZWCADBtn.dll" "ZwBaseLib.dll" "ZwBase.dll" "ZwAuto.dll" "ZwAuthManagedWrapper.DLL" "ZwAuthHostFNP.dll" "ZwAuthBase.dll" "ZwAskForInput.dll" "ZwAcisBuilder.dll" "ZdUI.dll" )
(dos_dir "z*.dll" 4) | ("ZwMouseGestureLib.dll" "ZwOlp.dll" "ZwPCW.dll" "ZwDatabaseMgd.DLL" "ZwFg.dll" "ZwGdi.dll" "ZwMouseGestureUI.DLL" "ZwPictBom.dll" "ZwRibbonData.DLL" "ZwDatabase.dll" "ZwHopl.dll" "ZwRibbonControls.DLL" "ZwRibbonSupport.DLL" "ZwVUtil1.dll" "ZwDrawPict.dll" "ZwHNRW.dll" "ZwManaged.DLL" "ZwPSSetting.dll" "ZwStyleShWiz.dll" "ZwAskForInput.dll" "ZWCADBtn.dll" "ZwColour.dll")
(dos_dir "z*.dll" 6) | ("ZwDatabase.dll" "ZwUiMfcEx.dll" "ZwDatabaseMgd.DLL" "ZwFg.dll" "ZwAuthHostFNP.dll" "ZWCADFNP.dll" "ZwInstallDriveFNP.dll" "ZwAuto.dll" "ZWCADBtn.dll" "ZwDialogBox.DLL" "ZwGeometry.dll" "ZwManaged.DLL" "ZwPltRaster.dll" "ZwRibbonControls.DLL" "ZwCxImage.dll" "ZwPltDWF.dll" "ZwCmds.dll" "ZwOlp.dll" "ZwPltPDF.dll" "ZwGsx.dll" "ZwGRegen.dll" "ZwPCM.dll" "ZwVUtil1.dll" "ZwGdiPt.dll" "ZwAcisBuilder.dll" "ZwPlotSetting.dll" "ZwSgUtil.dll" "ZwSoftActivation.dll" "ZwDraw.dll" "ZwOsBase.dll" "ZwRibbonControlsLibrary.DLL" "ZwHNRW.dll" "ZwUI.dll" "ZwMouseGestureApp.dll" )


dos_dirp

(dos_dirp path)

Check for the existence of a directory.

Parameters

path
A string containing an existing path.

Returns

T if the directory exists.
nil if the directory does not exist, or on error.

Example

Code | Result
(dos_dirp "C:\\Program Files\\ZWCAD 2012\\") | T
(dos_dirp "C:\\Program Files\\ZWCAD 2013\\") | nil


dos_dirtree

(dos_dirtree [path])

Returns a list of directories and any subdirectories found in the specified directory.

Parameters

path
A string containing an existing path. If not specified, the current directory is used.

Returns

A list of subdirectories if successful.
nil on error.

Example

Code | Result
(dos_dirtree "C:\\Program Files\\ZWCAD 2012\\Support\\") | ("C:\\Program Files\\ZWCAD 2012\\Support\\" "C:\\Program Files\\ZWCAD 2012\\Support\\color")


dos_drive

(dos_drive [drive])

Returns the current drive or changes the current drive to the one specified.

Parameters

drive
The drive name (for example, C:, D:). If not specified, the current drive is used.

Returns

A string identifying the current or new drive if successful.
nil on error.

Example

Code | Result
(dos_drive) | "C"
(dos_drive "E:") | "E"


dos_drives

(dos_drives)

Return the list of drives.

Parameters

n/a

Returns

list of drives if successful.
nil on error.

Example

Code | Result
(dos_drives ) | ("A:" "C:" "D:" "E:" "F:")


dos_drivetype

(dos_drivetype [drive])

Returns the type of the specified drive; either removable, fixed, CD-ROM, RAM disk, or a network drive.

Parameters

drive
The drive name (for example, C:, D:). If not specified, the current drive is used.

Returns

A string describing the drive type if successful.
nil on error.

Example

Code | Result
(dos_drivetype) | "FIXED"
(dos_drivetype "E:") | "CDROM"
(dos_drivetype "F:") | "REMOTE"


dos_execute

(dos_execute command [show])

Executes an external program. The PATH environment variable is used to find the program to be executed.

Parameters

command
The command to run, including arguments.
show
How the newly opened window is to be shown. The default value is Normal (0).

0 | Normal. Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
1 | Not Active. Displays a window in its most recent size and position. This value is similar option 0, except the window is not active.
2 | Minimized. Activates the window and displays it as a minimized window.
3 | Minimized Not Active. Displays the window as a minimized window. This value is similar to option 2, except the window is not activated.
4 | Maximized. Activates the window and displays it as a maximized window.

Returns

Returns command if successful.
nil on error.

Example

Code | Result
(dos_execute "Notepad.exe") | "Notepad.exe"


dos_exewait

(dos_exewait command [show])

Executes an external program, then waits for termination before returning control to the calling application.

Parameters

command
The command to run, including arguments.
show
How the newly opened window is to be shown. The default value is Normal (0).

0 | Normal. Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
1 | Not Active. Displays a window in its most recent size and position. This value is similar option 0, except the window is not active.
2 | Minimized. Activates the window and displays it as a minimized window.
3 | Minimized Not Active. Displays the window as a minimized window. This value is similar to option 2, except the window is not activated.
4 | Maximized. Activates the window and displays it as a maximized window.

Returns

T if successful.
nil on error.

Example

Code | Result
(dos_exewait "Notepad.exe") | Running external process, please wait... T


dos_filedate

(dos_filedate filespec)

Returns a list containing filenames and ZWCAD calendar dates. Use rtos and substr or dos_strleft to extract elements from the ZWCAD calendar date.

Parameters

filespec
The desired file or files. filespec can contain wildcard characters ("*" and "?"). If filespec is not supplied, it is assumed to be *.*.

Returns

An association list containing filenames and their corresponding dates in ZWCAD calendar date format if successful.
nil on error.

Example

Code | Result
(dos_filedate "C:\\Program Files\\ZWCAD 2012\\Support\\*.lsp") | (("ZWCAD2012.lsp" . 20130331) ("ZWCAD2012doc.lsp" . 20130327) ("ZWmvsetup.lsp" . 20130323))


dos_filep

(dos_filep filename)

Tests for the existence of a file.

Parameters

filename
The source filename.

Returns

T if filename exists.
nil if filename does not exist, or on error.

Example

Code | Result
(dos_filep "C:\\Program Files\\ZWCAD 2012\\ZWCAD.exe") | T
(dos_filep "C:\\ZWCAD 2012\\drawing1.dwg") | nil


dos_filesize

(dos_filesize filespec)

Returns a list containing filenames and sizes in bytes.

Parameters

filespec
The desired file or files. filespec can contain wildcard characters ("*" and "?"). If filespec is not supplied, it is assumed to be *.*.

Returns

An association list containing filenames and their corresponding sizes in bytes if successful. Note, file sizes are returned as real numbers.
nil on error.

Example

Code | Result
(dos_filesize "C:\\Program Files\\ZWCAD 2012\\Support\\*.lsp") | (("ZWCAD2012.lsp" . 59) ("ZWCAD2012doc.lsp" . 1452) ("ZWmvsetup.lsp" . 87103))


dos_filesys

(dos_filesys [drive])

Returns the file system of the specified drive; either FAT, FAT32, NTFS, HPFS, CDFS, or a network drive.

Parameters

drive
The drive name (for example, C:, D:). If not specified, the current drive is used.

Returns

A string identifying the file system if successful.
nil on error.

Example

Code | Result
(dos_filesys) | "NTFS"
(dos_ filesys "F:") | "CDFS"


dos_getdir

(dos_getdir [title [path [message [T]]]])

Show the "Browse Folder" dialog of Windows. dos_getdir can create new folder.

Parameters

title
The title of dialog.

path
Set an existing dir. Use current dir if nil.

message
Selective message.

T
Show "Create new folder" button.

Returns

Full path user selected if successful.
nil on cancel or error.

Example

Code | Result
(dos_getdir "Browse for folder" "C:\\Program Files\\ZWCAD 2023\\" "Select a folder to use" T) | "C:\\Program Files\\ZWCAD 2023\\Support\\"


dos_getstring

(dos_getstring title prompt [default [length]])

Equal the dialog of "getstring" functin in LISP.

Parameters

title
The title of dialog.

prompt
The prompt message.

default
Default value.

length
The maximal length allowed.

Returns

The string if successful.
nil on cancel or error.

Example

Code | Result
(dos_getstring "Text" "Please input text:") | Text input in dialog


dos_mkdir

(dos_mkdir path)

Create new dir.

Parameters

path
An existing path.

Returns

The new path created if successful.
nil on error.

Example

Code | Result
(dos_mkdir "c:\\temp\\") | "c:\\temp\\"


dos_pwdir

(dos_pwdir [drive])

Return current dir or current dir in given drive.

Parameters

drive
Drive(for example, C:, D:).

Returns

Current Dir of given drive if successful.
nil on error.

Example

Code | Result
(dos_pwdir ) | "c:\\temp\\"
(dos_pwdir "D:") | "d:\\projects\\drawings\\"


dos_splitpath

(dos_splitpath path)

Split full path to four parts.

Parameters

path
The full path.

Returns

Table with the following four elements if successful.
drive with (:).
dir with (\\) at begin and end.
filename without extension.
extension with (.) at begin.
nil on error.

Example

Code | Result
(dos_splitpath "C:\\Program Files\\ZWCAD2023\\zwcad.exe") | ("C:" "\\Program Files\\ZWCAD2023\\" "zwcad" ".exe")
(dos_splitpath "C:\\Program Files\\ZWCAD2023\\") | ("C:" "\\Program Files\\ZWCAD2023\\" "" "")


dos_subdir

(dos_subdir [path [T]])

Return list of subdir in given dir without (\\).

Parameters

path
Given path. Use current path if not given.

T
Return current dir "." and parent dir "..". Not return in default.

Returns

List of subdir if successful.
nil on error.

Example

Code | Result
(dos_subdir) | ("en-US" "Express" "Fonts" "Help" "PlotStyles" "Plotters" "Sample" "Support" "Template" "UserDataCache" "WebServices")


dos_time

(dos_time [time])

Returns the current system time or changes the current system time to one specified.

Parameters

time
A list of numbers specifying the new hour and minutes in 24-hour format. Optionally, the seconds and milliseconds can be specified.

Returns

A list of numbers identifying the current hour, minutes, seconds, and milliseconds in 24-hour format if successful.
nil on error.

Example

Code | Result
(dos_time) | (15 8 15 242)
(dos_time '(9 0 0)) | (9 0 0 10)


dos_username

(dos_username)

Returns user name of the current thread. This is the name of the user currently logged onto the system.

Parameters

n/a

Returns

A string identifying the current user if successful.
nil on error.

Example

Code | Result
(dos_username) | "roomy"


E Functions

Topics in this section:

  • end_image
  • end_list
  • entdel
  • entget
  • entlast
  • entmake
  • entmakex
  • entmod
  • entnext
  • entsel
  • entupd
  • eq
  • equal
  • *error*
  • eval
  • exit
  • exp
  • expand
  • expt


end_image

(end_image)

End the creation of a dialog box image.

This function signals the end of the creation of an image in the current dialog box, which was begun by the start_image function.

Examples

Code | Result
(end_image ) | nil


end_list

(end_list)

End the processing of a dialog box list.

This function signals the end of processing a list in the current dialog box, which was begun by the start_list function.

Examples

Code | Result
(end_list ) | nil

Note

You also use this function when creating list boxes and drop-down list boxes in DCL.


entdel

(entdel entity-name)

Erase that entity from the drawing.

This function deletes an entity (or entity) specified by entity-name if it exists in the drawing. Use the entnext or entget functions to get the entity's entity-name.

If the entity was deleted from the drawing earlier in the current editing session, the entity is restored. In other words, using entdel twice un-deletes the entity. This works until you exit the drawing. Once the drawing is reloaded, you can no longer use entdel to restore entities deleted in the previous drawing session.

Examples

Code | Result
(command "line" '(2 3) '(6 9) "") (entdel (entlast)) | < Entity name: 49d2bf0 >

Note

  • Only entities can be deleted with entdel, not attributes or polyline vertices. To delete attributes and polyline vertices, use the command function with the AttEdit and PEdit commands.
  • Entities within blocks may not be deleted. To delete entities within a block, use entmake to redefine the block without the entities you want erased.

Tell me about...

(handent handle)


entget

(entget entity-name [application-list])

Determine the DXF data of an entity.

This function retrieves the entity list from the drawing database. The list is assigned to a variable, and then is taken apart, using functions like car, cdr, and assoc.

The entity list returned is composed of element pairs called dotted pairs because a dot separates each half. In each pair, the first number represents the code number for a characteristic of the element; the second number is the data associated with the code.

Examples

Code | Result
(command "line" '(2 3) '(6 9) "") (entget (entlast)) | ((-1 . ) (0 . "LINE") (5 . "E3") (67 . 0) (8 . "0") (410 . "Model") (62 . 256) (6 . "ByLayer") (370 . -1) (48 . 1.00000) (60 . 0) (39 . 0.000000) (10 2.00000 3.00000 0.000000) (11 6.00000 9.00000 0.000000) (210 0.000000 0.000000 1.00000))

Note

  • Entget does not return all information about an entity. Missing is dotted pair data about the entity's properties when they do not differ from default values: color, linetype, thickness, attributes-follow flag, and the entity handle.

  • While the data returned by entget is very similar to DXF format, there is one primary difference: x,y,z coordinates are returned by entget as a single value, rather than the separate values in DXF. Thus, you only see group code 10 with entget, instead of DXF group codes 10 (x-coordinate), 20 (y-coordinate), and 30 (z-coordinate).

Tell me about...

(entdel entity-name)

(entlast)

(entmod entity-list)

(entmake [entity-list])

(entnext [entity-name])

(entupd entity-name)

(handent handle)


entlast

(entlast)

Get the last entity in the drawing.

This function retrieves the name of the last non-deleted entity in your database. This is useful if you want to use the last entity drawn.

Examples

Code | Result
(command "line" '(2 3) '(6 9) "") (entlast ) | < Entity name: 49d2bf0 >

Note

  • The entity does not need to be currently on screen, unthawed, or unlocked to be selected. This behavior differs from the Last selection set option.

  • To find the first entity in the database, use the entnext function with no arguments.

Tell me about...

(entdel entity-name)

(entget entity-name [application-list])

(entmod entity-list)

(entmake [entity-list])

(entnext [entity-name])

(handent handle)


entmake

(entmake [entity-list])

Add an entity to the drawing.

This function allows you to write the entity-list to the database. The entity-list must be in the dotted pair format, as shown by the entget function. Without a valid entity-list, entmake doesn't make the entity and returns nil.

Examples

Code | Result
(entmake '((0 . "LINE") (62 . 3) (10 4.0 4.0 0.0) (11 1.0 1.0 0.0))) | ((0 . "LINE") (62 . 3) (10 4.00000 4.00000 0.000000) (11 1.00000 1.00000 0.000000))

Note

  • This function is similar to entmod. The difference is that entmake allows you to write a new list that was not previously in the database; entmod creates a new entity by modifying an existing entity.

  • Entmake does not require that you provide all information about the entity. Not required are dotted pair data about the entity's properties when they do not differ from default values: color, linetype, thickness, attributes-follow flag, and the entity handle.

  • While the data specified by entmake is very similar to DXF format, there is one primary difference: x,y,z coordinates are specified by entmake as a single value, rather than the separate values in DXF. Thus, you specify group code 10 with entmake, instead of DXF group codes 10 (x-coordinate), 20 (y-coordinate), and 30 (z-coordinate).

Tell me about...

(entdel entity-name)

(entget entity-name [application-list])

(entmod entity-list)

(handent handle)


entmakex

(entmakex [elist])

Makes a new object or entity, gives it a handle and entity name, and returns the new entity name.

This function allows you to define new entities -- both graphical and nongraphical -- where elist is a list of the information necessary to define the entity. If any required definition data is omitted, entmakex returns nil and the entity is rejected. If you omit optional definition data (such as the layer), entmakex uses the default value. If successful, entmakex returns the name of the entity created. If entmakex is unable to create the entity, the function returns nil.

Objects and entities without owners are not written out to DWG or DXF files. Be sure to set an owner at some point after using entmakex. You can use dictadd to set a dictionary to own an object.

Examples

Code | Result
(entmakex '((0 . "LINE") (62 . 3) (10 4.0 4.0 0.0) (11 1.0 1.0 0.0))) | < Entity name: 64ca670 >

Tell me about...

(entmake [entity-list])

(handent handle)


entmod

(entmod entity-list)

Modify the entity in that drawing.

This function changes the entity defined by entity-list in the drawing database. You may have made changes to entity-list that you retrieved using entget, so the function entmod writes the changed list permanently into the database.

Examples

Use the following LISP code example as a pattern to change any property of any entity:
Code | Result
(command "circle" '(5 11) 5) (setq ent (entlast)) (setq ed (entget ent)) (setq ed (subst (cons 40 20) (assoc 40 ed) ed)) (entmod ed) | ((-1 . ) (0 . "CIRCLE") (5 . "E9") (67 . 0) (8 . "0") (410 . "Model") (62 . 256) (6 . "ByLayer") (370 . -1) (48 . 1.00000) (60 . 0) (39 . 0.000000) (210 0.000000 0.000000 1.00000) (10 5.00000 11.0000 0.000000) (40 . 20))

Note

  • Entmod checks that the following parameters are valid for every entity: layer name, linetype name, and color name or number.

  • Entmod automatically creates a layer if it does not already exist.

Tell me about...

(entdel entity-name)

(entget entity-name [application-list])

(entmake [entity-list])

(entnext [entity-name])

(handent handle)


entnext

(entnext [entity-name])

Get the next entity in the drawing.

This function returns the name of the first non-deleted entity in the database if no arguments are supplied. If an entity name is supplied, entnext returns the next entity following the given entity-name. When there is no next entity in the database, entnext returns nil.

Examples

Code | Result
(setq a (entnext )) | < Entity name: 1fe0540 >
(setq b (entnext a)) | Entity name following entity a.

Tell me about...

(entdel entity-name)

(entget entity-name [application-list])

(entmake [entity-list])

(entmod entity-list)

(handent handle)


entsel

(entsel [prompt])

Ask the user to select an entity.

The entsel function selects a single entity using a point-click, and then returns a list containing the entity name and the coordinates of the point used to select it. Any prior entity snap settings have no effect unless specifically requested during the function.

If a prompt is supplied, the user will be asked to select the entity with the wording of that prompt. If no prompt is supplied, the default prompt "Select Entity:" is displayed.

Examples

Code | Result
(command "line" '(2 3) '(6 9) "") (entsel "Select Entity:" ) | (< Entity name: 64c7df0> (2.00000 3.00000 0.000000))

Note

The function entsel works only with top-level entities. To select entities that belong to a block or a polyline, use nentsel.

Tell me about...

(entget entity-name [application-list])

(entmake [entity-list])

(entnext [entity-name])

(initget [bits] [string])

(handent handle)


entupd

(entupd entity-name)

Redraw the entity.

This function redraws the entity on the screen. After you modify a block attribute or polyline vertex, the block or polyline is not updated automatically because recalculating and displaying a multitude of changes might take a long time.

Instead, you force an update of complex entities on the screen after the computations are done using entupd. The entity-name of an entity within the block or polyline updates the whole entity group.

Examples

Code | Result
(command "circle" '(5 11) 5) (setq ent (entlast)) (setq ed (entget ent)) (setq ed (subst (cons 40 20) (assoc 40 ed) ed)) (entmod ed) (entupd ent) | < Entity name: 64c5380 >

Note

You can ensure that all entities on the screen are updated with the (command"regen") function.

Tell me about...

(entget entity-name [application-list])

(entmake [entity-list])

(entnext [entity-name])

(initget [bits] [string])

(handent handle)


eq

(eq statement1 statement2)

Determine whether two expressions are bound to the same symbol.

This function determines whether two expressions are bound to the same symbol. If so, eq returns T; if not, eq returns nil.

Examples

Code | Result
(setq s1 '(1 2 3)) (setq s2 '(1 2 3)) (setq s3 s2) (eq s1 s3) | nil
(eq s2 s3) | T

Note

The eq function is not the same as the = (equal to operator) and equal(equal statement1 statement2 [tolerance])(IDR_166)functions. The = function returns T when two numbers or strings are equal. The equal function returns T when two expressions are equal. The eq function returns T when two expressions are bound to the same symbol.

Tell me about...

(= item1 item2 ...)

(equal statement1 statement2 [tolerance])


equal

(equal statement1 statement2 [tolerance])

Determine whether two statements are the same.

This function compares statement1 and statement2. If they are equal, LISP returns a T; if not, a nil is returned. Whereas the equal function compares lists, the = (equal to operator) function compares numbers and strings.

Examples

Code | Result
(setq s1 '(1 2 3)) (setq s2 '(1 2 3)) (setq s3 s2) (equal s1 s3) | T
(equal s2 s3) | T
The tolerance is the amount that the two expressions are allowed to differ, which is very important when comparing real numbers (which tend to suffer from rounding error). In the following example, the two statements can differ by 0.01:
Code | Result
(equal 7.8989 7.89 0.01) | T

Note

The equal function is not the same as the = (equal to operator) and eq functions. The = function returns T when two numbers or strings are equal. The equal function returns T when two expressions are equal. The eq function returns T when two expressions are bound to the same symbol.

Tell me about...

(= item1 item2 ...)

(eq statement1 statement2)


*error*

(*error* string)

Display an error message..

This function allows you to define an error within your LISP routine. Errors can be caused by the programmer, or by user input. You need to be able to either test for these errors, or "trap" them when they occur.

Examples

Code
(defun c:test()
(setq message "too few arguments")
(*error* (message))
)
(defun *error* (msg)
(princ "error: ")
(princ msg)
(princ)
)

Tell me about...

(vl-catch-all-apply 'function list)

(vl-catch-all-error-message error-obj)

(vl-catch-all-error-p arg)


eval

(eval statement)

Evaluate the statement.

The eval function evaluates statement.

Examples

Code | Result
(eval (+ 2 3)) | 5
(eval (ascii "a")) | 97


exit

(exit)

Terminate.

This function forces the current application to quit. ZWCAD displays the : prompt.

Examples

Code
(exit )

Tell me about...

(quit)


exp

(exp number)

Calculate the natural exponent.

The exp returns the natural exponent (the inverse of the natural logarithmic function) raised to the power of the number (ex), where e = 2.71828. The result is a real number.

Examples

Code | Result
(exp 4) | 54.5982
(exp -5) | 0.00673795
(exp 1) | 1.00000
(exp 4.8) | 121.510


expand

(expand integer)

Expand the memory space.

This function expands the amount of node space (a form of memory used by LISP) by integer number of segments.

Examples

Code | Result
(expand 7) | 7

Tell me about...

(alloc integer)


expt

(expt base power)

Calculate the exponential.

This function returns the base raised to the power. When both the base and power are integers, the result is an integer. If either is a real number, the result is a real number.

Examples

Code | Result
(expt 3 2) | 9
(expt 3.0 2) | 9.00000
(expt -3 2) | 9


F Functions

Topics in this section:

  • fill_image
  • findfile
  • fix
  • float
  • foreach
  • function


fill_image

(fill_image x y width height color)

Fills a dialog box's rectangle with color.

This function draws a rectangle (or square), and then fills it with a color. This function must be used between the start_image and end_image functions.

The x and y arguments specify the upper-left corner of the rectangle. The width and height arguments indicate the relative distance to the lower-right corner; these two arguments must be positive.

If you obtained the lower-right coordinates from the dimx_tile and dimy_tile functions, then the origin (0,0) is the upper-left corner.

Examples

Code | Result
(fill_image 0 0 27 -2) | nil


findfile

(findfile filename)

Find that file.

This function searches your computer for the location of a file. This is important because if you specify the name of a file in your LISP program that doesn't exist, you crash the program. When the file exists, its path and filename are returned; if it doesn't, the function returns nil.

Examples

Code | Result
(findfile "base.dcl") | "C:\\Program Files\\ZWCAD 2023 Chs\\base.dcl"
(findfile "zwcad.sds") | "C:\\Program Files\\ZWCAD 2023 Chs\\zwcad.sds"

Notes

The findfile function makes no assumption about the file type or extension of filename. If filename does not specify a drive/directory prefix, findfile searches the ZWCAD library path. If a drive/directory prefix is supplied, findfile looks only in that directory.


fix

(fix number)

Convert that real number into an integer.

This function changes the number to an integer. Real numbers are changed to integers by truncating everything after the decimal point; no attempt is made to round off the number.

Examples

Code | Result
(fix 1.8) | 1
(fix -3.9) | -3
(fix 0) | 0


float

(float number)

Convert that integer into a real number.

This function changes the number to a real number. An integer is changed to a real number by adding a decimal point, followed by zeroes.

Examples

Code | Result
(float 6) | 6.00000
(float 8.4) | 8.40000
(float -3.9) | -3.90000

Note

This function is the opposite of the fix function.


foreach

(foreach variable list expression ...)

Apply the expression to every item in the list.

This function performs an expression on each of the elements of the list. The first argument for foreach is variable. This is a temporary variable where the changed elements are stored. Next is the list argument, containing the elements to be affected. Following the list are one or more expressions, detailing the action to be performed on the list elements. The foreach function returns the result of the last evaluation.

Examples

Code | Result
(setq sample '(1.0 1.5 2.0 2.5)) (foreach result (cdr sample)) | (1.50000 2.00000 2.50000)


function

(function symbol | lambda-expr)

Links and optimizes this function by the Visual LISP compiler.

This function links and optimizes this function by the Visual LISP compiler. This function returns a expression that has been linked and optimized.

Examples

Code | Result
(mapcar (function (lambda (x) (abs x))) '(-10)) | (10)


G Functions

Topics in this section:

  • gc
  • gcd
  • get_attr
  • get_tile
  • getangle
  • getcfg
  • getcname
  • getcorner
  • getdist
  • getenv
  • getfiled
  • getint
  • getkword
  • getorient
  • getpoint
  • getreal
  • getstring
  • getvar
  • graphscr
  • grclear
  • grdraw
  • grread
  • grtext
  • grvecs


gc

(gc)

Collect the garbage in memory.

This function frees up memory no longer being used (short for Garbage Collection). This function always returns nil.

Examples

Code | Result
(gc ) | nil

Don't do this:

(defunc func ()

(setq var "hi")

.

.

.

(setq var nil)

)

Do this instead:

(defunc func (/var) <= automatically frees memory

(setq var "hi")

.

.

.

)


gcd

(gcd integer1 integer2)

Calculate the greatest common denominator.

This function returns the greatest common denominator between integer1 and integer2. Both numbers must be integers. Use the fix function to create integers out of real numbers.

Examples

Code | Result
(gcd 39 45) | 3
(gcd 40 45) | 5


get_attr

(get_attr key attribute)

Determine the attribute of a dialog box's key.

This function returns the value of the dialog box attribute. Note that this value changes due to user input, as well as by calls made by the set_tile function. The key argument specifies the dialog box tile; key is a string and is case-sensitive.


get_tile

(get_tile key)

Determine the value of a dialog box's tile.

This function returns the value of the tile referenced by key; key is a string and is case-sensitive.


getangle

(getangle [point] [prompt])

Ask the user to specify an angle.

This function prompts the user to enter an angle in the current angle units format, which is returned in radians. If a point (2D first point) is provided, getangle determines the angle between the current zero direction (as set in the ANGBASE variable) and the guide line; the angle increases in the counterclockwise direction.

When transforming the entered angle into radians, getangle ignores the ANGDIR variable and measures counterclockwise, with zero radians being the current setting of ANGBASE.

A prompt may be supplied to request a point or angle from the user.

The user cannot enter another LISP expression in reply to the getangle function.

Examples

Code | Result
(getangle "Rotation angle:") | Rotation angle:45 0.785398

Note

The getangle function measures the angle from the 0-angle as defined by the Units command. To measure the angle from the absolute x-axis (0 = East), use the getorient function instead.

Tell me about...

(getorient [pt] [prompt])

(initget [bits] [string])


getcfg

(getcfg parameter)

Determine the value of the parameter.

This function returns data from the system registry. The parameter is a string with the following format:

"AppData/appname/sname/parameter" where:

Cfg Name | Means
AppData | The [AppData] section.
appname | The name of the application.
sname | The section name.
parameter | The parameter name.

Examples

Code
(getcfg "appdata/appname/sname/parameter")

Tell me about...

(setcfg parameter value)


getcname

(getcname [ _ ]command-name)

Determine the localized command name.

This function returns the equivalent command name, depending on the presence of the underscore (_) prefix:

  • When prefixed by _, the localized command name is returned.

  • When not prefixed, the English command name is returned.

Examples

Code | Result
(getcname "_line") | "LINE"
(getcname "_move") | "MOVE"


getcorner

(getcorner point [prompt])

Ask the user to specify the second corner of a rectangle.

This function prompts the user to pick the second corner of a rectangle. The first corner argument (point) is required; the rectangle is drawn from that point as the user drags the cursor across the screen. Very often, this point is obtained from another function, such as getpoint.

The prompt is optional; it may be used to prompt the user for the corner point. Another LISP expression cannot be used in response to this prompt.

Examples

Code | Result
(getcorner '(4.894 1.548) "Select corner: ") | (290.880 -175.471 0.000000)
(getcorner '(0 0)) | (386.491 135.879 0.000000)

Note

The base point is based on the current UCS. Any z-coordinate entered is ignored, and the current elevation is used.

Tell me about...

(initget [bits] [string])


getdist

(getdist [point] [prompt])

Ask the user to specify two points, and returns the distance between them.

This function prompts the user to enter a distance, or to pick one or two points to specify the distance. The distance returned is a real number, regardless of the current distance format specified by the Units command. You can specify a prompt string to be displayed, asking the user for input. Another LISP expression cannot be entered in response to getdist.

Examples

The examples in this section demonstrate the two ways to use the getdist function.

  • Two-point method: leave out the point argument. The getpoint function prompts the user for two points. The prompt for the first point is specified by prompt;

    ZWCAD prompts, "Second point:" for the second pick point. A guide line stretches from the first point to the target to visually help in picking the second point.

    Code Result
    (getdist ) input:1,2
    input:3,4
    2.82843

  • One-point method: include the point argument. The getpoint function prompts the user for one point. The prompt for the second point is specified by prompt. A guide line stretches from the first point to the target to visually help in picking the second point.

    • Code | Result
(getdist '(3.0 2.0) "Length of pipe: ")) | Length of pipe:4,5 2.82843

Note

For more information, see the initget function.

Tell me about...

(initget [bits] [string])


getenv

(getenv variable)

Determine the value of the environment system variable.

This function returns the value of a specified operating system environment variable-for example, as stored by the DOS PATH variable. If the variable exists, its value is returned as a string; if it does not exist, nil is returned.

Examples

Code | Result
(getenv "lib") | "C:\\Program Files\\Microsoft Visual Studio .NET 2003\\SDK\\v1.1\\Lib\\"
(getenv "tmp") | "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\Temp"

Tell me about...

(setenv variable value)


getfiled

(getfiled title filename ext flags)

Display the Select File dialog box.

This function displays the operating system's file dialog box, which allows the user to select a file.

The title argument is the title of the file dialog box; this appears on the title bar. To create a blank titlebar, type " ", but you cannot leave the argument blank.

The filename argument is the default filename that appears highlighted in the File name portion of the dialog box. For no filename, type " ", but you cannot leave the argument blank.

The ext argument specifies the filetype, such as "dwg", "txt", or "lsp". When the argument is " ", no filetype is specified. To specify all filetypes, use "*" for the argument.

The flags argument is a bitcode that specifies options for getfiled.

Argument | Meaning
1 | Warn user about overwriting an existing file.
2 | Disable "Type It" button.
4 | The user can change the extension.
8 | Use the ZWCAD search path and only the name of the file, not the path spec.

You can sum the bits to specify more than one option. For example, bit code 5 is equal to the bits 1 and 4 added together, meaning the user will be warned about overwriting an existing file and is allowed to change the extension.

Examples

Code
(getfiled "Drawing Files" " " "DWG" 2)
(getfiled "Lisp Files" "sample.lsp" "LSP" 6)


getint

(getint [prompt])

Ask the user to specify an integer.

This function asks the user to input an integer, and returns that integer. You can include a prompt argument to ask for the integer.

Examples

Code | Result
(getint "Enter a number: ") | Enter a number:45 45

Tell me about...

(initget [bits] [string])


getkword

(getkword [prompt])

Ask the user to type a word.

This function works along with (equal statement1 statement2 [tolerance])(IDR_166)(initget [bits] [string])(IDR_205) to prompt for a response with restricted answers that you define ahead of time. For example, you may want the user to reply only "yes" or "no". Or, you may want to restrict the range of numbers that the user types to fall between 0 and 15.

Using this function is a two-step process: (1) first, use initget to set the valid response keywords; and (2) then, use getkword to prompt for input. IntelliCAD displays a dialog box listing the valid responses set by initget, as well as the Cancel option.

If the input does not match the predetermined criteria, the function tells the user that the input is invalid with "Try again:" and cycles back to try again. If the input is null (the user pressed the Enter key), getkword returns nil unless a null input is not allowed.

If no keywords are preset with initget, nil is returned.

Examples

Code | Result
(initget 2 "Yes No") (getkword "Are you sure? ") | Are you sure?Yes "yes"

Tell me about...

(initget [bits] [string])


getorient

(getorient [pt] [prompt])

Ask the user to specify an angle.

This function is very much like getangle, except that the angle returned by getorient is independent of the variables ANGDIR and ANGBASE. The base is always at the zero-radian direction towards the right (or east). The angles increase in a counterclockwise direction. Angles returned by getorient are shown as radians.

This function is better used for absolute angles (orientation), rather than relative angles (rotation amount).

Another LISP expression may not be used as a response to a getorient request.

Examples

Code | Result
(getorient "Angle:") | Angle:45 0.785398

Tell me about...

(initget [bits] [string])

(getangle [point] [prompt])


getpoint

(getpoint [point] [prompt])

Ask the user to specify a point.

This function waits for the user to input a point. You can use the point argument to specify a beginning point from which a guide line will be drawn, extending to the target. The user can either enter a coordinate or pick a point manually.

You can also include a prompt to prompt the user for the point.

Examples

Code | Result
(getpoint "Select a point: ") | Select a point:3,4 (3.00000 4.00000 0.000000)

Tell me about...

(initget [bits] [string])

(getcorner point [prompt])


getreal

(getreal [prompt])

Display the Select Color dialog box.

Ask the user to specify a real number.

This function waits for user input of a real number and returns that real number. You can supply a prompt argument asking the user to enter a number.

Examples

Code | Result
(getreal "Scale factor:") | Scale factor:2.5 2.50000

Tell me about...

(initget [bits] [string])


getstring

(getstring [flag] [prompt])

Ask the user to input some text.

Use this function to wait for user input of a string, and then to return it. Only the first 2048 characters of a string are returned.

Set flag to a non-nil value to allow spaces in the string. If flag is non-nil (typically, T is used), the user must terminate the string using the Enter key. If flag is nil or absent, the input string is terminated at the first press of the spacebar or the Enter key.

Because the text entered in a string is taken literally, the user cannot enter another LISP expression as a response to getstring.

Examples

Code | Result
(getstring "Where are you from?") | Where are you from?china "china"

Note

If you want the user to enter one of several pre-defined words, use the getkword function instead.

Tell me about...

(initget [bits] [string])


getvar

(getvar sysvar)

Determine the value of that system variable.

The getvar function retrieves and displays the current settings for ZWCAD system variables. Use the setvar function to change the value of a system variable.

Examples

Code | Result
(getvar "gripblock") | 0
(getvar "plinetype") | 2

Tell me about...

(setvar sysvar value)


graphscr

(graphscr)

Switch to the graphics window.

This function returns to the graphics window from the Prompt History window. This function has no effect if you are already in the graphics screen. It's a good idea to put this function at the beginning of your program to be sure the LISP program begins on the graphics screen.

Examples

Code | Result
(graphscr ) | nil

Tell me about...

(textscr)


grclear

(grclear)

Clear the viewport.

This function temporarily blanks out the graphic window of the current viewport. The redraw function brings the graphics back. The grclear function always returns nil.

Examples

Code | Result
(grclear ) | nil


grdraw

(grdraw point1 point2 color [highlight])

Draw a line.

This function draws a vector between two points in the current viewport. The first two arguments, pint1 and point2, represent 2-D or 3-D endpoints for the vector in terms of the current UCS. These are written as lists of real numbers. If the vector extends beyond the screen, ZWCAD automatically clips it.

The vector is drawn in the color specified, using the integer color argument. The integer -1 signifies the color XOR, which changes its color to complement whatever it draws over, or erases itself when overdrawn.

The highlight argument is optional. If provided, the vector will be drawn using the current highlighting method. If highlight is not provided or is set to zero, the normal display mode is used. The value must be an integer.

Examples

Code | Result
(grdraw '(2 6) '(3 8) 256 1) | nil

Tell me about...

(grvecs vector-lists [trans])


grread

(grread [flag] [bits [cursor]])

Read the data coming in from the input devices.

This function is another method to get user input. It reads successive input via input method. The flag option lets you obtain the user's coordinates. When flag is non-nil, it follows the movements of the mouse or pointer and records the coordinates dynamically, which can generate a great amount of data.

The optional bits argument specifies the following:

Bits | Meaning
1 | Returns the coordinates dynamically in the form of a list. The list consists of the value and the 3-D coordinate.
2 | Returns keystrokes but does not move the cursor. Returns all key values, including cursor and function key codes.
4 | Turn this on if you are going to choose a cursor type.
8 | Turns off the error message "console break" when you cancel out of the loop.
Add the bits above to obtain a combination if desired.
The cursor argument is an integer that corresponds to a cursor type:
Cursor | Meaning
0 | Normal cursor-crosshairs.
2 | No cursor.
4 | Selection cursor-box.
The following chart describes how the information is returned. For example, if you entered the letter, l (keyboard input), the value 2 and the character code would be returned (2 108) in a list.
Type of Input | Returned Value (Definition
Keyboard | 2 (Character code)
Selected Point | 3 (3-dimensional point)
Mouse (other pointer) | 5 (3-dimensional point)

Examples

Code
(defun c:b ()
(while (print (grread 1 5 2)))
)

In the above example, when you move the mouse, a list displays similar to (5 (2.3659 9.2846 0.0)), where the 5 represents the type of input (mouse) and where the coordinates are the exact coordinates of the mouse location. This changes dynamically as you move the mouse. When you select a point, a possible return would be (3 (2.3659 9.2846 0.0)), where 3 designates the type of input (selected point). When you entered a letter, let's say p, your return would be (2 112), where 2 denotes keyboard input, and 112 stands for the character code.


grtext

(grtext [flag text])

Write text on the status line.

This function allows you to put text in the status line or the coordinate status area. The flag determines where the text is placed:

Flag | Meaning
-1 | Status Line
-2 | Coordinate Status Line

The text is a string. If the string is too long for the space provided, it is truncated.

If coordinate status is turned on (the Coords command is set to 1 or 2), the text previously entered into this field is overwritten with new coordinates as soon as the mouse is moved.

You can use the grtext function without any arguments to remove the text from the coordinate status line field when COORDS is turned off or from the status line field.

Examples

Code | Result
(grtext -1 "tool") | "tool"


grvecs

(grvecs vector-lists [trans])

Draw one or more lines.

This function is like grdraw, except that it draws more than one vector at a time in the current viewport. These are temporary vectors that disappear with any command that refreshes the viewport.

The argument vector-lists represents lists for drawing vectors, complete with from and to points and color. The points must be passed as pairs, in two successive point lists:

'([color] from1 to1
[color] from2 to2
...
)

The color portion of the vector list must be within the range of 0-255. If the value is greater than 255, the color becomes XOR ink, which complements anything it draws over. If the color is less than 0, the vector becomes highlighted:

Color | Meaning
-1 | Highlight ink.
0 - 255 | Standard ZWCAD colors.
256 | XOR ink.

Examples

Code | Result
(grvecs '( 2 (1.0 1.0) (3.0 6.0))) | nil
(grvecs '( 1 (3.0 6.0) (6.5 10.5) 4 (0.0 0.0) (3.0 5.0))) | nil

Tell me about...

(nentselp [prompt] [point])

(grdraw point1 point2 color [highlight])


H Functions

Topics in this section:

  • handent
  • help


handent

(handent handle)

Determine the entity name of that handle.

This function retrieves the entity name of an entity with a specific handle. Unlike the entity name, the handle name remains constant throughout the editing process.

Assuming that the handle of the desired entity is "2D", we could perform the following example:

Examples

Code | Result
(handent "2D") | < Entity name: 1fe0568 >

Tell me about...

(entdel entity-name)

((entget entity-name [application-list])

(entlast)

(entmod entity-list)

(entmake [entity-list])

(entmakex [elist])

(entnext [entity-name])

(entsel [prompt])

(entupd entity-name)


help

(help [filename [topic [flag]]])

Display the Help dialog box.

This function displays the ZWCAD help window. The optional arguments have the following effects:

  • filename is the name of the HLP (help) file.

  • flag displays one of the following:

Examples

Code | Result
(help "ZwHelp.exe") | "ZwHelp.exe"

Tell me about...

(setfunhelp "c:filename" [helpfile [topic [command-name]]]])


I Functions

Topics in this section:

  • if
  • initdia
  • initget
  • inters
  • itoa


if

(if test statement1 [statement2])

If it is true, do it; otherwise, do something else.

This function lets you test two conditions: if test is true, then perform statement1, else perform statement2. (Statement2 is optional.) If test is true, then LISP returns the value of statement1. If test is not true, then LISP returns the value of statement2.

Examples

Code | Result
(if (= 100 (abs -100)) "ok") | "ok"
(if (= 12 (* 2 6)) "yes") | "yes"
(if (= 17 (* 2 6)) "yes") | nil

Tell me about...

(progn statement1 statement2 ...)


initdia

(initdia [flag])

Display of the next command's dialog box.

These commands can use of the initdia function: ATTDEF, ATTEXT, BHATCH, BLOCK, COLOR, IMAGE, IMAGEADJUST, INSERT, LAYER, LINETYPE, MTEXT, PLOT, RENAME, STYLE, TOOLBAR, and VIEW.

Parameter

flag

If flag is zero, restoring the default behavior of presenting the command line interface. If this argument is not present or is present and nonzero, the next use (and next use only) of a command will display that command's dialog box rather than its command line prompts.

Returns

nil

Examples

Code | Result
(initdia) (command "_.block") | Displays the block command dialog.
(command "_.block") | Displays the command line prompts.


initget

(initget [bits] [string])

Establish keywords.

This function helps you to restrict the user's choices when responding to LISP expressions, such as the getkword function.

The options for initget are specified with the bits argument. Use the sum-the-bits technique for specifying more than one error-checking option: simply add bits together to combine options. For example, a flag of 36 is a sum of 32 + 4, which uses dashed lines with drawing the guide line and does not allow negative values.

The following table describes the possible meanings for the bits argument:

Bits | Meaning
1 | Do not allow null input (user not allowed to press Enter).
2 | Do not allow zero values.
4 | Do not allow negative values.
8 | Do not check drawing limits, regardless of LIMCHECK setting.
16 | reserved for future use .
32 | Use dashed lines when drawing rubber band lines and boxes.
64 | For getdist only: do not allow input of a z-coordinate.
128 | Ignore above settings, allow any input.

For example, if you want to limit the user's input to only positive numbers (non-negative and non-zero), and draw a rubber-band line with dashes, you add 4 + 2 + 32 to get a value of 38 for the accept variable.

Once the bit code is set, you use string to determine the values that the user is limited to entering in response to the prompt displayed by the following function. This string is a list of keywords to be accepted by the next command. In essence, initget lets you define keywords. If keywords are not to be used, argument keys should be null or an empty string (""). The function always returns nil.

When defining your list of keywords, separate each keyword with a space. Show allowable abbreviations by capitalizing the required letter(s). When the entire word is in capital letters, the user is required to enter the entire word. Keywords may contain letters, numbers, and dashes. Here is an example of a list of keywords:

"One Two THree Four"

Given this, the user can type "three" or just "th" for three.

An alternative method of listing keywords is to write each word in all-capital letters, followed by a comma and the abbreviation for the word, as in the following example:

"ONE,O TWO,T THREE,TH FOUR,F"

This is usually used with (human) languages that do not use upper- and lower-case letters.

"~A B C _F _G ~_H"

The ~ prefix causes the keyword that follows to not be displayed in the popup menu. Use ~~ if you need to have ~ appear as a keyword. Entering a single ~ as a keyword will insert a separator between menu entries.

The first underscore prefix indicates that the remaining keywords are globalized forms of the preceding keywords. The first keyword ("A" in this example) will match the first globalized keyword ("F" in this example), the second keyword will match the next globalized keyword ("B" will match "G" in the example), and so on. The user can enter either the localized or globalized keyword; the globalized keyword will be returned in either case. Only the first globalized keyword is required to have the underscore prefix.

This function can be used with many LISP functions, but not all bits make sense. The functions and their possible bits are as follows:

Function | Bit
(getint) | 1, 2, 4, 128
(getreal) | 1, 2, 4, 128
(getdist) | 1, 2, 4, 32, 64, 128
(getangle) | 1, 2, 32, 128
(getorient) | 1, 2, 32, 128
(getpoint) | 1, 2, 32, 128
(getcorner) | 1, 8, 32, 128
(getkword) | 1, 128
(getstring) | none
(entsel) | none
(nentsel) | none
(nentselp) | none

Examples

Code
(initget 4)
(getreal "enter a positive number")

Tell me about...

(getint [prompt])

(getreal [prompt])

(getdist [point] [prompt])

(getangle [point] [prompt])

(getorient [pt] [prompt])

(getcorner point [prompt])

(getkword [prompt])

(getstring [flag] [prompt])

(entsel [prompt])

(nentsel [prompt])

(nentselp [prompt] [point])


inters

(inters point1 point2 point3 point4 [flag])

Find the intersection.

This function returns the intersection of two lines. Point1 and point2 represent the endpoints of the first line; point3 and point4 represent the endpoints of the second line. When the two lines intersect, the point of intersection is returned. If they do not intersect, nil is returned.

Flag is optional: if flag is not nil (T is typically used), the inters function performs as explained above. When flag is nil, the lines defined by the four points are considered infinite. Inters returns the point at which they eventually cross (unless they are parallel lines, in which case nil is returned).

Examples

Code | Result
(inters '(-2.7 6.4) '(-1 8.3) '(-1 6.9) '(-2 8)) | (-1.63130 7.59443)
(inters '(-2 3) '(2 -4) '(4 1) '(3 1)) | nil


itoa

(itoa integer)

Convert that integer into ASCII.

This function converts the integer into a string. When integer is a real number, it complains, "Error: bad argument type."

Examples

Code | Result
(itoa 5) | "5"
(itoa -3) | "-3"

Tell me about...

(atoi string)


L Functions

Topics in this section:

  • lambda
  • last
  • layoutlist
  • length
  • list
  • listp
  • load
  • load_dialog
  • log
  • logand
  • logior
  • lsh
  • lsplicense


lambda

(lambda arguments expression ...)

Create a temporary, unnamed LISP function.

This function creates another function on-the-fly. It is used when setting all the overhead for a new function is unnecessary. The lambda function usually occurs in the middle of another function, and is often used with apply or mapcar to perform a function on a list.

Examples

Code | Result
(apply '((lambda (a b c) (+ a (* b c))) '( 5 2 3)) | 11


last

(last list)

Determine the last item in that list.

This function returns the last element in a list. The element is not returned in a list, unless the last element is a list, as shown by the examples below.

Examples

Code | Result
(last '(1 2 3)) | 3
(last '("one" "two")) | "two"

Note

This function should be used with caution. For example, you may want a function to retrieve the z-coordinate of a point. However, there are some cases in which the point contains only the x- and y-coordinates. Your function would accidentally get the y-coordinate. For this reason, it is sometimes a better idea to use a mixture of the car and cdr functions.


layoutlist

(layoutlist)

A list of all paper space layouts.

Returns a list of strings. These strings are all paper space layouts in the current drawing.

Examples

Code | Result
(layoutlist ) | ("Layout1" "Layout2")


length

(length list)

Determine how many items are in that list.

This function returns number of items in list. The number returned is an integer.

Examples

Code | Result
(length '(1 2 3 4)) | 4
(length '(1 '(2 3) 4)) | 3

Tell me about...

(vl-list-length list-or-cons-object)


list

(list expression ...)

Make it a list.

This function creates a list from the expressions specified. You may also create the list literally by using the ' (quote) function, as shown in the last example below. Rather than use elements already defined as a list, you may need to create your own list. This list will become a variable, with its values proceeded by the command list.

Examples

Code | Result
(list "string1" "string2") | ("string1" "string2")
(list 1 2) | (1 2)

Tell me about...

(quote statement)


listp

(listp item)

Determine whether an item is a list.

This function tests if item is a list. If the item following listp is a list, the function returns T. If not, nil is returned.

Examples

Code | Result
(listp '("one" "two" "three" )) | T
(listp "one") | nil

Tell me about...

(vl-list* object[object]...)

(vl-list-length list-or-cons-object)


load

(load filename [flag])

Load that LISP file.

LISP program files must be loaded into ZWCAD before they can be run. The load function must be enclosed in parentheses, or ZWCAD will try to load a text or shape file.

The filename argument represents the name of the LSP file to load. You need not enter the file type .lsp, since this is assumed. The filename can also include the directory path. If one is not included, ZWCAD searches the environmental paths specified in the configuration.

If the LSP file is found and loaded, the last expression in the program is returned to the command line. If the file is not found, the program displays an error message indicating that the load failed.

You may want to have the program display some other specified string, represented by the optional flag argument.

Examples

The following examples assume that invalid.lsp does not exist and valid.lsp does. The last expression in valid.lsp is LST-FUNCT .

Code | Result
(load "invalid") | Load failed error
(load "valid") | LST-FUNCT

Tell me about...

(defun [c:] name ([arg1 arg2 ...] / [local-var1 local-var2 ...]) expression)


load_dialog

(load_dialog filename)

Load that dialog box definition file.

This function loads a DCLdialog control file. DCL files must be loaded before a custom dialog box can be displayed by ZWCAD. The filename argument is the name of the DCL file.

This function returns the following codes:

Return Code | Meaning
1 | DCL was successfully loaded.
-1 | DCL file was not found.

Examples

Code | Result
(load_dialog "gpdialog.dcl") | 1

Note

The order of calling a dialog box is as follows:

1.load_dialog

2.new_dialog

3.action_tile, start_image, start_list, etc (perform all dialog box initialization, such as associating an action with a tiles, creating an image, and making the lists for list boxes)

4.start_dialog


log

(log number)

Calculate the natural logarithm.

This function returns the natural logarithm, even though "ln" is usually considered the natural log in mathematics. This function cannot take a negative number. The result is a real number.

Examples

Code | Result
(log 3) | 1.09861
(log 5.9) | 1.77495

Note

The exp function is the opposite of the log function.


log10

(log10 number)

Calculate the base-10 logarithm

This function returns the base-10 logarithm. This function cannot take a negative number. The result is a real number.

Examples

Code | Result
(log10 3) | 0.477121
(log10 5.9) | 0.770852

Note

The exp function is the opposite of the log function.

Tell me about...

(log number)


logand

(logand integer1 integer2 ...)

Determine what is the logical AND.

This is a logic function using the Boolean AND. The result is generated via manipulating bits. If a bit is "on," it is denoted by a 1; if it is "off," it shows a 0. When the first bit AND the second bit (in the column) are on, then that bit is on. If the first bit is off AND the second is off, then that bit is off. The AND function requires that all bits in a column be on.

Examples

Code | Result
(logand 9 27 67) | 1
(logand 4 8 16) | 0


logior

(logior integer1 integer2 ...)

Determine what is the logical OR.

This is a logic function using the Boolean OR. The result is generated via bits, similar to the logand function. If a bit is "on," it is denoted by a 1; if it is "off," a 0 is displayed. If the first bit OR the second bit (in the column) are on, then that bit is on. The OR function requires that at least one bit in a column be on.

Examples

Code | Result
(logior 2 13 34) | 47
(logior 8 2 19) | 27


lsh

(lsh integer1 integer2)

Do a bitwise shift.

This function performs a logical shift of bits. Integer1 denotes the number, while integer2 denotes the number of bits to shift integer1. When integer2 is positive, it shifts to the left; negative shifts to the right.

lsh works with integers only. The 1 signifies the bit is on; the 0 signifies it is off.

Examples

Code | Result
(lsh 2 3) | 16
(lsh 2 0) | 2


lsplicencse

(lsplicencse vernumparameter)

Determines whether the user had been authorized the ZWCAD encryption for the ZWCAD software.

This function returns T if your computer installs the encryption lock for the ZWCAD. Otherwise, returns nil.

The vernumparameter specified the type of the ZWCAD vernum:

vernumparameter | meaning
"ZWCAD_SINGLE" | Standard in stand-alone version
"ZWCAD_PRO_SINGLE" | Professional in stand-alone version
"ZWCAD_EDU_SINGLE" | Educational in stand-alone version
"JIANZHU_SINGLE" | Construct in stand-alone version
"JIXIE_SINGLE" | Mechanical in stand-alone version
"JIEGOU_SINGLE" | Struct in stand-alone version
"JIPAISHUI_SINGLE" | Drainage in stand-alone version
"NUANTONG_SINGLE" | Ventilation in stand-alone version
"DIANQI_SINGLE" | Electrical in stand-alone version
"TSDCAD_SING" | Stamping_mould in stand-alone version
"TSDMOLD_SINGLE" | Plastic_mould in stand-alone version
"ZWCAD" | Standard in online version
"ZWCAD_PRO" | Professional in online version
"ZWCAD_EDU" | Educational in online version
"JIANZHU" | Constuct in online version
"JIXIE" | Mechanical in online version
"JIEGOU" | Construct in online version
"JIPAISHUI" | Drainage in online version
"NUANTON" | Ventilation in online version
"DIANQI" | Electrical in online version
"ZWCAD_HS2D" | High school of 2D in online version
"ZWCAD_HS3D" | High school of 3D in online version
"ZWCAD_HS_TEACHING" | High school teaching in online version
"ZWCAD_HS_STRUCT" | High school struct in online version
"TSDCAD" | Stamping_mould in online version
"TSDMOLD" | Plastic_mouldl in online version

Examples

The following examples assume that you hasn't been authorized the ZWCAD encryption for the ZWCAD software. The last expression in valid.lsp is nil.

Code | Result
(lsplicense "ZWCAD_PRO_SINGLE") | nil


M Functions

Topics in this section:

  • mapcar
  • max
  • mem
  • member
  • menucmd
  • menugroup
  • min
  • minusp
  • mode_tile


mapcar

(mapcar function list1 [list2 ...])

Apply the function to the list.

This function is one of the most powerful tools for handling large lists. Mapcar performs a function on each of the elements of a list, and then returns a second list. There can be multiple lists, but each list must have the correct number of items for the function to affect all the lists at one time.

Examples

Code | Result
(setq a 10 b -20 c -30) (mapcar 'abs (list a b c)) | (10 20 30)


max

(max number1 number2 ...)

Determine which is the biggest number.

The max function chooses the greatest number (real number or integers) from the list. If all the numbers are real, the result is real. If all the numbers are integers, the result is an integer. The combination of real numbers and integers results in a real number.

Examples

Code | Result
(max 8 17) | 17
(max 9.7 9.6) | 9.70000
(max 10) | 10


mem

(mem)

Display the status of the LISP memory.

This function reports on the status of the memory being used by LISP. The parameters reported by mem have the following meanings:

mem | Meaning
Nodes | Total number of nodes allocated to LISP.
Free nodes | Number of nodes freed by garbage collection.
Segments | Number of segments allocated.
Allocate | Size of the segment.
Collections | Number of garbage collections.

Examples

Code | Result
(mem ) | Nodes: - Free nodes: - Segments: - Allocate: 514 Collections: - nil


member

(member item list)

Identify the first occurrence of an item in the list.

This function identifies the first occurrence of an item in a list. A list is returned, beginning with the first occurrence of the item and containing any items following it. This is useful if you need to make a change to a particular item in the list, but you aren't sure exactly where the item is.

Examples

Code | Result
(member '"two" '("one" "two")) | ("two")
(member 'q '(x y z)) | nil


menucmd

(menucmd string)

Execute that menu command.

This function executes a command in the menu bar (cursor menu and pull-down menus). The string parameter uses the following formats:

"menu=value"

"menu=*"

The menu parameter has two parts-for example (menucmd "P1.2=*"). In this case, the "P1" refers to the first pull-down menu (usually the File menu). the ".2" refers to the first item on the menu (usually the Open item). The first values of menu permitted in ZWCAD are:

Menu | Meaning
P0 | Cursor menu
P1 - P16 | Pull-down menus 1-16

The value parameter has the following meanings:

Value | Meaning
? | What is status of the menu item?
* | Display the menu.
~ | Disable the menu item (grayed out).
!. | Prefix menu item with a check mark.
 | (blank) Remove properties.
name | Load the menu name.

Examples

Code | Result
(menucmd "P3=*") | Display menu #3 (the View menu).
(menucmd "P3.1=~") | Disable menu #3, item #1 (the View | Redraw menu item).


menugroup

(menugroup name)

Determine whether a menu group is loaded.

This function checks to see if a menu group is loaded. The name argument specifies the name of the menu group. When name matches the name of a loaded menu group, the menugroup function returns the group's name; otherwise, it returns nil.

Examples

The following examples assume that "tool" is loaded.

Code | Result
(menugroup "tool") | "tool"


min

(min number1 number2 ...)

Determine which is the smallest number.

This function chooses the smallest or minimum number. When all the numbers are integers, then the result is also an integer. Any other combination results in a real number.

Examples

Code | Result
(min 45 98) | 45
(min 45 -98) | -98
(min 2.4 4.9) | 2.40000


minusp

(minusp number)

Determine whether a value is a negative number.

This function determines negative numbers. If number is an integer or a real number and it has a negative value, the minusp function returns a T. Otherwise it returns a nil.

Examples

Code | Result
(minusp -9.4) | T
(minusp 8) | nil
(minusp -8.7) | T


mode_tile

(mode_tile key mode)

Set the mode of the dialog box's tile.

This function sets the mode of the tile identified by key. The mode argument takes one of the following integers:

Mode | Meaning
0 | Enable tile.
1 | Disable tile.
2 | Set the focus to the tile.
3 | Select the contents of an edit box.
4 | Change image highlighting between on and off.


N Functions

Topics in this section:

  • namedobjdict
  • nentsel
  • nentselp
  • new_dialog
  • not
  • nth
  • null
  • numberp


namedobjdict

(namedobjdict)

Return the entity name of the current drawing's named object dictionary, which is the root of all nongraphical objects in the drawing.

This function enables an application can access the nongraphical objects in the drawing.

Examples

Code | Result
(namedobjdict ) | < Entity name: 37c4380 >


nentsel

(nentsel [prompt])

Ask the user to select an entity.

This function works just like entsel, except nentsel lets you to pick an entity and return its name, even when the entity belongs to a block or a polyline. The prompt argument is an optional prompt you can present to the user.

Examples

Code | Result
(nentsel "Select a polyline: ") | Select a polyline: ( (187.151 150.912 0.000000))

Tell me about...

(entsel [prompt])

(initget [bits] [string])

(nentselp [prompt] [point])


nentselp

(nentselp [prompt] [point])

Return a point, without necessarily asking the user.

This function works just like nentsel, except nentselp does not need the user to pick a point. The prompt argument is an optional prompt you can present to the user. When you include the point argument, you do not need to prompt the user for a point.

Examples

Code | Result
(nentselp "Select a polyline: " '(187.151 150.912)) | (< Entity name: 49dc500 > (187.151 150.912 0.000000))

Tell me about...

(initget [bits] [string])

(nentsel [prompt])


new_dialog

(new_dialog dialog dcl-id [function point])

Display a dialog box.

This is the function you use to display a dialog box. The dialog box is identified by dialog within the DCL file named dcl-id. The string dialog is obtained from the load_dialog function.

The new_dialog function optionally executes the LISP routine named function. To ignore this argument, use " "; you have to use the " " when you want to specify the point coordinates but not execute a function.

The optional point argument specifies the x,y coordinates of the upper-left corner. When point consists of negative coordinates, such as '(-1 -1), the dialog box appears at the default location, which is usually the center of the ZWCAD window.

When the new_dialog function is successful, it returns T; otherwise, it returns nil.

Examples

Code
(new_dialog "basedcl" dcl_id)

Note

The order of calling a dialog box is as follows:

1.load_dialog

2.new_dialog

3.action_tile, start_image, start_list, etc (perform all dialog box initialization, such as associating an action with a tiles, creating an image, and making the lists for list boxes)

4.start_dialog


not

(not item)

Determine whether an item is nil.

This function determines whether item is nil. If it is nil, a T is returned. If it is not nil, nil is returned.

Examples

Code | Result
(not (< 5 6)) | nil
(not nil) | T

Note

The not and the null functions are very similar. The difference is that null checks whether the item is bound to nil. Null is meant for testing for empty lists.

Tell me about...

(null item)


nth

(nth integer list)

Display the Select Color dialog box.

Parameters

nth

the position of the item in list(numbered from 0).

list

a list.

Like car and cdr, the function nth is used to separate an element from a list.. This function is much easier to use in long lists to isolate a single element.

The argument integer represents the number of the item to isolate. Remember that the first item in the list is numbered 0, so that when you want the third item you use 2. When integer is larger than the number of items (actually, number - 1 items) in the list, the nth function returns nil.

Examples

Code | Result
(nth 0 '(12 34 89)) | 12
(nth 2 '("one" "two" "three")) | "three"


null

(null item)

Determine whether the item is bound to nil.

The null function confirms that your item is bound to nil. If it is nil, a T is returned. If it is not nil, nil is returned.

Examples

Code | Result
(null (< 6 5)) | T
(null "yes") | nil

Note

  • The null function is the opposite of the boundp function.

  • The not and the null functions are very similar. The difference is that not checks whether the item is nil. Null is meant for testing for empty lists.

Tell me about...

(not item)


numberp

(numberp item)

Determine whether an item is a number.

This function tests item to see if it is a number-either a real number or an integer. If item is a number, a T is returned. If not, nil is returned.

Examples

Code | Result
(numberp 20) | T
(numberp 28.9) | T
(numberp "hello") | nil


O Functions

Topics in this section:

  • open
  • or
  • osnap


open

(open filename mode)

Display the Select Color dialog box.

This function makes a file's filename accessible for input and output functions. The filename argument represents the path and filename of the file to open.

The open function returns a file descriptor (an 8-digit hexadecimal number) for the opened file, which should be stored as a variable using the setq function. Once you have the file descriptor, you must refer to the file using the file descriptor-not the filename!

The mode argument has three options, which must be in lowercase:

Mode | Meaning
"r" | Open the file as read-only; returns nil if the file does not exist.
"w" | Open the file for writing; overwrites existing data; creates a new file if non-existent.
"a" | Open the file for writing; append to existing data; creates a new file if non-existent.

Examples

Code | Result
(open "gpdialog.dcl" "r") | < File: #7C3AB698 >

Note

  • In append mode, new data is added to the end of the existing file.

  • LISP only reads ASCII files (no binary files) using sequential access (no random access).

  • To separate subdirectory names, you use either two backslashes ( \\ ) or a single forward slash ( / ).


or

(or statement ...)

Calculate the logical OR.

This function performs a logical OR to the statements that precede it. If at least one of the statements is true, LISP returns a T. If all are false, LISP returns nil.

Examples

Code | Result
(or nil '()) | nil
(or 2 nil) | T


osnap

(osnap point mode)

Determine the 3-D coordinates of an entity snap.

This function uses the ZWCAD entity snap modes to find a point. You specify which entity snap mode to use with the mode argument. You can assign multiple modes simultaneously.

Mode | Meaning
"nea" | NEArest
"end" | ENDpoint
"mid" | MIDpoint
"cen" | CENter
"gcen" | GCENter
"per" | PERpendicular
"ext" | EXTension
"tan" | TANgent
"qua" | QUAdrant
"ins" | INSertion
"nod" | NODe
"int" | INTersection (3D intersection)
"app" | APParent intersection
"para" | PARAllel
"off" | Off

Using the point argument, you specify a point near the entity where the snap attaches to. If no point is found that specifies the mode requirements, the function returns nil.

Examples

Create a line. The start point is (5 5). The end point is (11 11).

Code | Result
(osnap '(5 5) "mid") | (8.00000 8.00000 0.000000)

Note

The distance allowable between the starting point and the entity is determined by the system variable APERTURE, which ranges from 1 to 50 pixels.


P Functions

Topics in this section:

  • polar
  • prin1
  • princ
  • print
  • progn
  • prompt


polar

(polar point angle distance)

Find a point using polar coordinates.

This function returns a 3-D point at an angle and distance from another point. The given point is rotated by the angle specified in radians, then moved the specified distance from the point.

Examples

Code | Result
(polar '(3 4) 89 3) | (4.53053 6.58021)
(polar '(8.4 4.5) 0.89 3.2) | (10.4141 6.98663)

Note

The angle is measured in radians relative to the x-axis with radians increasing counterclockwise.


prin1

(prin1 [expression [file-descriptor]])

Print it exactly the way it looks.

This function prints data to the screen or to a file. When a file-descriptor is provided, LISP prints to a file; when the file-descriptor is missing, LISP prints to the ZWCAD Prompt History window.

The argument expression represents the expression to be printed. It can be any expression, not just a string. Only the expression is printed, no new line or space is included.

The prin1 function can be used with no arguments to return a null string, in which case an empty file is printed.

Examples

Code | Prints | Result
(prin1 "hello") | "hello" | "hello"
(prin1 "\nName:") | "\nName:" | "\nName:"
(prin1 "Thank you") | "Thank you" | "Thank you"


princ

(princ [expression [file-descriptor]])

Print, taking into account control characters.

This function prints to a file or to the screen. When a file-descriptor is provided, LISP prints to a file; when the file-descriptor is missing, LISP prints to the Prompt History window.

When you are printing to a file, the file must previously have been opened with the open function in write "w" or append "a" mode.

The argument expression represents the expression to be printed. It can be any expression, not just a string. The expression is printed, as well as a new line.

Unlike print and prin1, the princ function activates any control characters present within the expression. You can use the following control characters within the expression:

Control Character | Meaning
\\ | \ backslash character
\" | " quote character
\e | Escape
\n | Newline
\r | Return
\t | Tab
\nnn | Octal code nnn

Examples

Code | Prints | Result
(princ "hello") | hello | "hello"
(princ "\nName:") | Name: | "\nName:"
(princ "Thank you") | Thank you | "Thank you"

Note

The difference between the princ function and LISP's other print-related functions (for example, print and prin1) is that princ acts upon control characters.


print

(print [expression [file-descriptor]])

Print, using formatted printing.

  • This function prints the same way as prin1, with the exception of adding an new-line character before expression and a space after it. Like prin1, the print function treats control characters literally (does not activate them).

Examples

Code | Prints | Result
(print "hello") | "hello" | "hello"
(print "\nName:") | "\nName:" | "\nName:"
(print "Thank you") | "Thank you" | "Thank you"

Note

The difference between the print function and LISP's other print-related functions (for example, prin1 and princ is that print automatically includes a new-line character before expression and adds a space after expression).


progn

(progn statement1 statement2 ...)

Evaluate the statement.

This function evaluates all the statements and returns the value of the last statement.

Generally, the progn function works in conjunction with the if function, since the if function is limited to a single if and then statement. Each if function can have only one then statement and an else statement. The progn allows you to have multiple statements evaluated. The value of the last statement is returned.

Examples

Code | Result
(progn (+ 2 3) (* 7 8)) | 56

Tell me about...

(if test statement1 [statement2])


prompt

(prompt string)

Print the message on the command line.

This function prints the string to the command line and the Prompt History window. The prompt function acts upon control characters.

Examples

Code | Result
(prompt "zwcad") | zwcadnil
(prompt "hello") | hellonil

Note

The difference between the prompt function and LISP's other print-related functions (for example, princ, print, and prin1) is that prompt only prints to the Prompt History window and not to a file.


Q Functions

Topics in this section:

  • quit
  • quote


quit

(quit)

Quit the current LISP routine.

This function forces the current LISP routine to quit. An error message is returned.

Examples

Code | Result
(quit ) | error: quit / exit abort

Tell me about...

(exit)


quote

(quote statement)

Create a list.

When you want LISP to treat the statement literally, you use the quote function. Quote prevents LISP from evaluating the statement. The single quote symbol (') is used as a shortcut for the quote function; the two are interchangeable.

Examples

Code | Result
(quote (+ 2 3)) | (+ 2 3)
(quote zwcad) | ZWCAD

Tell me about...

(function symbol | lambda-expr)


R Functions

Topics in this section:

  • read
  • read-char
  • read-line
  • redraw
  • regapp
  • rem
  • repeat
  • reverse
  • rtos


read

(read string)

Determines the first item in a string.

This function returns the first list item or atom in the string. Spaces may not be used within the string argument unless they are within a list or string.

Examples

Code | Result
(read "one two three") | ONE
(read "(1 2 3)") | (1.00000 2.00000 3.00000)


read-char

(read-char [file-descriptor])

Read a single character.

This function reads a single character from the file or keyboard. When a file-descriptor is included (as assigned by the openfunction), read-char reads from a file. When file-descriptor is missing, read-char reads from the keyboard.

The read-char function doesn't actually return the letter, rather it returns the ASCII code of that letter. To actually see the letter, you must convert the ASCII code using the chr function.

Examples

Code | Result
(read-char ) | input: a 97
(read-char ) | input: M 77


read-line

(read-line [file-descriptor])

Read a whole line.

The read-line function is similar to the read-char function, but is generally much more practical and efficient to use. Anything can be read from a file, since the format is a string. The file is specified by the file-desc, assigned by the open(open filename mode)(IDR_237) function.

Examples

For the following example, assume the file sample.lsp exists, the first line is "C:\Sample\First.txt", and the second line is "Second Line".

Code | Result
(setq file (open "sample.lsp" "r")) (setq c (read-line file)) (setq d (read-line file)) | "C:\\Sample\\First.txt" "Second Line"

Note

  • The read-line function automatically moves to the next line in the file; it returns the next line from the file.

  • When read-line reaches the end of the file, it returns nil.


redraw

(redraw [ename [mode]])

Redraw the viewport or just a single entity.

This function redraws (or refreshes) the entire graphic display screen, or a single entity. Any temporary graphics present (such as those drawn with the grdraw function) disappear with this function.

If an ename (short for entity name) argument is entered, that entity is displayed differently, depending on the value specified in the mode argument:

Mode | Meaning
1 | Perform a standard redraw.
2 | Blank the entity from the screen (a reverse redraw).
3 | Highlight redraw (system variable HIGHLIGHT).
4 | Do not highlight.

When these values are entered as negative numbers, the function affects only the main part of a complex element (for example, a block or polyline). The sub-elements are not affected. This function always returns nil.

Examples

Code | Result
(command "line" '("6 7) '("8 9) "") (setq ent (entlast)) (redraw ent 3) | nil


regapp

(regapp appname)

Register the application.

This function adds the application name to the drawing's list of registered applications. You can register as many applications as you like in each drawing. This application name is registered in the APPID symbol table and is used for grouping together extended entity data assigned to entities. This allows individual applications to recognize their own extended entity data.

The application name itself can be up to 31 characters long, and can contain letters, digits, and special characters. It cannot contain spaces. If the application name already exists, nil is returned.

Examples

Code | Result
(regapp "AM/FM.DESIGNER") | "INTELLICAD-DEPT.52"
(regapp "INTELLICAD-DEPT.52") | "AM/FM.DESIGNER"


rem

(rem number1 number2 [number3 ...])

Determine the remainder of this division operation.

This function returns the remainder when number1 is divided by number2. You can use integers or real numbers. When there are more than two numbers, this function first finds the remainder of number1 divided by number2. Use that remainder and divide by number3 and continue the process.

Examples

Code | Result
(rem 34 24) | 10
(rem 12 2) | 0


repeat

(repeat number statement1 [statement2 ...])

Repeat it.

This function repeats the statements by number of times, where number is a positive integer.

Examples

Code | Result
(setq a 2) (repeat 10 (setq a (+ a 3))) | 32


reverse

(reverse list)

Reverse that list.

This function reverses the order of the items in a list.

Examples

Code | Result
(reverse '(one two three)) | (THREE TWO ONE)


rtos

(rtos number [mode [precision]])

Convert that real number to a string.

This function converts a real number to a string. The argument number is the real number you want to convert.

Mode and precision arguments are optional arguments. The mode (1 through 5) selects the format of the string:

Mode | Meaning
1 | Scientific
2 | Decimal
3 | Engineering
4 | Architectural
5 | Fractional

The precision argument allows you to select the number of places after the decimal point. The range is 0 to 8.

Examples

Code | Result
(rtos 23 1 4) | "2.3000E+01"
(rtos 34.7 3 2) | "2'-11\""

Note

When you leave them out, the mode and precision arguments read the settings of system variables LUNITS (default = decimal units) and LUPREC (default = 4 decimal places). Thus, to automatically use the current system settings, simply leave out mode and precision.


S Functions

Topics in this section:

  • set
  • set_tile
  • setcfg
  • setenv
  • setfunhelp
  • setq
  • setvar
  • setview
  • sin
  • slide_image
  • snvalid
  • sqrt
  • ssadd
  • ssdel
  • ssget
  • ssgetfirst
  • sslength
  • ssmemb
  • ssname
  • ssnamex
  • sssetfirst
  • startapp
  • start_dialog
  • start_image
  • start_list
  • strcase
  • strcat
  • strlen
  • subst
  • substr


set

(set 'symbol statement)

Assign the statement to the symbol.

This function is an assignment function, similar to the setq function. Set assigns the statement argument to symbol. The symbol should be quoted. When left unquoted, it changes the values of previously assigned symbols.

Examples

Code | Result
(set 'a 5) | 5
(set 'b "hello") | "hello"

Note

The difference between the set function and the setq function is that set evaluates the symbol. The following are equivalent expressions:

(set 'i "Me")

(setq i "Me")

Tell me about...

(setq symbol1 statement1 [symbol2 statement2] ...)


set_tile

(set_tile key value)

Set the value of the dialog box tile.

This function sets the value of a dialog box tile.

The key argument is a case-sensitive string that specifies the tile. The value attribute is a string that assigns the new value to the tile.

Examples

Code
(set_tile tile1 val1)


setcfg

(setcfg parameter value)

Set the parameter to the value.

This function changes data in the following registry path: HKEY_CURRENT_USER\Software\ZWSOFT\ZWCAD\2023\en-US\Settings\fconfig (take English version as an example). The value can be any text or number. The parameter is a string with the following format:

"AppData/appname/sname/parameter"

where:

Cfg Name | Meaning
AppData | The [AppData] section.
appname | The name of the application.
sname | The section name.
parameter | The parameter name.

Examples

Code | Result
(setcfg "appdata/appname/sname/parameter" "56") | 56

Tell me about...

(getcfg parameter)


setenv

(setenv variable value)

Set the environment system variable to that value.

This function sets the value of a specified operating system environment variable.

Examples

Code | Result
(setenv "tmp" "one") | "one"

Tell me about...

(getenv variable)


setfunhelp

(setfunhelp c:name [file [topic [command]]])

Registers a command defined by customer with the Help facility, thus the appropriate helpfile and topic are called if the user requests help on that command.

Return

Returns a c:name if successful, otherwise nil.

Parameters

c:name

A string stands the command defined by customer (the C:XXX function). The c: prefix must be included.

file

A string stands for help file.

topic

The file name's extension name is default./p>

titile

A string stands for a command name./p>

This function create your own Help file and associate that Help file and titile with your function.Load the following lisp file and input "test" onto the command line, then it will display "line" index dialog box with "ZWCAD_Dev.chm" help file.

Examples

Code | Result
(defun c:test1() (defun c:test()(getstring "\nTEST: ") (princ)) (setfunhelp "c:test" "ZWCAD_Dev.chm" "line") ) | Displays "line" index dialog box with "ZWCAD_Dev.chm" help file.

Note

You must pay attention that the setfunhelp should be called only after the defun call, which defines the customer-defined command.

Tell me about...

(help [filename [topic [flag]]])


setq

(setq symbol1 statement1 [symbol2 statement2] ...)

Set the symbol to the statement.

This function is LISP's most commonly-used assignment function. This function assigns statement1 to symbol1. For example:

(setq x 16)

sets the value of 16 to the symbol x.

Note

Don't confuse this with the equals function (=. The = function doesn't assign.

Symbol1 is the variable that receives the value, where as statement1 is the value that is assigned to symbol1. Statement1 can be a variable representing a value, a numeric value, or a string.

You can set multiple variables at a time with the setq function. The [symbol2 stmt2]... is optional. When assigning multiple variables, the value returned is the last variable's assigned value. If the symbol is a symbol but without given a value, then the result is nil.

Examples

Code | Result
(setq a 9) | 9
(setq a 6 b 7) | 7
(setq c) | nil

Tell me about...

(set 'symbol statement)


setvar

(setvar sysvar value)

Set the system variable to that value.

This function changes the value of ZWCAD system variables. The sysvar argument is the exact name of the system variable, in string format.

The value is the new value for the system variable. The format of value varies, depending on the system variable; it could be an integer, a real number, a list of x,y or x,y,z-coordinates, or a string-as shown by the examples below.

Examples

Code | Result
(setvar "gripblock" 1) | 1
(setvar "plinetype" 0) | 0

Note

  • The setvar function is identical in nature to the setvar command, with a single exception: the Angbase system variable accepts degrees with the Setvar command but only accepts radians with the setvar function.

  • Some system variables are read-only, which means their value cannot be changed with setvar. For example, the CDate system variable contains the current date and time. You cannot change that with the setvar function. Instead, you must use the Windows Date & Time Properties dialog box. You can, however, retrieve the value of any system variable with getvar. The first eight color numbers have the following meanings:

Tell me about...

(getvar sysvar)


setview

(setview view-descriptor [vport])

Create a 3-D viewpoint.

This function changes the 3-D viewpoint of a specified viewport.

The view-descriptor argument is not the simple x,y,z coordinates, such as '(1.0 2.0 3.0), that you might expect from the Viewpoint command. Instead, it requires the view descriptor table as returned by the tblsearch function. The data is in dotted-pair format and looks like the following:

(0 . "VIEW") (2 . "asdf") (70 . 0) (10 7.62206 8.75728 0.000000) (11 0.000000 0.000000 1.00000) (12 0.000000 0.000000 0.000000) (40 . 5.22240) (41 . 6.89416) (42 . 50.0000) (43 . 0.000000) (44 . 0.000000) (50 . 0.000000) (71 . 0))

Examples

One easy way to create the viewpoint data is with the View Save command. The example code below shows how to create and get this data.

Code | Comments
(command "view" "s" "asdf") (setq vp (tblsearch "VIEW" "asdf")) (setq cv (getvar "cvport")) (setview vp cv) | 1. Create a viewpoint named ASDF. 2. Get the viewpoint data. 3. Get the current viewport number. 4. Set the viewpoint in the viewport.

Note

The vport argument is an optional integer that specifies the viewport number. When you have a single viewport, the argument is not required; the default value is 2. To get the number of the current viewport, use the Cvport system variable, as in the above example.


sin

(sin angle)

Calculate the sine.

This function returns the sine of an angle. The angle is interpreted to be in radians and the result is an real number.

Examples

Code | Result
(sin 34) | 0.529083
(sin -3) | -0.141120


slide_image

(slide_image x y width height slide)

Display a slide in the dialog box.

This function displays an image in a dialog box.

The image is positioned at x,y coordinates. These coordinates are the upper-left corner of the image. The width argument specifies the width of the image in the negative x-direction. The height argument specifies the height of the image in the negative y-direction.

The slide argument is the name of the snapshot file, which can be in EMF (enhanced metafile), WMF (Windows metafile), or SLD (slide) format.

Examples

Code | Result
(slide_image 10 10 15 20 "image.sld") | nil

Note

Use the MSlide command to create an image. For good reproduction, create the snapshot at the same size and aspect ratio (usually 4:3) that you plan to display the image in the dialog box.


snvalid

(snvalid symbol [flag])

Determine whether the symbol table has valid characters.

The snvalid function depends on the system variable EXTNAMES to determine the rules for the symbol. EXTNAMES has two values: 0 and 1(default). The following are not allowed in symbol names, regardless of the setting of EXTNAMES:

The flag argument toggles whether the vertical bar ( | ) character is valid:

  • Control and graphic characters
  • Null string
  • "|" as the first or last character of the name
Flag | Meaning
0 | Vertical bar is not permitted.
1 | Vertical bar is permitted.

Examples

Code | Result
(snvalid "A") | T
(snvalid "a|b" 1) | T
(snvalid "ab|" 1) | nil
(snvalid "a|b" 0) | nil


sqrt

(sqrt number)

Calculate the square root.

This function returns the square root of the number. The result is always a real number.

Examples

Code | Result
(sqrt 4) | 2.00000
(sqrt 89) | 9.43398


ssadd

(ssadd [entity-name [selection-set]])

Add it to the selection set.

This function adds entity entity-name to selection-set or creates a new selection set (when ssadd is used without arguments). The ssadd function works in one of the three ways below:

Code | Result
(ssadd) | A new selection set is created with no entitys.
(ssadd entity-name) | A new selection set is created containing entity-name as the only entity.
(ssadd entity-name selection-set) | Adds the entity, entity-name, to an existing selection set, selection-set.

The new or revised selection set name is returned in a format similar to the following:

< Selection set: 26146268 >

ZWCAD can have more than one selection set open at a time.

Examples

Code | Comments
(setq sset1 (ssadd)) (setq ent1 (car (entsel))) (ssadd ent1 sset1) (setq ent2 (entlast)) (ssadd ent2 sset1) | Creates a new selection set called sset1. Prompts the user to select the entity to set to ent1 Adds ent1 to sset1. Returns last entity in drawing; sets it to ent2. Adds ent2 to sset1.


ssdel

(ssdel entity-name selection-set)

Erase it from the selection set.

This function deletes the entity, entity-name, from the selection set, selection-set. Unlike the ssadd function, entity-name and selection-set are not optional.

If entity-name is part of the selection set, ssdel deletes it and returns the selection set. If it is not part of the selection set, a nil is returned.

Examples

Code | Result
(setq sset1 (ssget)) (setq ent1 (entnext)) (ssadd ent1 sset1) (ssdel ent1 sset1) (ssdel ent2 sset1) | Creates a new selection set called sset1. Finds the first entity in the drawing and sets it to ent1. Adds ent1 to sset1 . Deletes ent1 from sset1. Assuming ent2 is set to an entity(not in sset1), a nil would return.


ssget

(ssget [mode] [point1 [point2]] [point-list] [filter-list])

Ask the user to select entities.

This function prompts the user to select entities. When all arguments are left out, the ssget function prompts the user with the "Select entities:" prompt. This is the only situation when ssget highlights selected entities. The ssget function returns < Selection set: 26146268>. The selection set does not contain attributes nor polyline vertices.

The mode argument specifies the entity selection method:

Mode | Meaning | Points | Example
 | (none) Single pick point | point1 | (ssget '(10 15)) or (ssget)
"C" | Crossing | point1 point2 | (ssget "C" '(1 1) '(2 2))
"CP" | Crossing Polygon | points-list | (ssget "CP" ptlist)
"F" | Fence | points-list | (ssget "F" ptlist)
"I" | Implied | none | (ssget "I" )
"L" | Last | none | (ssget "L" )
"P" | Previous | none | (ssget "P" )
"W" | Window | point1 point2 | (ssget "W" '(1 1) '(2 2))
"WP" | Window Polygon | points-list | (ssget "WP" ptlist)
"X" | All | none | (ssget "X" )
":S" | single selection | none | (ssget ":S" )

The "I" mode creates an "implied" selection set of entities selected while system variable PICKFIRST is on.

The point1 (and many times point2) argument specifies the pick point for the selection mode, as noted in the table above.

The filter-list argument is a list that specifies entity properties in dotted-pair format, such as:

(ssget "X" '((0 . "CIRCLE") (62 . 1)))

which selects all circles colored red (color 1). In addition, the special dotted-pair of -4 lets you include a relational test, such as:

(ssget "X" '((0 . "CIRCLE") (62 . 1) (-4 . "< ") (40 . 15.0))

which selects all red circles less than 15 units in radius. For this function, the operators recognized by ZWCAD are:

Operator | Meaning
"&" | Bitwise AND (integers only).
"&=" | Bitwise masked equals (integers only).
"*" | All.
"=" | Equals.
"!=" | Not equal to.
"/=" | Not equal to.
"<>" | Not equal to.
"<" | Less than.
"<=" | Less than or equal to.
">" | Greater than.
">=" | Greater than or equal to.

These operators are used with integers; the bitwise operators cannot be used with real numbers; the "*" operator is the only that can be used with strings.

Note

The current entity snap setting is ignored by the ssget function.


ssgetfirst

(ssgetfirst)

Determine which entities are highlighted and/or gripped.

This function reports the number of entities in the drawing that are highlighted (selected) and gripped. Grips are the small squares that surround a selected entity that you can use to manipulate or modify the entity.

The ssgetfirst function returns a list with two elements: the first element is a selection set of entities that are gripped but not selected; the second element is a selection set of entities that are gripped and selected.

Examples

Code | Comments
(ssgetfirst ) | Displays a list of highlighted and gripped entities.

Tell me about...

(ssget [mode] [point1 [point2]] [point-list] [filter-list])

(sssetfirst grip-set [pick-set])


sslength

(sslength selection-set)

Determine how many entities are in the selection set.

This function reports the number of entities in the selection set, selection-set.

Note

Use the ssget function to create the selection-set.

Examples

Code | Result
(setq sset1 (ssadd)) (setq ent1 (car (entsel))) (ssadd ent1 sset1) (sslength sset1) | Creates a new selection set called sset1. Prompts user to select entity to set to ent1. Adds ent1 to sset1. Returns 1.


ssmemb

(ssmemb entity-name selection-set)

Determine whether an entity is in the selection set.

This function determines if the entity, entity-name, is in the selection set, selection-set. This function searches through the entities within the selection set to find if entity-name is included. If it is included, the entity's name is returned. If not, nil is returned.

Examples

Code | Result
(setq sset1 (ssadd)) (ssadd ent1 sset1) (ssmemb ent1 sset1) (ssmemb ent2 sset1) | Creates a new selection set called sset1. Adds ent1 to sset1. Asks if ent1 is a member of sset1. Yes, so entity name is returned. Asks if ent2 is a member of sset1. No, so nil is returned.


ssname

(ssname selection-set index)

Identify the nth entity in the selection set.

This function returns the name of the entity corresponding to the index in the given selection-set. The index refers to the order in which the entities were placed in the selection set starting with 0: index #0 is the first entity, index #1 is the second entity, and so forth.

Examples

Code | Comments
(setq a (ssget)) (setq part1 (ssname a 0) (setq part2 (ssname a 1) | Creates new selection set. Returns the name of the 1st entity. Returns the name of the 2nd entity.

Tell me about...

(entnext [entity-name])


ssnamex

(ssnamex selection-set index)

Retrieves information about how a selection set was created.

This function only retrives information about selection sets with entities from the current drawing's model space and paper space. Nongraphical objects or entities in other block definitions are not included.

Examples

Code | Comments
(setq part1(ssnamex ss1 0)) | Returns entity data.


sssetfirst

(sssetfirst grip-set [pick-set])

Grip these entities.

This function highlights entities in pick-set and places grips around entities in grip-set. (Grips are the small squares that surround a selected entity that you can use to manipulate or modify the entity.)

Note

Use the ssgetfirst function to create the grip-set and pick-set selection sets.

Examples

Code
(sssetfirst ss)

Tell me about...

(ssget [mode] [point1 [point2]] [point-list] [filter-list])

(ssgetfirst)


startapp

(startapp appname [filename])

Launch this Windows application.

This function starts any other Windows application appname. Optionally, it also loads a filename into that application. When successful, the startapp function returns an integer greater than 2; when unsuccessful, it returns 2.

Examples

Code | Result
(startapp "base.dcl") | 11
(startapp "abc") | 2


start_dialog

(start_dialog)

Display the Select Color dialog box.

This function displays a dialog box and accepts clicks the user inputs with the mouse button. It returns the status code passed to it by the done_dialog function:

Argument | Meaning
1 | User clicked OK button.
0 | User clicked Cancel button.
-1 | The term_dialog function was used.

Examples

Code
(start_dialog )

Note

  • A dialog box is first initialized by the new_dialog function.

  • The order of calling a dialog box is as follows:

  • load_dialog

  • new_dialog

  • action_tile, start_image, start_list, etc (perform all dialog box initialization, such as associating an action with a tiles, creating an image, and making the lists for list boxes)

  • start_dialog


start_image

(start_image key)

Start creating a dialog box image.

This function signals the start of the image key in a dialog box. This function is used to precede the dialog box drawing functions: fill_image, slide_image, and vector_image.

To end the drawing, use the end_image function.

Examples

Code
(start_image key)


start_list

(start_list key [operation [index]])

Start processing a list box.

This function signals the start of processing a list key in a dialog box. The optional operation argument describes the list operation to be performed (default = 3):

Operation | Meaning
1 | Change contents of the list.
2 | Append new data to the list.
3 | Replace the list with a new one (default).

The optional index argument is used only when operation = 1. It indicates the item # to be changed; the first item is #0; the second item is #1, and so on.

Examples

Code | Result
(start_list ssg) (start_list ssg 3) (start_list ssg 1 4) (start_list ssg 2) | Replace list with new list. Same action as above. Change the fifth item on the list. Add data to the list.

Note

You also use this function when creating list boxes and drop-down list boxes in DCL. For examples using this function in conjunction with DCL, see list_box and popup_list (drop-down list box).


strcase

(strcase string [flag])

Convert this string to all upper- or all lower-case.

This function converts text in a string to all upper-case or all lower-case (when flag is non-nil).

The case to be converted is specified by the flag argument. When omitted or set to nil, all characters are converted to upper-case. When not nil (T is typically used), all alphabetic characters are converted to lower-case.

Examples

Code | Result
(strcase "zwcad") | "ZWCAD"
(strcase "HELLO" T) | "hello"


strcat

(strcat string1 [string2] ...)

Make one big string out of all these little strings.

This function joins together strings, an operation also known as concatenation.

Examples

Code | Result
(strcat "zw" "cad") | "zwcad"
(strcat "H" "e" "l" "l" "o") | "Hello"


strlen

(strlen [string1] [string2] ...)

Determine how many characters are in a string.

This function counts the number of characters in a string, or series of strings. It returns the amount as an integer. If an empty string exists or no string is provided, the value is zero.

Examples

Code | Result
(strlen "What's your name?") | 17
(strlen "") | 0


subst

(subst new old list)

Substitute this for that in a list.

This function is much like the search-and-replace function in a word processor. The difference is that subst works with lists, not strings.

The subst function replaces every occurrence of old with new in list. You can use this function together with the assoc function to manipulate dotted-pair entity data.

Examples

Code | Result
(subst '2 '3 '(3 10)) | (2 10)
(subst 'w 'o '(o our)) | (W OUR)


substr

(substr string start [length])

Give me part of that string.

This function takes apart strings. It takes out a sub-string from the original string, which you can then assign to a variable or use as any other string.

The argument start indicates which character in the string to start from. Unlike other functions that deal with elements of a list, substr considers the first character in the string as number one (not #0). When the start position is greater than the length of the string, substr returns "" (non-nil).

The length argument represents the number of characters to include in the sub-string; this value must be a positive integer. If this argument is not provided, the sub-string extends to the end of the original string. When the integer is larger than the number of characters available, the entire list from the specified first character to the end will be returned with no error.

Examples

Code | Result
(substr "congratulation" 4) | "gratulation"
(substr "angthing" 4) | "thing"


T Functions

Topics in this section:

  • tablet
  • tblnext
  • tblobjname
  • tblsearch
  • term_dialog
  • terpri
  • textbox
  • textpage
  • textscr
  • trace
  • trans
  • trim
  • type


tablet

(tablet code [row1 row2 row3 direction])

Retrieves and sets digitizer calibrations.

This function set the new calibration according to the arguments that row1, row2, row3, and direction. This function return the current digitizer calibration.

Note

  • The value of code is 0 or 1. If the code value is 0, return the current digitizer calibration and omit the remaining arguments. If the code value is 1, set the new calibration according.

  • The direction is a 3D point. row1, row2 and row3 are three 3D point.

  • If this function fails, it returns nil.

Examples

Code
(tablet 0)


tblnext

(tblnext table-name [flag])

Get me the next item in the table.

This function finds the first (or next, depending on the flag) instance of a symbol type in the drawing table. The argument table-name represents the name of symbol type to search for. Valid table-names are:

Table-name | Meaning
"appid" | Application identification.
"block" | Block names.
"dimstyle" | Dimension style names.
"layer" | Layer names.
"ltype" | Linetype names.
"style" | Text style names.
"ucs" | UCS names.
"view" | View names.
"vport" | Viewport names.

First, the tblnext function returns the first specified symbol in the table. When the symbol is found, it is returned as a list of dotted pairs. Used repeatedly, the next symbol is returned in order. When no more symbols exist in the list, nil is returned.

When the flag argument is supplied (typically as T), the search begins from the top of the table.

Examples

Code | Result
(tblnext "layer") | ((0 . "LAYER") (2 . "0") (70 . 64) (6 . "Continuous") (62 . 7) (290 . 1) (370 . -3))
(tblnext "layer" T) | ((0 . "LAYER") (2 . "0") (70 . 64) (6 . "Continuous") (62 . 7) (290 . 1) (370 . -3))


tblobjname

(tblobjname table-name symbol)

Determine the name of the entity associated with that symbol.

This function returns the entity name of a specified symbol table entry. The tblobjname function searches the symbol table table-name for symbol. It returns the entity name of that symbol table entry. Valid table-names are:

Table-name | Meaning
"appid" | Application identification.
"block" | Block names.
"dimstyle" | Dimension style names.
"layer" | Layer names.
"ltype" | Linetype names.
"style" | Text style names.
"ucs" | UCS names.
"view" | View names.
"vport" | Viewport names.

Default symbol names are:

Symbol | Meaning
"CONTINUOUS" | Default linetype.
"0" | Default layer.
"STANDARD" | Default text style.
"STANDARD" | Default dimension style.

Examples

Code | Result
(tblobjname "style" "standard") | < Entity name: 6525520 >
(tblobjname "layer" "0") | < Entity name: 6525270 >


tblsearch

(tblsearch table-name symbol [flag])

Search the table for a symbol.

This function obtains information about a known symbol from a drawing table-name. After entering in the table-name argument and the known symbol name, a list is returned containing dotted pairs for the symbol.

The flag (when set non-nil, such as T) lets the tblnext function retrieve the next item in the table:

(tblsearch "layer" "0" T)

(tblnext "LAYER")

The list returned is exactly like that returned from tblnext.

Examples

Code | Result
(tblsearch "layer" "0") | ((0 . "LAYER") (2 . "0") (70 . 64) (6 . "Continuous") (62 . 7) (290 . 1) (370 . -3))
(tblsearch "style" "standard") | ((0 . "STYLE") (2 . "Standard") (70 . 64) (3 . "txt") (4 . "") (40 . 0.000000) (41 . 1.00000) (42 . 2.50000) (50 . 0.000000) (71 . 0))


term_dialog

(term_dialog)

Terminate all dialog boxes.

This function terminates all dialog boxes. This function is especially useful for closing several nested dialog boxes all at once.

Examples

Code | Result
(term_dialog ) | nil


terpri

(terpri)

Print a carriage return.

This function prints a new line to the command prompt area, and returns nil.

Examples

Code | Result
(terpri ) | nil

Note

Do not use this function to print a new line in a file. For that, use print or princ instead.


textbox

(textbox entity-list)

Determine the x,y,z dimensions of that text entity.

This function returns the 3-D coordinates of a box that encloses a text entity. The lower-left corner is always (0,0). The argument entity-list must refer to a text entity but not text in dimensions and blocks.

Examples

Code | Result
(setq txt (entlast)) (setq txt1 (entget txt)) (textbox txt1) | Entity name. Dotted-pair list. ((0.000000 0.000000 0.000000) (409.496 153.561 0.000000))


textpage

(textpage)

Switch to the Text window and clear it.

This function is the same as textscr, except the Prompt History window is cleared. This gives you an entire empty page.

Examples

Code | Result
(textpage ) | nil


textscr

(textscr)

Switch to the Prompt History window.

The textscr function is the opposite of graphscr. If you are already in the textscr, the function has no effect.

Examples

Code | Result
(textscr 1) | nil


trace

(trace function . . .)

Turn on debug mode.

Used for debugging, this function sets a trace debug aid for the specified function. Each time the function is run, the trace appears and prints the result of the function.

Note

Use untrace to turn off the trace debugging aid.

Examples

Code | Result
(defun fun (a b) (+ a b)) (trace fun) (fun 3 4) | Entering FUN: 3 4 Result: 7 7

Tell me about...

(untrace function ...)


trans

(trans point from to [flag])

Translates that point from one coordinate system to another.

This function translates (moves) a point from one to another coordinate system.

The point argument is a 3-D point in list format. The meaning of this argument depends on the setting of flag.

  • The from argument describes the current coordinate system:

Code | Coordinate system
0 | World coordinate system (WCS).
1 | Current user-defined coordinate system (UCS).
2 | Display coordinate system ( DCS) of current viewport-with code 0 or 1 DCS of current model space viewport-with code 3.
3 | Paper space DCS

  • The two argument describes the destination coordinate system, using the same codes as the argument from.

  • The flag argument determines the meaning of point:

Flag | Meaning
T | 3D displacement.
nil | 3D point.

Examples

Code | Result
(trans '(3.6 -4 5.4) 1 0) | (3.60000 -6.64680 0.989949)


trim

(trim string)

Trims all leading and trailing whitespace from the string.

This function returns a copy of a string without leading spaces and trailing spaces.

The string argument is any valid string expression. If string contains null, null is returned.

Examples

Code | Result
(trim " abc def gh ") | "abc def gh"


type

(type item)

Determine the type (for example, file, integer, string, and so forth) of an item.

This function returns the type (such as real number, integer, list, entity name, and so forth) of the item. The following table lists the various types and their meanings.

Argument | Meaning
ENAME | Entity name.
EXSUBR | External subroutines: SDS functions.
FILE | File descriptor.
INT | Integer number.
LIST | List and user-defined function.
PAGETB | Function paging table.
PICKSET | Selection set.
REAL | Real number.
STR | String.
SUBR | Subroutines: LISP functions.
SYM | Symbol.

Examples

Code | Result
(type 10) | INT
(type "zwcad") | STR


U Functions

Topics in this section:

  • unload_dialog
  • untrace


unload_dialog

(unload_dialog dcl_id)

Unload that dialog box.

This function unloads a dialog box identified as dcl_id.

Examples

Code | Result
(unload_dialog hlg) | nil

Tell me about...

(load_dialog filename)

(new_dialog dialog dcl-id [function point])


untrace

(untrace function ...)

Turn off debug mode.

This function turns off the trace debugging aid for the selected function, which was set using trace. The last function name is returned.

Examples

Clears trace aid for FNAME function.

Code | Result
(untrace fname) | FNAME


V Functions

Topics in this section:

  • vector_image
  • ver
  • vl-acad-defun
  • vl-acad-undefun
  • vl-arx-import
  • vl-bb-ref
  • vl-bb-set
  • vl-catch-all-apply
  • vl-catch-all-error-message
  • vl-catch-all-error-p
  • vl-cmdf
  • vl-consp
  • vl-directory-files
  • vl-doc-export
  • vl-doc-import
  • vl-doc-ref
  • vl-doc-set
  • vl-every
  • vl-exit-with-error
  • vl-exit-with-value
  • vl-file-copy
  • vl-file-delete
  • vl-file-directory-p
  • vl-file-rename
  • vl-file-size
  • vl-file-systime
  • vl-filename-base
  • vl-filename-directory
  • vl-filename-extension
  • vl-filename-mktemp
  • vl-get-resource
  • vl-list*
  • vl-list->string
  • vl-list-exported-functions
  • vl-list-length
  • vl-list-loaded-vlx
  • vl-load-all
  • vl-load-com
  • vl-load-reactors
  • vl-mkdir
  • vl-member-if
  • vl-member-if-not
  • vl-position
  • vl-prin1-to-string
  • vl-princ-to-string
  • vl-propagate
  • vl-registry-delete
  • vl-registry-descendents
  • vl-registry-read
  • vl-registry-write
  • vl-remove
  • vl-remove-if
  • vl-remove-if-not
  • vl-some
  • vl-sort
  • vl-sort-i
  • vl-string->list
  • vl-string-elt
  • vl-string-left-trim
  • vl-string-mismatch
  • vl-string-position
  • vl-string-right-trim
  • vl-string-search
  • vl-string-subst
  • vl-string-translate
  • vl-string-trim
  • vl-symbol-name
  • vl-symbol-value
  • vl-symbolp
  • vl-unload-vlx
  • vl-vbaload
  • vl-vbarun
  • vl-vlx-loaded-p
  • vlax-3D-point
  • vlax-add-cmd
  • vlax-create-object
  • vlax-curve-getArea
  • vlax-curve-getClosestPointTo
  • vlax-curve-getClosestPointToProjection
  • vlax-curve-getDistAtParam
  • vlax-curve-getDistAtPoint
  • vlax-curve-getEndParam
  • vlax-curve-getEndPoint
  • vlax-curve-getFirstDeriv
  • vlax-curve-getParamAtDist
  • vlax-curve-getParamAtPoint
  • vlax-curve-getPointAtDist
  • vlax-curve-getPointAtParam
  • vlax-curve-getSecondDeriv
  • vlax-curve-getStartParam
  • vlax-curve-getStartPoint
  • vlax-curve-isClosed
  • vlax-curve-isPeriodic
  • vlax-curve-isPlanar
  • vlax-dump-object
  • vlax-ename->vla-object
  • vlax-erased-p
  • vlax-for
  • vlax-get-object
  • vlax-get-or-create-object
  • vlax-get-property
  • vlax-get-acad-object
  • vlax-import-type-library
  • vlax-invoke-method
  • vlax-ldata-delete
  • vlax-ldata-get
  • vlax-ldata-list
  • vlax-ldata-put
  • vlax-ldata-test
  • vlax-make-safearray
  • vlax-make-variant
  • vlax-map-collection
  • vlax-method-applicable-p
  • vlax-product-key
  • vlax-property-available-p
  • vlax-put-property
  • vlax-read-enabled-p
  • vlax-release-object
  • vlax-remove-cmd
  • vlax-safearray-fill
  • vlax-safearray-get-dim
  • vlax-safearray-get-element
  • vlax-safearray-get-l-bound
  • vlax-safearray-get-u-bound
  • vlax-safearray-put-element
  • vlax-safearray-type
  • vlax-safearray->list
  • vlax-tmatrix
  • vlax-typeinfo-available-p
  • vlax-variant-change-type
  • vlax-variant-type
  • vlax-variant-value
  • vlax-vla-object->ename
  • vlax-write-enabled-p
  • vlr-acdb-reactor
  • vlr-add
  • vlr-added-p
  • vlr-beep-reaction
  • vlr-command-reactor
  • vlr-data-set
  • vlr-docmanager-reactor
  • vlr-dwg-reactor
  • vlr-dxf-reactor
  • vlr-editor-reactor
  • vlr-insert-reactor
  • vlr-linker-reactor
  • vlr-lisp-reactor
  • vlr-miscellaneous-reactor
  • vlr-mouse-reactor
  • vlr-notification
  • vlr-object-reactor
  • vlr-owner-add
  • vlr-owner-remove
  • vlr-owners
  • vlr-pers
  • vlr-pers-list
  • vlr-pers-p
  • vlr-pers-release
  • vlr-reaction-names
  • vlr-reaction-set
  • vlr-reactions
  • vlr-reactors
  • vlr-remove
  • vlr-remove-all
  • vlr-set-notification
  • vlr-sysvar-reactor
  • vlr-toolbar-reactor
  • vlr-type
  • vlr-types
  • vlr-undo-reactor
  • vlr-wblock-reactor
  • vlr-window-reactor
  • vlr-xref-reactor
  • vports


vector_image

(vector_image x1 y1 x2 y2 color)

"Draw a vector in the dialog box."

Parameters

x1

the X Coordinate of the first point.

y1

the Y Coordinate of the first point

x2

the X Coordinate of the second point

y2

the Y Coordinate of the second point

color

the color value in ZWCAD, or the special color listed as follows:

color value | Meaning
-2 | the background color of current graphic screen
-15 | the background color of current dialog
-16 | the foreground color of current dialog
-18 | the color of current dialog

Returns

The integer number that represents the color

This function draws a vector of a specified color in a dialog box. The vector is drawn from x1,y1 to x2,y2. The origin (0,0) of the dialog box tile is at the upper-left corner.

Examples

Code | Result
(vector_image 0 0 2 5 -2) | nil


ver

(ver)

Determine the version number of this LISP.

This function returns the version number of the LISP programming language included with ZWCAD.

Examples

Code | Result
(ver ) | "LISP Release 1.0"


vl-acad-defun

Defines an AutoLISP function symbol as an external subroutine.


vl-acad-undefun

Undefines an AutoLISP function symbol so it is no longer available to ObjectARX applications.


vl-arx-import

Imports ObjectARX/ADSRX functions into a separate-namespace VLX.


vl-bb-ref

Returns the value of a variable from the blackboard namespace.


vl-bb-set

Sets a variable in the blackboard namespace.


vl-catch-all-apply

(vl-catch-all-apply 'function list)

Passes a list of arguments to a specified function and intercepts any exceptions.

If the function invoked by vl-catch-all-apply completes successfully, it is the same as using apply. The benefit of using vl-catch-all-apply is that it allows you to intercept errors and continue processing. When you use apply, an exception occurs and an error message displays.

The function accepts two arguments:

Argument | Meaning
'function | A symbol identifying a defun, or a lambda expression
list | A list containing arguments to be passed to the function

Examples

Code | Result
(setq catchit (vl-catch-all-apply '/ (list 100 10))) | 10
(setq catchit (vl-catch-all-apply '/ (list 100 0))) | #<%catch-all-apply-error%>

Note

The vl-catch-all-apply function intercepts the error and returns an error object. Use vl-catch-all-error-message to see the error message contained in the error object.

Tell me about...

(*error* string)

(apply 'function list)

(vl-catch-all-error-p arg)

(vl-catch-all-error-message error-obj)


vl-catch-all-error-message

(vl-catch-all-error-message error-obj)

Returns a string from an error object.

The vl-catch-all-apply function traps the error and returns an error object. Use vl-catch-all-error-message to see the error message contained in the error object.

The function accepts one argument:

Argument | Meaning
error-obj | An error object returned by vl-catch-all-apply

Examples

Code | Result
(setq catchit (vl-catch-all-apply '/ (list 100 0))) (vl-catch-all-error-message catchit) | "divide by zero"

Tell me about...

(*error* string)

(vl-catch-all-apply 'function list)

(vl-catch-all-error-p arg)


vl-catch-all-error-p

(vl-catch-all-error-p arg)

Determines whether an argument is an error object returned from vl-catch-all-apply.

If the supplied argument is an error object returned from vl-catch-all-apply, this function returns T; otherwise nil.

The function accepts one arguments:

Argument | Meaning
arg | Any argument

Examples

Code | Result
(setq catchit (vl-catch-all-apply '/ (list 100 0))) (vl-catch-all-error-p catchit) | T

Tell me about...

(*error* string)

(vl-catch-all-apply 'function list)

(vl-catch-all-error-message error-obj)


vl-cmdf

(vl-cmdf [arguments] ...)

Executes a ZWCAD command.

This function evaluates all the supplied arguments before executing the ZWCAD command, and will not execute the ZWCAD command if it detects an error during argument evaluation.

The function accepts some optional arguments:

Argument | Meaning | Note
arguments | ZWCAD commands and their options | They can be strings, reals, integers or points, as expected by the prompt sequence of the executed command. A null string ("") is equivalent to pressing ENTER on the keyboard. Invoking the function without any arguments is equivalent to pressing ESC and cancels most ZWCAD commands.

Examples

Code | Result | Note
(vl-cmdf "line" '(0 0) '(100 200) (200 300) "") | error: bad function | Because vl-cmdf evaluates each argument before passing the command to ZWCAD, the invalid point list (200 300) is detected and the command is not executed.

Note

In AutoCAD, the vl-cmdf function is similar to the command function, but differs from command in the way it evaluates the arguments passed to it. But in ZWCAD, the ways in which these two functions evaluate the arguments are same.

Tell me about...

(command [arguments] ...)


vl-consp

(vl-consp list-variable)

Determines whether or not a list is nil.

This function determines whether a variable contains a valid list definition.

The function accepts one argument:

Argument | Meaning
list-variable | A list

Examples

Code | Result
(vl-consp (cons 0 "LINE")) | T
(vl-consp pi) | nil


vl-directory-files

(vl-directory-files [directory pattern directories])

Lists all files or sub directories in a given directory.

A list of file and path names; otherwise nil if no files match the specified pattern.

The function accepts three optional arguments:

Argument | Meaning
directory | A string naming the directory to collect files for; if nil or absent, vl-directory-files uses the ZWCAD's target directory
pattern | A string containing a DOS pattern for the file name; if nil or absent, vl-directory-files assumes “*.*”
directories | An integer that indicates whether the returned list should include directory names. Specify one of the following: -1 List directories only 0 List files and directories (the default) 1 List files only

Examples

Code | Result
(vl-directory-files "C:\\WINDOWS\\Help") | ("." ".." "Tours" "netcfg.hlp" "api.chm" "hhaxref.chm" "htmlref.chm" "htmlhelp.chm" "acsignext.hlp")
(vl-directory-files "C:\\WINDOWS\\Help" nil 1) | ("netcfg.hlp" "api.chm" "hhaxref.chm" "htmlref.chm" "htmlhelp.chm" "acsignext.hlp")
(vl-directory-files "C:\\WINDOWS\\Help" "*.hlp") | ("netcfg.hlp" "acsignext.hlp")


vl-doc-export

Makes a function available to the current document.


vl-doc-import

Imports a previously exported function into a VLX namespace.


vl-doc-ref

Retrieves the value of a variable from the current document's namespace.


vl-doc-set

Sets the value of a variable in the current document's namespace.


vl-every

(vl-every predicate-function list [list]...)

Checks whether the predicate is true for every element combination.

This function passes the first element of each supplied list as an argument to the test function, followed by the next element from each list, and so on. Evaluation stops as soon as one of the lists runs out. If predicate-function returns a non-nil value for every element combination, vl-every function returns T, otherwise nil

The function accepts two arguments at least and some other optional arguments:

Argument | Meaning
predicate-function | The test function. This can be any function that accepts as many arguments as there are lists provided with vl-every, and returns T on any user-specified condition. The predicate-function value can take one of the following forms: A symbol (function name) '(LAMBDA (A B) ...) (FUNCTION (LAMBDA (A B) ...))
list | A list to be tested

Examples

Code | Result
(vl-every '(lambda (fnm) (> (vl-file-size fnm) 0)) (vl-directory-files "C:\\WINDOWS\\Help" nil 1)) | T
(setq alist (list 1 2 3 4)) (setq temp nil) (vl-every '= temp alist) | T


vl-exit-with-error

Passes control from a VLX error handler to the *error* function of the calling namespace.


vl-exit-with-value

Returns a value to the function that invoked the VLX from another namespace.


vl-file-copy

(vl-file-copy source-file destination-file [append])

Copies or adds the contents of source file to destination file.

This function copies or adds the contents of source file to destination file. Source-file is a string naming of the file to be copied. Destination-file is a string naming of the destination file.

If it is successful, the function returns an integer; otherwise the functions return a nil.

Examples

The following examples assume that test3.txt does not exist and test1.txt, test2.txt does.

Code | Result
(vl-file-copy "d:/test1.txt" "d:/test3.txt") | 3
(vl-file-copy "d:/test1.txt" "d:/test2.txt") | nil
(vl-file-copy "d:/test1.txt" "d:/test2.txt" T ) | 3


vl-file-delete

(vl-file-delete filename)

Deletes a file.

This function deletes a specified file .

  • If the file was deleted, this function returns a T.

  • If the file was not deleted, this function returns a nil.

Examples

The following examples assume that abc.txt does not exist and test1.txt does.

Code | Result
(vl-file-delete "d:/test1.txt") | T
(vl-file-delete "d:/abc.txt") | nil


vl-file-directory-p

(vl-file-directory-p filename)

Checks whether a file name is the directory name.

This function checks whether filename is the directory name. If filename is the directory name, the function returns a T. If filename is not the directory name, the function returns a nil.

Examples

Code | Result
(vl-file-directory-p "C:") | T
(vl-file-directory-p "D:/test1.txt") | nil


vl-file-rename

(vl-file-rename old-filename new-filename)

Renames a file.

This function renames an old name(old-filename) to a new name (new-filename) in a file.

If it is successful, the function returns a T; otherwise the function returns a nil.

Examples

The following examples assume that test.txt does exist.

Code | Result
(vl-file-rename "D:/test.txt" "D:/abc.txt") | T


vl-file-size

(vl-file-size filename)

Calculates the size of a file .

This function calculates the size of a file in bytes. If this function returns nil that the file is not readable. If this function returns 0 that the file is a directory or an empty file.

If this function returns an integer showing the size of filename, this function successful.

Examples

The following examples assume that test.txt does exist.

Code | Result
(vl-file-size "d:/test.txt") | 234
(vl-file-size "e:") | 0


vl-file-systime

(vl-file-systime filename)

Returns a list that contains last modification time of the specified file.

This function returns last modification time of the specified file.

If it is successful, the function returns a list. A list contains the elements: year, month, day of week, day of month, hours, minutes, seconds.

If the file failed, this function returns a nil.

Examples

The following examples assume that test.txt does exist.

Code | Result
(vl-file-systime "d:/test.txt") | (2012 8 3 5 16 17 24)

Note

The file was last modified in 2012, in the 8th month of the year (August), the 3rd day of the week (Wednesday), on the 5th day of the month, at 16:17:24.


vl-filename-base

(vl-filename-base filename)

Deletes the directory path and extension of the specified file name.

This function returns the name of a file that removes the directory path and extension.

Examples

Code | Result
(vl-filename-base "C:\Program Files\ZWCAD 2023 Eng\zwcad.exe") | "zwcad"


vl-filename-directory

(vl-filename-directory filename)

Returns the directory path of the specified file name.

This function returns the directory path of the specified file name that removes the name of a file and extension.

Examples

Code | Result
(vl-filename-directory "C:/Program files/ZWCAD 2023 Eng/zwcad.exe") | "C:\\PROGRAM FILES\\ZWCAD 2023 ENG"
(vl-filename-directory "zwcad.exe") | ""


vl-filename-extension

(vl-filename-extension filename)

Returns the extension of the specified file name.

This function returns extension of the specified file name that removes the name of the specified file name and the directory path.

Examples

Code | Result
(vl-filename-extension "C:/Program files/ZWCAD 2023 Eng/zwcad.exe") | ".EXE"
(vl-filename-extension "zwcad.exe") | ".EXE"


vl-filename-mktemp

(vl-filename-mktemp [pattern directory extension])

Returns a string containing a temporary file name.

This functions returns a string that contains a unique temporary file name and a file name pattern.

Examples

Code | Result
(vl-filename-mktemp ) | "C:\\DOCUME~1\\ADMINI~1\\LOCALS~1\\TEMP\\$VL~~001"
(vl-filename-mktemp "c:\\win\\data.del") | "C:\\WIN\\DATA002.DEL"


vl-get-resource

Returns the text stored in a .txt file packaged in a VLX.


vl-list*

(vl-list* object[object]...)

Makes a new list.

This function creates a list from the objects specified.

The possible return values:

objects | Result
a single atom | An atom
all atoms | A dotted pair
the last argument is an atom | A dotted list
none of the previous statements is true | A list

Note

If the last argument is an atom and both of the previous conditions are not true, the third condition returns a dotted list.

Examples

Code | Result
(vl-list* 3 4 0) | (3 4 . 0)
(vl-list* '(1 3 5) 4) | ((1 3 5) . 4)
(vl-list* 3) | 3

Tell me about...

(list expression ...)


vl-list->string

(vl-list->string char-codes-list)

Returns a string.

This function converts the character ASCII code(an integer) to string and combines these strings .

The character ASCII code(an integer) must be less than 256.

Examples

Code | Result
(vl-list->string '(97 23)) | "a\027"
(vl-list->string '(2 23 98)) | "\002\027b"

Tell me about...

(vl-string->list string)


vl-list-exported-functions

Lists exported functions.


vl-list-length

(vl-list-length list-or-cons-object)

Determine how many items are in that list.

This function returns number of items in list. If list-or-cons-object is a dotted list, the function returns a nil.

Examples

Code | Result
(vl-list-length '(45 9 a b)) | 4
(vl-list-length '()) | 0

Tell me about...

(listp item)


vl-list-loaded-vlx

Returns a list of all separate-namespace VLX files associated with the current document.


vl-load-all

(vl-load-all filename)

Load that file.

The filename argument represents the name of the loaded file. You need enter the file type. The function does not assume a file type. The filename can include the directory path. If one is not included, ZWCAD searches the support file search paths specified in the configuration.

Examples

The following examples assume that test1.lsp and test2.lsp do exist .

Code | Result
(vl-load-all "test1.lsp") | C:T3
(vl-load-all "c:/test2.lsp") | C:T3


vl-load-com

(vl-load-com)

Loads Visual LISP extensions AutoLISP functions.

This function loads Visual LISP extensions to AutoLISP functions. This function does not return values. If the extensions are already loaded, this function does nothing.

Tell me about...

(load filename [flag])


vl-mkdir

(vl-mkdir directoryname)

Makes a new directory.

This function makes a new directory.

Each directory name must be a unique name. If the directory exists or if unsuccessful, the function returns a nil. If the directory creates successful, the function returns a T.

Examples

Code | Result
(vl-mkdir "c:\\dir") | T
(vl-mkdir "c:\\dir") | nil


vl-member-if

(vl-member-if predicate-function list)

Tests each element in list by the predicate function.

This function tests each element in list by the predicate-function.

If predicate-function returns a T value, this function returns a list. A list contains the element that first passes the test and all elements following this in the original argument. If this function returns a nil, none of the elements passes the test condition.

The test function value can take one of the following forms:

predicate-function value
A symbol (function name)
'(LAMBDA (X Y) ...)
(FUNCTION (LAMBDA (X Y) ...))

Examples

Code | Result
(vl-member-if '(lambda (x) (= (abs x) 100)) '(4 7 100 -100 -3 -4)) | (100 -100 -3 -4)
(vl-member-if '(lambda (x) (= (abs x) 30)) '(4 7 100 -100 -3 -4)) | nil

Tell me about...

(vl-member-if-not predicate-function list)


vl-member-if-not

(vl-member-if-not predicate-function list)

Tests each element in list by the predicate function.

This function tests each element in list by the predicate-function.

If predicate-function returns a nil value, this function returns a list. A list contains the element that first fails the test and all elements following this in the original argument. If this function returns nil, none of the elements passes the test condition.

The predicate-function value can take one of the following forms:

predicate-function value
A symbol (function name)
'(LAMBDA (X Y) ...)
(FUNCTION (LAMBDA (X Y) ...))

Examples

Code | Result
(vl-member-if-not '(lambda (x) (= (abs x) 100)) '(100 -100 -3 -4)) | (-3 -4)
(vl-member-if-not '(lambda (x) (= (abs x) 100)) '(100 -100)) | nil

Tell me about...

(vl-member-if predicate-function list)


vl-position

(vl-position symbol list)

Returns the index position of symbol in specified list.

This function gets the index of the specified list item. If successful, this function returns an integer. If symbol does not exist in the list, this function returns a nil.

Index 0 is the first element of list.

Examples

Code | Result
(vl-position "one" '("one" "two" "three")) | 0
(vl-position "four" '("one" "two" "three")) | nil


vl-prin1-to-string

(vl-prin1-to-string data)

Displays the string representation of the parameters.

This function displays the data by the printed representation.

Examples

Code | Result
(vl-prin1-to-string "Hello") | "\"Hello\""
(vl-prin1-to-string "Welcome") | "\"Welcome\""

Tell me about...

(prin1 [expression [file-descriptor]])


vl-princ-to-string

(vl-princ-to-string data)

Displays the string representation of the parameters.

This function displays the data by the printed representation.

Examples

Code | Result
(vl-princ-to-string "Hello") | "Hello"
(vl-princ-to-string "Welcome") | "Welcome"

Tell me about...

(princ [expression [file-descriptor]])


vl-propagate

Copies the value of a variable into all open document namespaces (and sets its value in any subsequent drawings opened during the current ZWCAD session).


vl-registry-delete

(vl-registry-delete reg-key [val-name])

Deletes Windows registry key.

This function deletes Windows registry key. If the val-name is existed and is not a nil, this function deletes the specified value in the registry. If the val-name is not existed or is a nil, this function deletes the specified Windows registry key.

If this function returns a T, it is successful; otherwise this function returns a nil.

Examples

Code | Result
(vl-registry-write "HKEY_CURRENT_USER\\Software\\Test") (vl-registry-delete "HKEY_CURRENT_USER\\Software\\Test") | T

Tell me about...

(vl-registry-read reg-key [val-name])

(vl-registry-descendents reg-key [val-names])

(vl-registry-write reg-key [val-name val-data])


vl-registry-descendents

(vl-registry-descendents reg-key [val-names])

Displays a list.

This function displays a list. A list contains the specified value names or all subkeys of reg-key. If this function returns the specified value names, the val-names is existed and is not a nil. If this function returns all subkeys of reg-key, the val-names is not exist.

Examples

Code | Result
(vl-registry-descendents "HKEY_CURRENT_USER\\Software\\Chinaweal Longteng\\ZWCAD 2023 Chs\\Profiles") | ("zwjx")
(vl-registry-descendents "HKEY_CURRENT_USER\\Software\\Chinaweal Longteng\\ZWCAD 2023 Chs\\Profiles" "PreviousProfile") | ("")

Tell me about...

(vl-registry-delete reg-key [val-name])

(vl-registry-read reg-key [val-name])

(vl-registry-write reg-key [val-name val-data])


vl-registry-read

(vl-registry-read reg-key [val-name])

Displays the registry data in the Windows registry.

This function displays the registry data in the Windows registry. If successful, its value is returned as a registry data; if failed, nil is returned.

If this value of the val-data is not existed, this function return the specified key and all of its values.

Examples

Code | Result
(vl-registry-write "HKEY_CURRENT_USER\\NewKey" "" "data1") (vl-registry-read "HKEY_CURRENT_USER\\NewKey") | "data1"

Tell me about...

(vl-registry-delete reg-key [val-name])

(vl-registry-descendents reg-key [val-names])

(vl-registry-write reg-key [val-name val-data])


vl-registry-write

(vl-registry-write reg-key [val-name val-data])

Makes a new Windows registry key.

This function makes a new Windows registry key and sets a registry entry and registry data. If successful, its value is returned as a registry data; if failed, nil is returned.

The function will be supply a default value for the registry entry when val-name is not supplied or is nil. If val-name is exist and val-data is not exist, this function will be set a nil in val-data.

Examples

Code | Result
(vl-registry-write "HKEY_CURRENT_USER\\NewKey" "" "data1") | "data1"
(vl-registry-write "HKEY_CURRENT_USER\\NewKey" "tmp" "data2") | "data2"

Tell me about...

(vl-registry-delete reg-key [val-name])

(vl-registry-descendents reg-key [val-names])

(vl-registry-read reg-key [val-name])


vl-remove

(vl-remove element-to-remove list)

Get everything in the list except the removed elements.

If successful, this function returns a list. A list contains all elements except the removed elements.

Examples

Code | Result
(vl-remove 1 (list 1 2 3)) | (2 3)


vl-remove-if

(vl-remove-if predicate-function list)

Returns a list, that each element doesn't pass the function specified in test function .

This function returns all elements of the specified list that fail the test function.

The test function value can take one of the following forms:

predicate-function value
A symbol (function name)
'(LAMBDA (X Y) ...)
(FUNCTION (LAMBDA (X Y) ...))

Examples

Code | Result
(vl-remove-if 'zerop (list 0 8 9)) | (8 9)


vl-remove-if-not

(vl-remove-if-not predicate-function list)

Returns a list, that each element pass the function specified in test function .

This function returns all elements of the specified list that pass the test function.

The test function value can take one of the following forms:

predicate-function value
A symbol (function name)
'(LAMBDA (X Y) ...)
(FUNCTION (LAMBDA (X Y) ...))

Examples

Code | Result
(vl-remove-if-not 'zerop (list 0 8 9)) | (0)


vl-some

(vl-some predicate-functionlist [list]...)

Checks whether exist a elements in the specified list passing the test function .

This function checks whether exists a element in the specified list passing the test function. If it exist a element passing the test, this function returns a T. Otherwise the test function test the next element in the list. If all elements has failed, this function return a nil.

The test function value can take one of the following forms:

predicate-function value
A symbol (function name)
'(LAMBDA (X Y) ...)
(FUNCTION (LAMBDA (X Y) ...))

Examples

Code | Result
(vl-some 'zerop (list 4 0 8 9)) | T
(vl-some 'zerop (list 4 7 8 9)) | nil


vl-sort

(vl-sort list comparison-function)

Sorts elements according to compare function.

This function return a list. A list contains elements sort order of the specified list.

The compare function value can take one of the following forms:

predicate-function value
A symbol (function name)
'(LAMBDA (X Y) ...)
(FUNCTION (LAMBDA (X Y) ...))

Examples

Code | Result
(vl-sort '(2 8 9 4) '>) | (9 8 4 2)


vl-sort-i

(vl-sort-i list comparison-function)

Returns the index values of the elements of list, sorted in the order specified by give comparison function.

This function sorts the elements in a list according to a given comparison function. This function returns the element index numbers.

The compare function value can take one of the following forms:

predicate-function value
A symbol (function name)
'(LAMBDA (X Y) ...)
(FUNCTION (LAMBDA (X Y) ...))

Examples

Code | Result
(vl-sort-i '(2 8 9 4) '>) | (2 1 3 0)


vl-string->list

(vl-string->list string)

Converts each character of the string into its numerical ASCII code.

This function returns a list. A list contains each character of the string corresponding numerical ASCII code.

Examples

Code | Result
(vl-string->list "ab") | (97.0000 98.0000)
(vl-string->list "?%") | (63.0000 37.0000)

Tell me about...

(vl-list->string char-codes-list)


vl-string-elt

(vl-string-elt string position)

Converts the character at a specified position in a string to its numerical ASCII code.

This function returns the character corresponding the ASCII code. If fail, this function returns an error message. Zero is the first character position index in a string.

Examples

Code | Result
(vl-string-elt "Hello" 3) | 108
(vl-string-elt "Hello" 8) | error: invalid argument(VL-STRING-ELT "Hello" 8)


vl-string-left-trim

(vl-string-left-trim character-set string)

Searches a string form the left of a string and deletes the specified characters.

This function returns a string that deletes the specified characters from the beginning of a string.

Examples

Code | Result
(vl-string-left-trim "abc" "abc def") | " def"
(vl-string-left-trim "abcd" "abcde def") | "e def"


vl-string-mismatch

(vl-string-mismatch str1 str2 [pos1 pos2 ignore-case-p])

Displays the longest length of the common prefix for two strings.

This function returns the longest length of the common prefix for two strings and uses pos1, pos2 specified str1, str2 the starting positions. If str1 or str2 is zero, its omitted. If ignore-case-p is T, case is ignored.

Examples

Code | Result
(vl-string-mismatch "abcd" "abef") | 2
(vl-string-mismatch "abcd" "sabcef" 0 1) | 3
(vl-string-mismatch "abcd" "sABCef" 0 1 T) | 3


vl-string-position

(vl-string-position char-codestr [start-pos [from-end-p]])

Searches for the string and returns the character position corresponding the specified ASCII code.

In the string, this function returns the character position corresponding the specified ASCII code. If start-pos is not zero, this function look for begins at the start-pos position of the string; otherwise, it is omitted. If from-end-p is a T, this function look for begins at the end of the string; otherwise, this function look for begins at the begin of the string.

Examples

Code | Result
(vl-string-position (ascii "e") "abcde") | 4
(vl-string-position (ascii "e") "eabcde" 2) | 5
(vl-string-position (ascii "e") "eabcde" nil T) | 5


vl-string-right-trim

(vl-string-right-trim character-set string)

Searches a string form right of a string and deletes the specified characters.

This function returns a string that deletes the specified characters from the ending of a string.

Examples

Code | Result
(vl-string-right-trim "abc" "abc sads abc") | "abc sads "
(vl-string-right-trim "abc" "abc sa abc bc") | "abc sa abc "


vl-string-search

(vl-string-search pattern string [start-pos])

Searches the specified string and returns the position, in the string.

If the specified string was found in the string, this function returns an integer representing the position in the string. If the specified string was not found in the string, this function returns a zero. If the start-pos is not zero, this function searches the string begin at the start-pos position.

Examples

Code | Result
(vl-string-search "abc" "xyz-abc") | 4
(vl-string-search "abc" "abc-xyz-abc" 2) | 8

Tell me about...

(vl-string-position char-codestr [start-pos [from-end-p]])


vl-string-subst

(vl-string-subst new-str pattern string [start-pos])

Replaces a string with the specified string.

This function returns the string that have been replaced by the specified string. This function replaces the pattern with the new-str in the string. If the start-pos is not zero, this function searches the string begin at the start-pos position.

Examples

Code | Result
(vl-string-subst "one" "two" "one two three") | "one one three"
(vl-string-subst "two" "one" "two two three" 2) | "two two three"


vl-string-translate

(vl-string-translate source-set dest-set str)

Substitutes one character for another, within a string.

This function returns the string that has been replaced by the specified characters.

Examples

Code | Result
(vl-string-translate "AB" "ab" "A-B-C") | "a-b-C"
(vl-string-translate "AB" "ab" "A-B-C-AB") | "a-b-C-ab"


vl-string-trim

(vl-string-trim str)

Searches specified characters form right and left of a string and deletes the specified characters.

This function returns a string that deletes the specified characters from the beginning and ending of a string.

Examples

Code | Result
(vl-string-trim "abc" "abc-def-abc") | "-def-"
(vl-string-trim "abc" "abc-def-ABC") | "-def-ABC"


vl-symbol-name

(vl-symbol-name symbol)

Returns the name of the symbol in the form of capital string.

If the datatype of the symbol argument is SYM, this function returns the name of the symbol in the form of capital string, otherwise, returns an error message like "bad argument type".

Examples

Code | Result
(vl-symbol-name t) | "T"
(vl-symbol-name 'S::StartUp) | "S::STARTUP"
(vl-symbol-name 12) | error: "bad argument type"


vl-symbol-value

(vl-symbol-value symbol)

Returns the value of the symbol.

If the datatype of the symbol argument is SYM, this function returns the value of the symbol, otherwise, returns nil.

Examples

Code | Result
(vl-symbol-value T) | T
(vl-symbol-value 'pi) | 3.14159
(vl-symbol-value 'PAUSE) | "\\"


vl-symbolp

(vl-symbolp object)

Checks whether the specified object is a symbol.

If this function returns a T, the object is a symbol. If this function returns a nil, the object is not a symbol.

Examples

Code | Result
(vl-symbolp t) | T
(vl-symbolp 4) | nil


vl-unload-vlx

Unloads a VLX application that is loaded in its own namespace.


vl-vbaload

(vl-vbaload filename)

Loads that VBA file.

This function returns a nil. Note that an error occurs if the VBA file load failed.

Examples

The following examples assume that addline.zvb does exist.

Code | Result
(vl-vbaload "D:\\Program Files\\ZWCAD 2023 Chs\\addline.zvb") | nil

Tell me about...

(vl-vbarun macroname)


vl-vbarun

(vl-vbarun macroname)

Runs a VBA macro from the loaded file.

This function return a macro, if a VBA macro run successfully.

Examples

The following examples assume that addline.zvb does exist. Addline is a loaded VBA macro in the addline.zvb.

Code | Result
(vl-vbarun "Addline") | "Addline"

Tell me about...

(vl-file-rename old-filename new-filename)


vl-vlx-loaded-p

Determines whether a separate-namespace VLX is currently loaded.


vlax-3D-point

(vlax-3D-point list) or (vlax-3D-point x y [z])

Constructs a variant, the actual datatype of which is a array including two or three double value.

Parameters

list

A list of 2 or 3 numbers for a point.

X Y Z

Numbers representing X,Y and Z coordinates of a point.

Notes

The list argument must contain two double value at least, otherwise this function would return an error message and reject to create the variant. If the number of the list elements is more than 3, this function would create a variant only with the first three elements.

Examples

Code | Result
(vlax-3D-point '(25.6 38.6 10.0)) | #<variant 8197 ...>
(vlax-3D-point '(25.6 38.6)) | #<variant 8197 ...>
(vlax-3D-point 25.6 38.6 0) | #<variant 8197 ...>

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...)]

(vlax-make-variant [value] [type])

(vlax-safearray-fill var 'element-values)

(vlax-safearray-put-element var index... value)


vlax-add-cmd

(vlax-add-cmd global-name func-sym)

Adds custom function to ZWCAD commands set.

Generally, the custom function (function name has no "c:" prefix) can't be executed in ZWCAD command bar, but this function can define these functions as ZWCAD common command with the name of the global-name argument. If successfully, this function returns the value of global-name argument, otherwise, returns nil.

Before invoking vlax-add-cmd to add welcomeinfo function to ZWCAD command set, we can't execute welcomeinfo function in ZWCAD command bar. Now we can execute Hello command in ZWCAD command bar to invoke welcomeinfo function.

Examples

Code Result
(defun welcomeinfo ()
  (princ "\nWelcome to use ZWCAD LISP language programming")
  (princ)
)
(vlax-add-cmd "Hello" 'welcomeinfo)
 (Input Hello in the command line. The result is)
Welcome to use ZWCAD LISP language programming

NOTE

The command added by vlax-add-cmd function can't be called transparently in command function, doing so ZWCAD will reports "error: rejected function".

Tell me about...

(vlax-remove-cmd global-name)


vlax-create-object

(vlax-create-object prog-id)

Creates a new instance of a specified application object.

Use this function when you want to start a new instance of an application, and an object of the type specified by <Component> (see the argument description) to be created. If an application object has registered itself as a single-instance object, only one instance of the object is created, no matter how many times you call this function. If prog-id is a registered ActiveX object, this function returns the application object (VLA-object), otherwise nil.

The function accepts one argument:

Argument | Meaning
prog-id | A string containing the programmatic identifier of the desired ActiveX object, its format is as following: <Vendor>.<Component>.<Version> eg: excel.application.12

Examples

Code | Result
(vlax-create-object "ZwCAD.Drawing") | #<VLA-OBJECT IIcadDocument 1a3f2c>

Tell me about...

(vlax-get-object prog-id)

(vlax-get-or-create-object prog-id)


vlax-curve-getArea

(vlax-curve-getArea curve-obj)

Returns the area of a curve.

If area makes sense to the curve-obj, this function returns a real number representing the area of the curve, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Assume curve-obj argument represents the polyline as following:

Code | Result
(vlax-curve-getArea curve-obj) | 138.979.

NOTE

The measured curve must be closed, otherwise vlax-curve-getArea function will returns 0.


vlax-curve-getClosestPointTo

(vlax-curve-getClosestPointTo curve-obj givenPnt [extend])

Returns the point (in WCS) on a curve or its extensions that is nearest to the specified point.

If the curve-obj argument represent a curve, this function returns the point on the curve or its extensions which is nearest to the specified point. Otherwise, returns nil.

The function accepts two essential arguments and one optional argument:

Argument | Meaning
curve-obj | A VLA-object.
givenPnt | A list representing a point in WCS, which used to measure the closest point to this point.
extend | Search the target point on the curve or its extensions.

Examples

Assume curve-obj argument represents the arc as following:

Code | Result
(vlax-curve-getClosestPointTo curve-obj '(9.3 -5.1 0)) | (10.0000 0.000000 0.000000) Return the closest point on the arc to the coordinates 9.3,-5.1.
(vlax-curve-getClosestPointTo curve-obj '(9.3 -5.1 0) T) | (8.76812 -4.80833 0.000000) Return the closest point on the arc's extensions to the coordinates 9.3,-5.1.


vlax-curve-getClosestPointToProjection

Returns the closest point (in WCS) on a curve after projecting the curve onto a plane.


vlax-curve-getDistAtParam

(vlax-curve-getDistAtParam curve-obj param)

Returns the length of the part of the curve from the curve's start point to the specified parameter.

If the value of param argument is between the startparam (get with vlax-curve-getStartParam function) and endparam (get with vlax-curve-getEndParam function), this function returns a real number representing the length up to the specified parameter, otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
param | A real number, and its available value is between startparam and endparam of the measured curve.

Examples

Assume curve-obj argument represents the spline as following:

Its startparam is 0.000000, and endparam is 24.2244.

Code Result
(vlax-curve-getDistAtParam
  curve-obj
  (vlax-curve-getEndParam curve-obj)
)
 24.7499
Returns the total length of the spline.
(vlax-curve-getDistAtParam curve-obj 40.2) nil
The value of param argument is more than the endparam of the curve, this expression returns nil.


vlax-curve-getDistAtPoint

(vlax-curve-getDistAtPoint curve-obj point)

Returns the length of the part of the curve from the curve's start point to the specified point.

If the point specified by point argument is on the curve, this function returns a real number representing the length up to the specified point, otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
point | A 3D point list (in WCS)

Examples

Assume curve-obj argument represents the spline as following:

Its startparam is 0.000000, and endparam is 24.2244.

Code Result
(vlax-curve-getDistAtPoint
  curve-obj
  (osnap (getpoint "\npick middle point: ") "_mid")
)
 12.3523
Returns the half length of the spline.
(vlax-curve-getDistAtPoint
  curve-obj
  (osnap (getpoint "\npick middle point: ") "_non")
)
 nil
The point argument isn't a point on the curve because of closing osnap.


vlax-curve-getEndParam

(vlax-curve-getEndParam curve-obj)

Returns the parameter of the endpoint of the curve.

If endpoint makes sense to the curve-obj, this function returns a real number representing an end parameter, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Code | Result
(command "line" "0,0" "20,30" "") (setq vla_object (vlax-ename->vla-object (entlast))) (vlax-curve-getEndParam vla_object) | 36.0555 (the length of the line)

Tell me about...

(vlax-curve-getStartParam curve-obj)


vlax-curve-getEndPoint

(vlax-curve-getEndPoint curve-obj)

Returns the endpoint of the curve.

If endpoint makes sense to the curve-obj, this function returns a 3D point list representing an endpoint, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Code | Result
(command "line" "0,0" "20,30" "") (setq vla_object (vlax-ename->vla-object (entlast))) (command "ucs" "O" "100,100") (vlax-curve-getEndPoint vla_object) | (20.0000 30.0000 0.000000) (in WCS)

Note

This function returns the endpoint's coordinates in WCS even if the current coordinate system is UCS.

Tell me about...

(vlax-curve-getStartPoint curve-obj)


vlax-curve-getFirstDeriv

(vlax-curve-getFirstDeriv curve-obj param)

Returns the first derivative (in WCS) of a curve at the specified param.

If the value of param argument is between the startparam (got with vlax-curve-getStartParam function) and endparam (got with vlax-curve-getEndParam function), this function returns a 3D point list representing the first derivative of the curve at the param, otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
param | A real number, and its available value is between startparam and endparam of the measured curve.

Examples

Assume curve-obj argument represents the spline as following:

Its start parameter is 0.000000, end parameter is 24.2244.

Code Result
(vlax-curve-getFirstDeriv
  curve-obj
  (/ (-	(vlax-curve-getEndParam curve-obj)
    (vlax-curve-getStartParam curve-obj)
     )
     2.0
  )
)
 (0.904500 -0.578730 0.000000)
Returns the first derivative of the spline at its middle point.
(vlax-curve-getFirstDeriv curve-obj 40.2) nil
The value of param argument is more than the endparam of the curve, this expression returns nil.


vlax-curve-getParamAtDist

(vlax-curve-getParamAtDist curve-obj dist)

Returns the parameter of a curve at the specified distance from the beginning of the curve.

This function returns a real number representing an parameter, if successful; otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
dist | A number specifying the distance from the beginning of the curve.

Examples

Code | Result
(command "spline" "0,0" "6,7" "12,2" "22,8" "" "" "") (setq vla_object (vlax-ename->vla-object (entlast))) (vlax-curve-getParamAtDist vla_object 10.0) | 9.59229


vlax-curve-getParamAtPoint

(vlax-curve-getParamAtPoint curve-obj point)

Returns the parameter of the curve at the specified point.

If the specified point is on the curve or on the extended line of the curve, this function returns a real number representing an parameter, otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
point | A 3D point list on curve or on the extended line of curve.

Examples

Code | Result
(command "line" "0,0" "20,30" "") (setq vla_object (vlax-ename->vla-object (entlast))) (command "osnap" "mid") (setq pt (getpoint "\npick a point on the line:")) (vlax-curve-getParamAtPoint vla_object pt) | 18.0278 (the half length of the line)

Note

If the specified point is on the extended line of the curve, this function can also return a real number representing an parameter.


vlax-curve-getPointAtDist

(vlax-curve-getPointAtDist curve-obj dist)

Returns the point along a curve at the specified distance.

If the specified distance equal to or less than the length of the curve, this function returns a 3D point list representing a point on the curve, otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
dist | The distance along the curve.

Examples

Code | Result
(command "spline" "0,0" "6,7" "12,2" "22,8" "" "" "") (setq vla_object (vlax-ename->vla-object (entlast))) (command "ucs" "O" "100,100") (vlax-curve-getPointAtDist vla_object 10.0) | (6.26490 6.91769 0.000000)

Note

This function returns the 3D point's coordinates in WCS even if the current coordinate system is UCS.


vlax-curve-getPointAtParam

(vlax-curve-getPointAtParam curve-obj param)

Returns the point at the specified parameter value along the curve.

If the specified parameter is less than or equal to the EndParam(return by the vlax-curve-getEndParam function) of the curve, this function returns a 3D point list representing a point on the curve, otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
param | A number specifying a parameter on the curve.

Examples

Code | Result
(command "spline" "0,0" "6,7" "12,2" "22,8" "" "" "") (setq vla_object (vlax-ename->vla-object (entlast))) (setq length (vlax-curve-getEndParam vla_object)) (command "ucs" "O" "100,100") (vlax-curve-getPointAtParam vla_object (/ length 2.0)) | (9.84327 3.74107 0.000000) (the middle point of the spline)

Note

This function returns the 3D point's coordinates in WCS even if the current coordinate system is UCS.


vlax-curve-getSecondDeriv

(vlax-curve-getSecondDeriv curve-obj param)

Returns the second derivative (in WCS) of a curve at the specified param.

If the value of param argument is between the startparam (got with vlax-curve-getStartParam function) and endparam (got with vlax-curve-getEndParam function), this function returns a 3D point list representing the second derivative of the curve at the param, otherwise nil.

The function accepts two arguments:

Argument | Meaning
curve-obj | A VLA-object.
param | A real number, and its available value is between startparam and endparam of the measured curve.

Examples

Assume curve-obj argument represents the spline as following:

Its start parameter is 0.000000, end parameter is 24.2244.

Code Result
(vlax-curve-getSecondDeriv
  curve-obj
  (/ (-	(vlax-curve-getEndParam curve-obj)
    (vlax-curve-getStartParam curve-obj)
     )
     2.0
  )
)
 (0.000756251 0.0116285 0.000000)
Returns the second derivative of the spline at its middle point.
(vlax-curve-getSecondDeriv curve-obj 40.2) nil
The value of param argument is more than the endparam of the curve, this expression returns nil.


vlax-curve-getStartParam

(vlax-curve-getStartParam curve-obj)

Returns the parameter of the startpoint of the curve.

If startpoint makes sense to the curve-obj, this function returns a real number representing a start parameter, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Code | Result
(command "spline" "0,0" "6,7" "12,2" "22,8" "" "" "") (setq vla_object (vlax-ename->vla-object (entlast))) (vlax-curve-getStartParam vla_object) | 0.000000

Tell me about...

(vlax-curve-getEndParam curve-obj)


vlax-curve-getStartPoint

(vlax-curve-getStartPoint curve-obj)

Returns the startpoint of the curve.

If startpoint makes sense to the curve-obj, this function returns a 3D point list representing a startpoint, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Code | Result
(command "ellipse" "C" "0,0" "15,0" 6) (command "move" "l" "" "0,0" "@10.5,16.8") (setq vla_object (vlax-ename->vla-object (entlast))) (command "ucs" "O" "100,100") (vlax-curve-getStartPoint vla_object) | (25.5000 16.8000 0.000000) (in WCS)

Note

This function returns the startpoint's coordinates in WCS even if the current coordinate system is UCS.

Tell me about...

(vlax-curve-getEndPoint curve-obj)


vlax-curve-isClosed

(vlax-curve-isClosed curve-obj)

Determines whether the specified curve is closed.

If the curve-obj is closed (that is, its startpoint and endpoint are the same), this function returns T, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Code | Result
(command "pline" "0,0" "20,30" "60,15" "70,-20" "C") (setq vla_object (vlax-ename->vla-object (entlast))) (vlax-curve-isClosed vla_object) | T


vlax-curve-isPeriodic

(vlax-curve-isPeriodic curve-obj)

Determines whether the specified curve can be extended infinitely in both directions and has a period value dT.

If the curve is periodic and can be extended infinitely, this function returns T, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Code Result
(command "circle" "0,0" 20.0)
(setq curve-obj (vlax-ename->vla-object (entlast)))
(vlax-curve-isPeriodic curve-obj)
T

curve-obj argument represents circle, which is a periodic curve.

(command "line" "0,0" "20.0,30.0" "")
(setq curve-obj (vlax-ename->vla-object (entlast)))
(vlax-curve-isPeriodic curve-obj)
nil

curve-obj argument represents line, which isn't a periodic curve.


vlax-curve-isPlanar

(vlax-curve-isPlanar curve-obj)

Determines whether there is a planar contains all vertexes of the curve.

If there is at least one planar contains all vertexes of the curve, this function returns T, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Examples

Code Result
(command "3dpoly" "-6.8,4.3,0.0" "-5.2,-3.0,3.0"
     "5.2,-3.0,0.0" "0.0,6.0,0.0" "")
(setq curve-obj (vlax-ename->vla-object (entlast)))
(vlax-curve-isPlanar curve-obj)
nil

The vertexes of the 3D polyline constitutes a tetrahedron, so there isn't any planar contains these vertexes.

(command "circle" "-6.8,4.3,0.0" 6.0)
(setq curve-obj (vlax-ename->vla-object (entlast)))
(vlax-curve-isPlanar curve-obj)
T

curve-obj argument represents a circle, all point on the curve is in a same planar.


vlax-dump-object

(vlax-dump-object vla-object [T])

List a VLA-object's properties or properties and methods.

If T parameter isn't specified, this function will list all properties of the vla-object, return the name of this object, and list all methods of the vla-object additionally and returns T.

The function accepts one argument and one optional argument:

Argument | Meaning
vla-object | A VlA-object.
T | If specified, this function also lists all methods of the VLA-object.

Examples

Code | Result
(vlax-dump-object (vlax-get-zwcad-object)) | Property values: ; ActiveDocument (RO) ; Application (RO) ; Caption (RO) ; DefaultFilePath ; Documents (RO) ; FullName (RO) ; Height ; LocaleID (RO) ; WindowLeft ; Library (RO) ; Name (RO) ; Path (RO) ; PlotManager (RO) ; Preferences (RO) ; StatusBar ; WindowTop ; VBE (RO) ; Version (RO) ; Visible ; Width ; HWND (RO) ; WindowState ; LockHardID (RO) ; StatusID (RO) #<VLA-OBJECT IZWCADApplication 1e537c>
(vlax-dump-object (vlax-get-zwcad-object) T) | Property values: ; ActiveDocument (RO) ; Application (RO) ; Caption (RO) ; DefaultFilePath ; Documents (RO) ; FullName (RO) ; Height ; LocaleID (RO) ; WindowLeft ; Library (RO) ; Name (RO) ; Path (RO) ; PlotManager (RO) ; Preferences (RO) ; StatusBar ; WindowTop ; VBE (RO) ; Version (RO) ; Visible ; Width ; HWND (RO) ; WindowState ; LockHardID (RO) ; StatusID (RO) Methods supported: ; LoadZVB (1) ; UnloadZVB (1) ; RunMacro (1) ; ZoomAll () ; ZoomCenter (2) ; ZoomExtents () ; ZoomPrevious () ; ZoomPickWindow () ; ZoomScaled (2) ; ZoomWindow (2) ; Update () ; DefineFunction (2) ; UndefineFunction (1) ; Help (3) ; Quit () ; ListSDS () ; LoadSDS (1) ; UnloadSDS (1) ; LoadLISP (1) ; RunCommand (1) ; RunScript (1) ; GetInterfaceObject (1) ; IsFunctionLoaded (1) ; SetAppForMPrint (1) ; MPrint (1) T


vlax-ename->vla-object

(vlax-ename->vla-object entname)

Transforms an entity to a VLA-object.

If entname supplied is a valid autolisp object's name, this function returns a VLA-object's name, otherwise displays an error message.

The function accepts one argument:

Argument | Meaning
entname | An autolisp object's name (returned by entget, entsel or entlast functions).

Examples

Code | Result
(command "pline" "0,0" "20,30" "60,15" "70,-20" "C") (setq ename (entlast)) (setq vla_object (vlax-ename->vla-object ename)) | #<VLA-OBJECT IZWCADLightWeightPolyline 59e7e58>

Tell me about...

(vlax-vla-object->ename obj)


vlax-erased-p

(vlax-erased-p vla-obj)

Determines if an VLA-object was erased.

If vla-obj supplied was erased, this function returns T, otherwise nil.

The function accepts one argument:

Argument | Meaning
vla-obj | A VLA-object.

Examples

Code | Result
(command "pline" "0,0" "20,30" "60,15" "70,-20" "C") (setq vla_object (vlax-ename->vla-object (entlast))) (vlax-erased-p vla_object)) | nil
(command "pline" "0,0" "20,30" "60,15" "70,-20" "C") (setq vla_object (vlax-ename->vla-object (entlast))) (entdel (entlast)) (vlax-erased-p vla_object)) | T


vlax-for

(vlax-for symbol collection [expression1 [expression2 ...]])

Iterates through a collection of VLA-objects, evaluating each expression.

This function returns the value of the last expression evaluated for the last object in the collection.

The function accepts two arguments at least and some optional arguments:

Argument | Meaning
symbol | A symbol to be assigned to each VLA-object in a collection.
collection | A collection of VLA-objects.
expression1, expression2... | The expressions to be evaluated.

Examples

Code | Result
(vl-load-com) (setq mycad (vlax-get-acad-object)) (setq mydoc (vlax-get-property mycad 'ActiveDocument)) (setq textstyles (vlax-get-property mydoc 'TextStyles)) (vlax-for EachStyle textstyles (terpri) (princ (vlax-get-property EachStyle 'Name))) | Standard ...


vlax-get-object

(vlax-get-object prog-id)

Returns a running instance of an application object.

Use this function when you want to get an instance of an application, and an object of the type is specified by <Component> (see the argument description) to be returned. If there is instance of the specified object currently running, this function returns a VLA-object representing the instance of the specified application, otherwise nil.

The function accepts one argument:

Argument | Meaning
prog-id | A string containing the programmatic identifier of the desired ActiveX object, its format is as following: <Vendor>.<Component>.<Version> eg: excel.application.12

Examples

Code | Result
(vlax-get-object "Excel.application") | #<VLA-OBJECT _Application 201374>


vlax-get-or-create-object

(vlax-get-or-create-object prog-id)

Returns a running instance of an application object, or creates a new instance if the application is not currently running.

Use this function when you want to get or create an instance of an application, and an object of the type specified by <Component> (see the argument description) to be returned. Even though there isn't instance of the specified object currently running, this function returns a VLA-object representing the instance of the specified application.

The function accepts one argument:

Argument | Meaning
prog-id | A string containing the programmatic identifier of the desired ActiveX object, its format is as following: <Vendor>.<Component>.<Version> eg: excel.application.12

Examples

Code | Result
(vlax-get-or-create-object "Excel.application") | #<VLA-OBJECT _Application 201374>
(vlax-get-or-create-object "zwcad.drawing") | #<VLA-OBJECT IIcadDocument 1f3754>


vlax-get-property

(vlax-get-property vla-object propertyName)

Gets a VLA-object's property.

If the property makes sense to the vla-object, this function returns the specified property's value, otherwise displays an error message.

The function accepts two arguments:

Argument | Meaning
vla-object | A VLA-object.
propertyName | The VLA-object's property (vlax-dump-object function can be used to query a VLA-object's properties).

Examples

Code | Result
(setq testobj (car (entsel "\nselect a entity:"))) (setq vlaObj (vlax-ename->vla-object testobj)) (vlax-get-property vlaObj 'Radius) | If you select circle or arc, these codes return the radius' value, otherwise prompt "error: bad argument".

Tell me about...

(vlax-property-available-p obj prop [check-modify])

(vlax-put-property obj property arg)


vlax-get-zwcad-object

ZWCAD 2017 HELP
vlax-get-zwcad-object

(vlax-get-zwcad-object)

Returns the top level ZWCAD application object (all of the ActiveX objects' root) for the current ZWCAD session.

This function always returns a VLA-object, and it needn't any arguments.

Examples

Code | Result
(vlax-get-zwcad-object) | #<VLA-OBJECT IZWCADApplication 5ac3d9c>

© 2012-2016 ZWCAD Software Co.,Ltd. All Rights Reserved.


vlax-import-type-library

(vlax-import-type-library :tlb-filename filename [:methods-prefix mprefix :properties-prefix pprefix :constants-prefix cprefix])

Imports information from a type library.

If the specified type library is valid, this function imports the information from the type library and returns T, otherwise nil.

Parameters

filename

A string naming the type library. And the files can be divided as the following type:

  • type library (.tlb) and object library (.olb) files.

  • the .exe files.

  • the libraries files (.dll) included type libraries resources.

  • the compound files that include type libraries.

  • the files style that can be explained by the LoadTypeLib API.

The function accepts one argument with a symbol at least:

Argument | Meaning
filename | A string naming the type library.
mprefix | Prefix to be used for method wrapper functions.
pprefix | Prefix to be used for property wrapper functions.
cprefix | Prefix to be used for constants contained in the type library.

Examples

Code | Result
(setq sysdrv (getenv "systemdrive")) (setq tlbfile (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office12\\Excel.exe"))) (vlax-import-type-library :tlb-filename tlbfile :methods-prefix "msxl-" :properties-prefix "msxl-" :constants-prefix "msxl-") (if msxl-xl24HourClock (princ "\nLoading Microsoft Excel type library complete.") (princ "\nLoading Microsoft Excel type library error.")) | If you have installed Microsoft Excel 2007 to your system drive with default directory, executing these codes displays "Loading Microsoft Excel type library complete", otherwise displays "Error: bad argument".

Tell me about...

(vlax-typeinfo-available-p obj)


vlax-invoke-method

(vlax-invoke-method obj method arg1 [arg2...])

Invokes the method specified by "method" of the vla-object specified by "obj".

If the method makes sense to the vla-object and the supplied arguments are valid, the function runs successfully and the returned value depends on the vla-object's method, otherwise displays an error message.

The function accepts two arguments at least, and how many arguments must be supplied depends on the method invoked:

Argument | Meaning
obj | A VLA-object.
method | A symbol or string naming the method to be invoked.
arg1, arg2... | Argument to be passed to the method called.

Examples

Code | Result
(vl-load-com) (setq ename_line (car (entsel "\nPlease select a line: "))) (setq vlaname_line (vlax-ename->vla-object ename_line)) (setq centerpt (vlax-get-property vlaname_line'StartPoint)) (vlax-invoke-method vlaname_line 'ArrayPolar 10 360 centerpt) |

Tell me about...

(vlax-get-property vla-object propertyName)

(vlax-method-applicable-p objmethod)

(vlax-property-available-p obj prop [check-modify])

(vlax-put-property obj property arg)


vlax-ldata-delete

(vlax-ldata-delete dict key)

Erases key from a drawing dictionary.

If the specified key exists in the specified dictionary, this function erases the key successfully and returns T, otherwise nil.

The function accepts two arguments:

Argument | Meaning
dict | A VLA-object(ZWCAD drawing entity object), or a string naming a global dictionary.
key | A string specifying the dictionary key.

Examples

Code | Result
(vl-load-com) (vlax-ldata-put "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1" "Chinaweal Longteng") (vlax-ldata-delete "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1") | T

Tell me about...

(vlax-ldata-get dict key [default-data])

(vlax-ldata-list dict)

(vlax-ldata-put dict key data)


vlax-ldata-get

(vlax-ldata-get dict key [default-data])

Gets LISP data from a drawing dictionary or an object.

If the specified key is existed, this function returns its data value, otherwise returns the dafault-data.

The function accepts two arguments at least and one optional argument:

Argument | Meaning
dict | A VLA-object(ZWCAD drawing entity object), or a string naming a global dictionary.
key | A string specifying the dictionary key.
default-data | LISP data to be returned if no matching key exists in the dictionary.

Examples

Code | Result
(vl-load-com) (vlax-ldata-put "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1" "Chinaweal Longteng") (vlax-ldata-get "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1" "Can't get the LISP data from the specified key in the dictionary") | "Chinaweal Longteng"
(vl-load-com) (vlax-ldata-put "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1" "Chinaweal Longteng") (vlax-ldata-delete "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1") (vlax-ldata-get "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1" "Can't get the LISP data from the specified key in the dictionary") | "Can't get the LISP data from the specified key in the dictionary"


vlax-ldata-list

(vlax-ldata-list dict)

Lists LISP data in a specified drawing dictionary.

If the specified dictionary is existed and there're some keys in it, this function returns an associative list consisting of pairs (key . value), otherwise nil.

The function accepts one argument:

Argument | Meaning
dict | A VLA-object, ZWCAD drawing entity object, or a string naming a global dictionary.

Examples

Code | Result
(vl-load-com) (vlax-ldata-put "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1" "Bolts") (vlax-ldata-put "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL2" "Nuts") (vlax-ldata-put "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL3" "Pins") (vlax-ldata-list "ZWCAD_BOM_DICTIONARY") | (("ZWCAD_MXB_MXL1" . "Bolts") ("ZWCAD_MXB_MXL2" . "Nuts") ("ZWCAD_MXB_MXL3" . "Pins"))

Tell me about...

(vlax-ldata-get dict key [default-data])

(vlax-ldata-delete dict key)

(vlax-ldata-put dict key data)


vlax-ldata-put

(vlax-ldata-put dict key data)

Stores LISP data to a drawing dictionary or a drawing entity dictionary.

If the specified key is existed in the specified dictionary, this function corrects the data of the specified key and returns the data value, otherwise creates the key in the specified dictionary to store the LISP data and returns the data value too.

The function accepts three arguments:

Argument | Meaning
dict | A VLA-object(ZWCAD drawing entity object), or a string naming a global dictionary.
key | A string specifying the dictionary key.
data | LISP data to be stored in the key.

Examples

Code | Result
(vl-load-com) (vlax-ldata-put "ZWCAD_BOM_DICTIONARY" "ZWCAD_MXB_MXL1" "Chinaweal Longteng") | "Chinaweal Longteng"

Tell me about...

(vlax-ldata-get dict key [default-data])

(vlax-ldata-list dict)

(vlax-ldata-delete dict key)


vlax-ldata-test

(vlax-ldata-test data)

Determines whether data can be saved over a session boundary.

If the specified data can be saved as LISP data over a session boundary, this function returns T, otherwise returns nil.

The function accepts one argument:

Argument | Meaning
data | Any LISP data to be tested.

Examples

Code | Result
(vl-load-com) (vlax-ldata-test "ZWCAD_BOM_MXL1") | T
(defun drawcircle() (command "circle" pause 20.0) (princ) ) (vl-load-com) (vlax-ldata-test drawcircle) | nil

Tell me about...

(vlax-ldata-get dict key [default-data])

(vlax-ldata-delete dict key)

(vlax-ldata-list dict)

(vlax-ldata-put dict key data)


vlax-make-safearray

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

Creates a safearray.

This function returns a safearray filled with initial values which depend on the type of the safearray.
Type | Initial value
numbers | 0.000000
strings | Zero-length string.
booleans | :vlax-false.
variant | vlax-vbEmpty(Uninitialized).

The function accepts two arguments at least and some optional argument:

Argument | Meaning
type | The type of safearray. It can be one of the following constants: vlax-vbInteger (2) Integer vlax-vbLong (3) Long integer vlax-vbSingle (4) Single-precision floating-point number vlax-vbDouble (5) Double-precision floating-point number vlax-vbString (8) String vlax-vbBoolean (11) Boolean vlax-vbVariant (12) Variant This parameter can be a string constant or an integer constant(in parentheses), but the integer constant aren't suggested using for the lisp codes' compatibility.
(l-bound . u-bound) | Lower and upper index boundaries of a dimension.

Examples

Code | Result
(setq 3dpoint (vlax-make-safearray vlax-vbSingle '(0 . 2))) (vlax-safearray->list 3dpoint) | (0.000000 0.000000 0.000000)

Tell me about...

(vlax-make-variant [value] [type])

(vlax-safearray-fill var 'element-values)

(vlax-safearray-get-dim var)

(vlax-safearray-get-element var element...)

(vlax-safearray-get-l-bound var dim)

(vlax-safearray-get-u-bound var dim)

(vlax-safearray-put-element var index... value)

(vlax-safearray-type var)

(vlax-safearray->list var)

(vlax-variant-value var)


vlax-make-variant

(vlax-make-variant [value] [type])

Creates a variant type data.

This function returns a variant type data:

  • If only the "value" parameter is specified, the data is initialized with the specified value, and its factual type depends on the specified value:

    Value | Type
    nil | vlax-vbEmpty.
    :vlax-null | vlax-vbNull .
    integer | vlax-vbLong.
    real | vlax-vbDouble.
    string | vlax-vbString.
    VLA-object | vlax-vbObject.
    :vlax-true, :vlax-false | vlax-vbBoolean.
    safearray | vlax-vbArray.
  • If the "value" parameter equals nil and the "type" parameter is specified, the data is initialized with the default value which depends on the "type" parameter:
    Type | Initial value
    numbers | 0.000000
    strings | 0.
    booleans | 0.
    Variants | vlax-vbEmpty(Uninitialized).

  • If both parameters are specified, the system automatically transforms the "value" parameter to the "type" datatype, then initializes the data with the "value" parameter after transforming, and the data's factual type depends on the "type" parameter.

    The function accepts two optional arguments:

    Argument | Meaning
    value | The value to be assigned to the variant.
    type The type of variant. It can be one of the following constants:
  • vlax-vbEmpty (0) Uninitialized (default value)
  • vlax-vbNull (1) Contains no valid data
  • vlax-vbInteger (2) Integer
  • vlax-vbLong (3) Long integer
  • vlax-vbSingle (4) Single-precision floating-point number
  • vlax-vbDouble (5) Double-precision floating-point number
  • vlax-vbString (8) String
  • vlax-vbBoolean (11) Boolean
  • vlax-vbArray (8196) Array
    This parameter can be a string constant or an integer constant(in parentheses), but the integer constant aren't suggested using for the lisp codes' compatibility.

Examples

Code | Result
(vlax-make-variant 12.3 vlax-vbSingle) |

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-variant-change-type var type)

(vlax-variant-type var)

(vlax-variant-value var)


vlax-map-collection

(vlax-map-collection obj function)

Applies a function to all objects in a VLA collection object.

If obj argument doesn't represent a VLA collection object, or each object in the VLA collection object doesn't match the function, vlax-map-collection function would report "error: *error*", otherwise applies the function to all objects in the VLA collection object and returns the value of obj argument.

The function accepts two arguments:

Argument | Meaning
obj | A VLA collection object.
function | A function name or lambda expression.

Examples

Code Result
(vl-load-com)

(defun c:test (/ curdoc	PaperSpace Nums_circle Nums_line Nums_arc
           Nums_ellipse)
  (setq	Nums_circle
     0
    Nums_line 0
    Nums_arc 0
    Nums_ellipse
     0
  )
  (setq
    curdoc (vlax-get-property (vlax-get-zwcad-object) 'ActiveDocument)
  )
  (setq PaperSpace (vlax-get-property curdoc 'ModelSpace))
  (vlax-map-collection PaperSpace 'statistics)
  (alert (strcat (itoa Nums_circle)
         " circles"
         "\n"
         (itoa Nums_line)
         " lines"
         "\n"
         (itoa Nums_arc)
         " arcs"
         "\n"
         (itoa Nums_ellipse)
         " ellipses"
     )
  )
  (princ)
)

(defun statistics (ent / objType)
  (setq objType (cdr (assoc 0 (entget (vlax-vla-object->ename ent)))))
  (cond
    ((= objType "CIRCLE")
     (setq Nums_circle (1+ Nums_circle))
    )
    ((= objType "LINE")
     (setq Nums_line (1+ Nums_line))
    )
    ((= objType "ARC")
     (setq Nums_arc (1+ Nums_arc))
    )
    ((= objType "ELLIPSE")
     (setq Nums_ellipse (1+ Nums_ellipse))
    )
  )
)

The custom command "Test" is invoked to statistics the number of circle, line, arc and ellipse in current drawing's ModelSpace.


vlax-method-applicable-p

(vlax-method-applicable-p obj method)

Determines whether an VLA object supports a specified method.

If the VLA object supports the specified method, this function returns T, otherwise nil.

The function accepts two arguments:

Argument | Meaning
obj | A VLA object.
method | A string or symbol representing the method name to be tested.

Examples

The line-obj argument in the following codes represents a line object.

Code | Result
(vlax-method-applicable-p line-obj 'Move) | T Determines if line object supports move method.
(vlax-method-applicable-p line-obj 'Addline) | nil Determines if line object supports addline method.

Tell me about...

(vlax-property-available-p obj prop [check-modify])


vlax-product-key

(vlax-product-key)

Returns the ZWCAD WINDOWS registry path.

This function returns a string containing the ZWCAD registry path which can be used to register an application for demand loading.

The function doesn't accept any argument.

Examples

Code | Result
(vlax-product-key) | "Software\\ZWSoft\\ZWCAD 2023 Eng"


vlax-property-available-p

(vlax-property-available-p obj prop [check-modify])

Determines whether a VLA object has a specified property.

When nil or nothing is specified for check-modify argument, if the VLA object has the specified property, this function returns T, otherwise nil; When T or other not nil value is specified for check-modify argument, this function returns nil if either the VLA object hasn't the specified property or the value of the porperty can't be modified.

The function accepts two essential arguments and one optional argument:

Argument | Meaning
obj | A VLA object.
prop | A string or symbol representing the name of the property to be tested.
check-modify | Determines checking that the value of the property can be modified or not.

Examples

The line-obj argument in the following codes represents a line object.

Code | Result
(vlax-property-available-p line-obj 'Color) | T Determines if line object has color property.
(vlax-property-available-p line-obj 'Handle T) | nil Determines if line object has handle property and the value of handle property can be modified.
(vlax-property-available-p line-obj 'Area) | nil Determines if line object has area property.

Tell me about...

(vlax-method-applicable-p objmethod)

(vlax-put-property obj property arg)


vlax-put-property

(vlax-put-property obj property arg)

Sets the specified property of an ActiveX object.

If the specified property is set successfully, this function returns nil.

The function accepts three arguments:

Argument | Meaning
obj | A VLA-object.
property | A string or symbol representing a property of the VLA-object.
arg | The value to be set.

Examples

Code | Result
(vl-load-com) (setq vlaCircle (vlax-ename->vla-object (car (entsel "\nselect a circle: ")))) (vlax-put-property vlaCircle 'Color 2) (vlax-invoke-method vlaCircle 'update) | The seleted circle's color is changed to yellow.

Note

Updating the VLA-object immediately after modifying the VLA-object's property is suggested, because sometimes the drawing can't be updated automatically when some VLA-object's property is modified in ZWCAD.

Tell me about...

(vlax-get-property vla-object propertyName)


vlax-read-enabled-p

(vlax-read-enabled-p obj)

Determines whether a object can be read.

Parameter

obj 1

A VLA object.

Examples

Code | Result
(command "line" "10.0,10.0" "150.0,100.0" "") (setq vname (vlax-ename->vla-object(entlast ))) (vlax-read-enabled-p vname) | T

If the object is readable, returns T; otherwise nil.


vlax-release-object

(vlax-release-object obj)

Releases a argument with VLA object data type.

If obj argument represents a VLA object, this function releases the object and returns 0, otherwise ZWCAD reports "error: bad argument type". When the obj argument is released, it can' t be used to access the VLA object again (its value is #<VLA-OBJECT 00000000>), but the VLA object still exists. Before invoking vlax-release-object function to release VLA object, you'd better invoke vlax-object-released-p function to check if this object has been released already.

The function accepts one argument:

Argument | Meaning
obj | A VLA object.

NOTE

vlax-release-object function only releases the argument representing a VLA object, and the VLA object still exists.


vlax-remove-cmd

(vlax-remove-cmd global-name)

Removes the command from ZWCAD's command set which has been added by vlax-add-cmd function.

If global-name argument represents a command which has been added to ZWCAD's command set by vlax-add-cmd function, this function remove the command and returns T, otherwise nil.

The function accepts two optional arguments:

Argument | Meaning
global-name | A string representing the command to be removed.

Examples

Assume "Hello" is a command which has been added to ZWCAD commands set in vlax-add-cmd topic.

Code | Result
(vlax-remove-cmd "hello") | T
(vlax-remove-cmd "ZWCAD") | nil "ZWCAD" isn't a command name added by vlax-add-cmd function.

Tell me about...

(vlax-add-cmd global-name func-sym)


vlax-safearray-fill

(vlax-safearray-fill var 'element-values)

Assigns data to the elements of a safearray.

If the length of the list specified by "element-values" argument is fewer or more than the number of the var's elements, this function prompts "too few arguments" or "too many arguments", otherwise returns the safearray specified by "var" argument.

The function accepts two arguments:

Argument | Meaning
var | A safearray.
element-values | A list of values to be stored in the array.

Examples

Code | Result
(setq var (vlax-make-safearray vlax-vbsingle '(0 . 2))) (vlax-safearray-fill var (list 1.2 2.3 3.4)) | #<safearray...>

Note

If the var is a multi-dimension array, element-values must be a list of lists, with each list corresponding to a dimension of the array.

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-safearray-get-dim var)

(vlax-safearray-get-element var element...)

(vlax-safearray-get-l-bound var dim)

(vlax-safearray-get-u-bound var dim)

(vlax-safearray-put-element var index... value)

(vlax-safearray-type var)

(vlax-safearray->list var)

(vlax-variant-value var)


vlax-safearray-get-dim

(vlax-safearray-get-dim var)

Returns the number of dimensions in a safearray object.

If var doesn't represent a safearray, this function returns an error message, otherwise a integer representing the number of dimensions in var.

The function accepts one argument:

Argument | Meaning
var | A safearray.

Examples

Code | Result
(setq var (vlax-make-safearray vlax-vbsingle '(0 . 2) '(0 . 2))) (vlax-safearray-get-dim var) | 2

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-safearray-get-l-bound var dim)

(vlax-safearray-get-u-bound var dim)


vlax-safearray-get-element

(vlax-safearray-get-element var element...)

Returns an element from an array.

If the specified indexes of the element make sense to the safearray, this function returns the specified element's value, otherwise prompts an error message.

The function accepts two arguments at least:

Argument | Meaning
var | A safearray.
element | A integer representing the indexes of the element in the array, the number of element argument depends on the number of the dimension in the array.

Examples

Code | Result
(setq matrix (vlax-make-safearray vlax-vbString '(0 . 2) '(0 . 2))) (vlax-safearray-fill matrix '(("00" "01" "02") ("10" "11" "12") ("20" "21" "22"))) (vlax-safearray-get-element matrix 1 2) | "12"

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-safearray-get-dim var)

(vlax-safearray-get-l-bound var dim)

(vlax-safearray-get-u-bound var dim)

(vlax-safearray-put-element var index... value)


vlax-safearray-get-l-bound

(vlax-safearray-get-l-bound var dim)

Returns the lower boundary of the specified dimension of an array.

If the specified var is not an array, or the specified dim is invalid, this function prompts an error message, otherwise returns an integer representing the lower boundary (starting index) of the dimension.

The function accepts two arguments:

Argument | Meaning
var | A safearray.
dim | A integer representing the tested dimension of the array. The first dimension is dimension 1.

Examples

Code | Result
(setq matrix (vlax-make-safearray vlax-vbString '(0 . 2) '(0 . 3))) (vlax-safearray-get-l-bound matrix 1) | 0

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-safearray-get-dim var)

(vlax-safearray-get-u-bound var dim)


vlax-safearray-get-u-bound

(vlax-safearray-get-u-bound var dim)

Returns the upper boundary of the specified dimension of an array.

If the specified var is not an array, or the specified dim is invalid, this function prompts an error message, otherwise returns an integer representing the upper boundary (end index) of the dimension.

The function accepts two arguments:

Argument | Meaning
var | A safearray.
dim | A integer representing the tested dimension of the array. The first dimension is dimension 1.

Examples

Code | Result
(setq matrix (vlax-make-safearray vlax-vbString '(0 . 2) '(0 . 3))) (vlax-safearray-get-u-bound matrix 1) | 3

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-safearray-get-dim var)

(vlax-safearray-get-l-bound var dim)


vlax-safearray-put-element

(vlax-safearray-put-element var index... value)

Sets an element's value of an array.

If the specified var is an array, and the specified indexes of the element make sense to the array, this function assigns the specified value to the specified element and returns its value, otherwise prompts an error message.

The function accepts three arguments at least:

Argument | Meaning
var | A safearray.
index | A integer representing the indexes of the element in the array, the number of element argument depends on the number of the dimension in the array.
value | The value to assign the safearray element.

Examples

Code | Result
(setq matrix (vlax-make-safearray vlax-vbString '(0 . 2) '(0 . 2))) (vlax-safearray-fill matrix '(("00" "01" "02") ("10" "11" "12") ("20" "21" "22"))) (vlax-safearray-put-element matrix 1 2 "ZwCAD") (vlax-safearray->list matrix) | (("00" "01" "02") ("10" "11" "ZwCAD") ("20" "21" "22"))

Tell me about...

(vlax-safearray-get-element var element...)

(vlax-safearray-fill var 'element-values)

(vlax-safearray-type var)


vlax-safearray-type

(vlax-safearray-type var)

Returns the data type of a safearray.

If the specified var argument represents a safearray, this funtion returns an integer whose meaning can be inquired in the following table:

Integer constant | String constant
2 | Integer (vlax-vbInteger)
3 | Long integer (vlax-vbLong)
4 | Single-precision floating-point number (vlax-vbSingle)
5 | Double-precision floating-point number (vlax-vbDouble)
8 | String (vlax-vbString)
11 | Boolean (vlax-vbBoolean)
12 | Variant (vlax-vbVariant)

The function accepts two arguments at least and some optional argument:

Argument | Meaning
var | A safearray.

Examples

Code | Result
(setq 3dpoint (vlax-make-safearray vlax-vbSingle '(0 . 2))) (vlax-safearray-type 3dpoint) | 4

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])


vlax-safearray->list

(vlax-safearray->list var)

Returns the elements of a safearray in list form.

If var doesn't represent a safearray, this function returns an error message, otherwise a list contains all elements of the array.

The function accepts one argument:

Argument | Meaning
var | A safearray.

Examples

Code | Result
(setq var (vlax-make-safearray vlax-vbsingle '(0 . 2) '(0 . 2))) (vlax-safearray-fill matrix '(("00" "01" "02") ("10" "11" "12") ("20" "21" "22"))) (vlax-safearray->list matrix) | (("00" "01" "02") ("10" "11" "12") ("20" "21" "22"))

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-safearray-fill var 'element-values)

(vlax-safearray-put-element var index... value)


vlax-tmatrix

(vlax-tmatrix list)

Returns a 4 x 4 transformation matrix which can be used by tranformby VLA-method.

If the specified list's format is undesirable, this function prompts "Error: bad argument", otherwise returns a variant of type safearray, representing a 4 x 4 transformation matrix.

The function accepts one argument:

Argument | Meaning
list | A list containing four elements, and each element is a list containing four numbers.

Examples

Code | Result
(vl-load-com) (setq var_tmatrix (vlax-tmatrix '((10 0 0 0) (0 10 0 0) (0 0 10 0) (0 0 0 1)))) (setq arr_tmatrix (vlax-variant-value var_tmatrix)) (vlax-safearray->list arr_tmatrix) | ((10.0000 0.000000 0.000000 0.000000) (0.000000 10.0000 0.000000 0.000000) (0.000000 0.000000 10.0000 0.000000) (0.000000 0.000000 0.000000 1.00000))


vlax-typeinfo-available-p

(vlax-typeinfo-available-p obj)

Determines whether the specified VLA object has TypeLib information.

If the VLA object has TypeLib information, this function returns T, otherwise nil.

The function accepts one argument:

Argument | Meaning
curve-obj | A VLA-object.

Tell me about...

(vlax-import-type-library :tlb-filename filename [:methods-prefix mprefix :properties-prefix pprefix :constants-prefix cprefix])


vlax-variant-change-type

(vlax-variant-change-type var type)

Returns the value of a variant after changing its data type.

If the var can be converted to the specified data type successfully, this function returns the value of var after being converted to the specified data type, otherwise nil.

The function accepts two arguments:

Argument | Meaning
var | A variable whose value is a variant.
type | The type of variant. It can be one of the following constants: vlax-vbEmpty (0) Uninitialized (default value) vlax-vbNull (1) Contains no valid data vlax-vbInteger (2) Integer vlax-vbLong (3) Long integer vlax-vbSingle (4) Single-precision floating-point number vlax-vbDouble (5) Double-precision floating-point number vlax-vbString (8) String vlax-vbBoolean (11) Boolean vlax-vbArray (8196) Array This parameter can be a string constant or an integer constant(in parentheses), but the integer constant aren't suggested using for the lisp codes' compatibility.

Examples

Code | Result
(setq var_float (vlax-make-variant 12.3 vlax-vbSingle)) (setq var_string (vlax-variant-change-type var_float vlax-vbString)) (vlax-variant-value var_string) | "12.3"

Tell me about...

(vlax-variant-type var)

(vlax-variant-value var)


vlax-variant-type

(vlax-variant-type var)

Returns the data type of a variant.

If the specified var argument doesn't represent a variant, this function prompts "error: bad argument type", otherwise returns an integer whose meaning can be inquired in the following table:

Integer constant | String constant
0 | Uninitialized (vlax-vbEmpty)
1 | Contains no valid data (vlax-vbNull)
2 | Integer (vlax-vbInteger)
3 | Long integer (vlax-vbLong)
4 | Single-precision floating-point number (vlax-vbSingle)
5 | Double-precision floating-point number (vlax-vbDouble)
8 | String (vlax-vbString)
11 | Boolean (vlax-vbBoolean)
8192 + n | Safearray (vlax-vbArray) of some data type

The function accepts one argument:

Argument | Meaning
var | A variable.

Examples

Code | Result
(setq IntArray (vlax-make-safearray vlax-vbInteger '(0 . 2))) (setq IntArray (vlax-safearray-fill IntArray '(10 10 0))) (setq VarArray (vlax-make-variant IntArray)) (vlax-variant-type VarArray) | 8194 (equals 8192 + 2(vlax-vbInteger))

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-make-variant [value] [type])

(vlax-variant-change-type var type)

(vlax-variant-value var)


vlax-variant-value

(vlax-variant-value var)

Returns the value of a variant.

If the specified var argument doesn't represent a variant, this function prompts "error: bad argument type", otherwise returns the value of var.

The function accepts one argument:

Argument | Meaning
var | A variable.

Examples

Code | Result
(setq varInt (vlax-make-variant 12 vlax-vbInteger)) (vlax-variant-value varInt) | 12

Tell me about...

(vlax-make-safearray type '(l-bound . u-bound) ['(l-bound . u-bound)...])

(vlax-make-variant [value] [type])


vlax-vla-object->ename

(vlax-vla-object->ename obj)

Transforms a VLA-objectan to an entity .

If obj supplied is a valid ActiveX object, this function returns an autolisp's entity name, otherwise prompts "error: bad argument type".

The function accepts one argument:

Argument | Meaning
obj | A VLA-object.

Examples

Code | Result
(setq curDoc (vlax-get-property (vlax-get-zwcad-object) 'ActiveDocument)) (setq mSpace (vlax-get-property curDoc 'ModelSpace)) (setq FirstVName (vlax-invoke-method mSpace 'Item 0)) (vlax-vla-object->ename FirstVName) | #<Entity name: 5a01090>

Tell me about...

(vlax-ename->vla-object entname)


vlax-write-enabled-p

(vlax-write-enabled-p obj)

Determines whether a object can be written.

Parameter

obj 1

A VLA object.

Examples

Code | Result
(command "line" "10.0,10.0" "150.0,100.0" "") (setq vname (vlax-ename->vla-object(entlast ))) (vlax-wrtite-enabled-p vname) | T

If the object's attributes can be changed, returns T; otherwise nil.


vlr-acdb-reactor

(vlr-acdb-reactor data callbacks)

Constructs a database reactor object that notifies when an object is added to, modified in, or erased from a drawing database.

This function returns a database reactor object.

The function accepts two arguments:

Argument | Meaning
data | Any AutoLisp data, if there is no data, it can be nil.
callbacks | A list of pairs of the following form: (event-name . callback_function) event-name is one of the symbols listed below: :vlr-objectAppended An object has been appended to the drawing database. :vlr-objectOpenedForModify An object is about to be changed. :vlr-objectModified An object has been changed. :vlr-objectErased An object has been flagged as being erased. :vlr-objectUnErased An object's erased-flag has been removed. callback_function is a symbol representing a function to be called when the event fires. Each callback function accepts two arguments: reactor_object The reactor object that called the callback function. obj A list containing a single element, the string identifying the AutoLISP entity.

Examples

Code | Result
(vl-load-com) (vlr-acdb-reactor nil '((:vlr-objectAppended . objectAppended))) ;;;define the callback function (defun objectAppended(reactor_object obj) (alert (vl-princ-to-string obj)) ) | When you draw any entity, ZWCAD will open a dialog as following automatically:


vlr-add

(vlr-add reactor)

Adds a disabled reactor object.

If the reactor argument represents a reactor object, this function returns a reactor object even if the reactor object has been enabled, or it will prompt "error: bad argument type".

The function accepts one argument:

Argument | Meaning
reactor | A reactor object.

Examples

Code | Result
(vl-load-com) (setq appobjvlr (vlr-acdb-reactor nil '((:vlr-objectAppended . objectAppended)))) ;;;define the callback function (defun objectAppended(reactor_object obj) (alert "One entity has been appended to the drawing database!") ) ;;;Forbid a reactor (defun c:Forbidvlr() (vlr-remove appobjvlr) ) ;;;enable a reactor (defun c:Enablevlr() (vlr-add appobjvlr) ) | If you haven't executed Forbidvlr command, ZWCAD will open a dialog as following automatically when you draw any entity: But after executing Forbidevlr command, ZWCAD will open the dialog never again when you draw any entity until Enablevlr command has been executed.

Tell me about...

(vlr-added-p reactor)

(vlr-remove reactor)


vlr-added-p

(vlr-added-p reactor)

Determines whether a reactor object is enabled.

This function returns T if the specified reactor is enabled; otherwise nil if the reactor is disabled.

The function accepts one argument:

Argument | Meaning
reactor | A reactor object.

Examples

Code | Result
(vl-load-com) (setq appobjvlr (vlr-acdb-reactor nil '((:vlr-objectAppended . objectAppended)))) ;;;define the callback function (defun objectAppended(reactor_object obj) (alert "One entity has been appended to the drawing database!") ) (vlr-added-p appobjvlr) | T.

Tell me about...

(vlr-add reactor)


vlr-beep-reaction

(vlr-beep-reaction [args])

Produces a beep sound.

This is a predefined callback function that accepts a variable number of arguments, depending on the reactor type.

Examples

Code | Result
(vl-load-com) (vlr-acdb-reactor nil '((:vlr-objectAppended . vlr-beep-reaction))) | Whatever you draw, these codes produce a beep sound.

Note

The function can be assigned to an event handler for debugging.


vlr-command-reactor

(vlr-command-reactor data callbacks)

Constructs an editor reactor that notifies of a command event.

This function returns a command reactor object.

The function accepts two arguments:

Argument | Meaning
data | Any AutoLisp data, if there is no data, it can be nil.
callbacks | A list of pairs of the following form: (event-name . callback_function) event-name is one of the symbols listed below: :vlr-commandWillStart A ZWCAD command has been called. :vlr-commandEnded A ZWCAD command has completed. callback_function is a symbol representing a function to be called when the event fires. Each callback function accepts two arguments: reactor_object The reactor object that called the callback function. list A list containing a single element, the string identifying the command.

Examples

Code | Result
(vl-load-com) (vlr-command-reactor nil '((:vlr-commandWillStart . commandWillStart))) ;;;define the callback function (defun commandWillStart(reactor_object list) (alert (vl-princ-to-string list)) ) | When you draw a line, ZWCAD will open a dialog as following automatically:


vlr-data-set

Overwrites application-specific data associated with a reactor.


vlr-docmanager-reactor

(vlr-docmanager-reactor data callbacks)

Constructs a reactor object that notifies of events relating to drawing documents.

This function returns an editor reactor object.

The function accepts two arguments:

Argument | Meaning
data | Any AutoLisp data, if there is no data, it can be nil.
callbacks A list of pairs of the following form:
(event-name . callback_function)
event-name is one of the symbols listed below:
  • :vlr-documentCreated The user has created a new document or opened an document for drawing.
  • :vlr-documentToBeDestroyed The document is about to be destroyed (for example, be modified and saved).
  • :vlr-documentToBeActivated A currently inactive document has just received the activate signal, implying that it is about to become the current document.
  • :vlr-documentToBeDeactivated Another window (inside or outside of ZWCAD) has been activated.
    callback_function is a symbol representing a function to be called when the event fires. Each callback function accepts two arguments:
  • reactor_object The reactor object that called the callback function.
  • param-list A list whose content depends on the event triggered, showing as following:
    • :vlr-documentCreated A list containing one element which is a VLA-object representing the affected document.
    • :vlr-documentToBeDestroyed dto.
    • :vlr-documentToBeActivated dto.
    • :vlr-documentToBeDeactivated dto.

    • Examples

    Code | Result
(vl-load-com) (vlr-docmanager-reactor nil '((:vlr-documentCreated . documentCreated))) ;;;define the callback function (defun documentCreated(reactor_object param-list) (alert (strcat (vlax-get-property (car param-list) 'Name) " has been created!")) ) | When you create a new document in ZWCAD, ZWCAD will open a dialog as following automatically:


vlr-dwg-reactor

Constructs an editor reactor object that notifies of a drawing event (for example, opening or closing a drawing file).


vlr-dxf-reactor

Constructs an editor reactor object that notifies of an event related to reading or writing a DXF file.


vlr-editor-reactor

Constructs an editor reactor object.


vlr-insert-reactor

Constructs an editor reactor object that notifies of an event related to block insertion.


vlr-linker-reactor

Constructs a reactor object that notifies your application every time an ObjectARX application is loaded or unloaded.


vlr-lisp-reactor

Constructs an editor reactor object that notifies of a LISP event.


vlr-miscellaneous-reactor

Constructs an editor reactor object that does not fall under any other editor reactor types.


vlr-mouse-reactor

(vlr-mouse-reactor data callbacks)

Constructs an editor reactor object that notifies of a mouse event.

This function returns an editor reactor object.

The function accepts two arguments:

Argument | Meaning
data | Any AutoLisp data, if there is no data, it can be nil.
callbacks | A list of pairs of the following form: (event-name . callback_function) event-name is one of the symbols listed below: :vlr-beginDoubleClick The user has double-clicked in the drawing. :vlr-beginRightClick The user has right-clicked in the drawing. callback_function is a symbol representing a function to be called when the event fires. Each callback function accepts two arguments: reactor_object The reactor object that called the callback function. list A list containing 3 reals showing the point clicked on, in WCS.

Examples

Code | Result
(vl-load-com) (vlr-mouse-reactor nil '((:vlr-beginDoubleClick . beginDoubleClick))) ;;;define the callback function (defun beginDoubleClick(reactor_object point) (alert (vl-princ-to-string point)) ) | When you double-click the left key of the mouse in the drawing, ZWCAD will open a dialog as following automatically:


vlr-notification

Determines whether or not a reactor will fire if its associated namespace is not active.


vlr-object-reactor

(vlr-object-reactor owners data callbacks)

Constructs a drawing object reactor object.

This function returns a drawing object reactor object.

The function accepts three arguments:

Argument | Meaning
owners | A list containing VLA-objects representing the drawing objects to be watched.
data | Any AutoLisp data, if there is no data, it can be nil.
callbacks A list of pairs of the following form:
(event-name . callback_function)
event-name is one of the symbols listed below:
  • :vlr-erased The object has been marked as erased.
  • :vlr-unerased This object's erased mark has been cancelled (for instance, to execute undo operate after erase the VLA object).
  • :vlr-openedForModify The object is about to be modified.
  • :vlr-modified The object has been modified.
    callback_function is a symbol representing a function to be called when the event fires. Each callback function accepts three arguments:
  • owner The owner of the VLA-object the event applies to.
  • reactor_object The reactor object that called the callback function.
  • param-list A list whose content depends on the event triggered, showing as following:
    • :vlr-erased nil.
    • :vlr-unerased nil.
    • :vlr-openedForModify nil.
    • :vlr-modified nil.

Examples

Code Result
(vl-load-com)
(defun c:object(/ vname vnamelist)
(setq vname (vlax-ename->vla-object (car (entsel "\nselect an entity to link the reactor: "))))
(setq vnamelist (list vname))
(vlr-object-reactor vnamelist nil '((:vlr-modified . modified)))
)
;;;define the callback function
(defun modified(notifier-object reactor_object param-list)
(alert (strcat
"The lenght of the entity is: "
(vl-princ-to-string (vlax-get-property notifier-object 'Length))))
) 		After you execute object command and select a line to link the reactor in the drawing, if you modify the entity (for example, move it), ZWCAD will open a dialog as following automatically:

(vl-load-com)
(vl-load-reactors)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)

(setq myCircle
(progn
(setq ctrPt (list 430 0 0))
(setq radius 30.0)
(vla-addCircle
(vla-get-ModelSpace
(vla-get-ActiveDocument (vlax-get-zwcad-object))
)
(vlax-3d-point ctrPt)
radius
)
)
)
(command "regen")

(defun print1(notifier-object reactor-object param-list)
(princ (vl-princ-to-string notifier-object))
(alert "The interface :vlr-modified is succeed!")
)

(defun c:test1()
(setq objModifiedReactor
(vlr-object-reactor
(list myCircle)
"mycircle"
'((:vlr-modified . print1))
)
)
)

After you execute object command and select a line to link the reactor in the drawing, if you delete the entity (for example, E or delete), ZWCAD will call the function print1 automatically:


vlr-owner-add

Adds an object to the list of owners of an object reactor.


vlr-owner-remove

Removes an object from the list of owners of an object reactor.


vlr-owners

Returns the list of owners of an object reactor.


vlr-pers

Makes a reactor persistent.


vlr-pers-list

Returns a list of persistent reactors in the current drawing document.


vlr-pers-p

Determines whether a reactor is persistent.


vlr-pers-release

Makes a reactor transient.


vlr-reaction-names

Returns a list of all possible callback conditions for this reactor type.


vlr-reaction-set

Adds or replaces a callback function in a reactor.


vlr-reactions

Returns a list of pairs (event-name . callback_function) for the reactor.


vlr-reactors

(vlr-reactors [reactor-type...])

If the reactor-type is existing, it returns the list of the reactor types you specified. And if you omit the reactor-type, it returns all the reactors existed in current graph space.

parameters

reactor-type

the reactor type.

Examples

Code | Result
(vlr-reactors) | Displays a list of all the list reactor types in current graph.
(vlr-reactors :vlr-object-reactor) | Returns ((:VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor>)) if a object reactor has been attached to current graph space;returns nil if not.


vlr-remove

(vlr-remove reactor)

Forbids using a specified reactor object.

If the reactor argument represents a reactor object, this function returns a reactor object even if the reactor object has been forbidden, otherwise prompts "error: bad argument type".

The function accepts one argument:

Argument | Meaning
reactor | A reactor object.

Examples

Code | Result
(vl-load-com) (setq appobjvlr (vlr-acdb-reactor nil '((:vlr-objectAppended . objectAppended)))) ;;;define the callback function (defun objectAppended(reactor_object obj) (alert "One entity has been appended to the drawing database!") ) ;;;Forbid a reactor (defun c:Forbidvlr() (vlr-remove appobjvlr) ) | If you haven't executed Forbidvlr command, ZWCAD will open a dialog as following automatically when you draw any entity: But after executing Forbidevlr command, ZWCAD will never again open the dialog when you draw any entity.

Tell me about...

(vlr-remove-all [reactor-type])


vlr-remove-all

Disables all reactors of the specified type.


vlr-set-notification

Defines whether a reactor's callback function will execute if its associated namespace is not active.


vlr-sysvar-reactor

Constructs an editor reactor object that notifies of a change to a system variable.


vlr-toolbar-reactor

Constructs an editor reactor object that notifies of a change to the bitmaps in a toolbar.


vlr-type

(vlr-type rctobj)

Returns the VLR ojbect's type.

This function can return a reactor type of the VLR object.

Parameter

rctobj

A VLR object.

Examples

Code | Result
(vlr-type objModifiedReactor) | :VLR-Object-Reactor


vlr-types

(vlr-types)

Display all the reactor types.

Returns

(:VLR-AcDb-Reactor :VLR-Command-Reactor :VLR-DeepClone-Reactor :VLR-DocManager-Reactor :VLR-DWG-Reactor :VLR-DXF-Reactor :VLR-Editor-Reactor :VLR-Insert-Reactor :VLR-Linker-Reactor :VLR-Lisp-Reactor :VLR-Miscellaneous-Reactor :VLR-Mouse-Reactor :VLR-Object-Reactor :VLR-SysVar-Reactor :VLR-Toolbar-Reactor :VLR-Undo-Reactor :VLR-Wblock-Reactor :VLR-Window-Reactor :VLR-XREF-Reactor)


vlr-undo-reactor

Constructs an editor reactor object that notifies of an undo event.


vlr-wblock-reactor

Constructs an editor reactor object that notifies of an event related to writing a block.


vlr-window-reactor

Constructs an editor reactor object that notifies of an event related to moving or sizing an ZWCAD window.


vlr-xref-reactor

Constructs an editor reactor object that notifies of an event related to attaching or modifying XREFs.


vports

(vports)

Get information about this viewport.

This function returns a description of all current viewports. The description returned by the vports function is a list that includes the viewport identification number, followed by viewport coordinates. These coordinates vary, depending on the setting of Tilemode:

  • When TileMode = 1, the list consists of the viewports created with the VPorts command - coordinates of the viewport's corners ranging from (0.0, 0.0) for the lower-left corner, to (1.0, 1.0) for the upper-right corner. Corners are described by paper space coordinates.

  • When TileMode = 0, the list consists of the viewports created with the MView command. The corners are described by paper space coordinates.

Examples

Code | Result
(vports ) | ((2 (0.000000 0.000000) (1.00000 1.00000)))


W Functions

Topics in this section:

  • wcmatch
  • while
  • write-char
  • write-line


wcmatch

(wcmatch string pattern)

Search that string.

This function finds internal string matches. You can see if a certain string is found, or match it with another string.

For example, if you had a string variable called MYVAR which contained the string "SUPERCALIFRAGILISTIC123\##" and you wanted to see if the characters "FRAG" were anywhere in the string you could use the wcmatch function, as follows:

(wcmatch MYVAR "*FRAG*")

If a match is found, wcmatch returns T. If no match is found, nil is returned. The wcmatch function is case-sensitive. To find a match, you should use strcase to change everything to uppercase if necessary.

You can use several wildcards for wcmatch:

Argument | Meaning
~ | (tilde) Pattern not found in string.
* | Standard wildcard; can be used anywhere.
? | Matches for a space held by a character or number; number of question marks (?) must exactly match number of characters or numbers in the string.
# | (pound) Matches any single number.
@@ | Matches any single character; may not be a number.
. | (period) Matches any single non-alphanumeric character. (space) Matches one or more spaces.
[ ] | Matches for any of the characters enclosed in the brackets.
[~ ] | True only if there are extra characters not included in the brackets.
[ - ] | (hyphen) Searches within a predefined range pattern.
, | (comma) The "or" option.
' | (reverse quote) Read next character literally; use for special characters.

Examples

Code | Result
(wcmatch "b" "[a-c]") | T
(wcmatch "b" "?") | T
(wcmatch "abc" "~w") | T


while

(while text statement ...)

Keep doing it while it's still true.

This function is a common loop in LISP. The statement controls whether the loop continues or breaks. When statement is true, the loop continues. When statement is nil, the loop breaks. The last statement before the nil is displayed.

Examples

Code | Result
(setq x 25) (while (/= x 20) (setq x (1- x) ) | 20


write-char

(write-char character [file-descriptor])

Write that character to a file.

This function write a character to a file. The file is specified by the file-descriptor, assigned by the open function. This function writes characters that are in ASCII code.

You convert a letter to its ASCII code with the (equal statement1 statement2 [tolerance])(IDR_166)(ascii string)(IDR_128) function. When the file-descriptor is left out, the character is written to the command line and Prompt History window.

Note

The write-line, function, whose format argument is a string, is often more practical and efficient to use than the write-char function.

Examples

Code | Result
(write-char 97) | a97
(write-char 109) | m109


write-line

(write-line string [file-descriptor])

Write that string to a file.

This function is more practical and efficient to use than the write-char function. Anything can be written into a file, since the format is a string. The file is specified by the file-descriptor, assigned by the open function. When the file-descriptor is left out, the string is written to the command line and Prompt History window.

Examples

Code | Result
(setq fil (open "sample.lsp" "w")) (write-line "Name:" fil) (close f) | "Name:"


X Functions

Topics in this section:

  • xdroom
  • xdsize


xdroom

(xdroom entity-name)

Determine how much xdata space is still available for an entity.

This function reports the amount of xdata (short for extended entity data) space still free in the entity identified by entity-name. All entities in ZWCAD have 16KB (actually, 16,383 bytes) each to store any kind of user-defined data. This function tells you how many bytes are still remaining.

Examples

Code | Result
(command "line" '(15 14) '(19 17) "") (setq ent (entlast)) (xdroom ent) | 16383


xdsize

(xdsize list)

Determine how much space a list takes up as xdata.

This function returns the size (in bytes) that a list occupies as extended entity data. The list argument is a list of extended data that contain an application name registered with the regapp function. When the application name is unregistered, ZWCAD displays the error message, "Invalid application name in 1001 group nil."

Examples

Code | Result
(setq list_xdata (regapp "xdata_side")) (xdsize '(-3 ("xdata_side" (1000 . "DATA") (1002 . "{") (1040 . 0.0) (1040 . 1.0) (1002 . "}"))) ) | 31


Z Functions

Topics in this section:

  • zerop


zerop

(zerop number)

Determine whether this number is zero.

If number is a real number or an integer and it is a zero value, the zerop function returns a T. Otherwise, it returns a nil.

Examples

Code | Result
(zerop 0) | T
(zerop 3) | nil


(~)(1s compliment)

(~ number)

Apply the 1s compliment.

This function returns the bitwise NOT of a number. The number must be an integer.

Examples

Code | Result
(~ 20) | -21
(~ -3) | 2
(~ 0) | -1


acad_colordlg

(acad_colordlg color-number [flag])

Display the Select Color dialog box.

This function displays the Color dialog box. This function returns the color number that the user selects from the dialog box or nil when the user clicks the Cancel button.

The function accepts two optional arguments:

Argument | Meaning | Example | Range
color-number | Color Number | 1 | 0 - 256
flag | Flag | nil | nil or true (which is the same as not using the flag)

NOTES

    • The color-number argument lets you provide a default color. When clrno is 0, the default is BYBLOCK; when clrno is 256, the default is BYLAYER.
    • When nil, the dialog box disables the BYBLOCK and BYLAYER buttons.

Examples

Code | Result
(acad_colordlg 1) | Displays dialog box with color 1 (red) selected as the default.
(acad_colordlg 1 nil) | Displays dialog box with color 1 (red) selected as the default, and the BYBLOCK and BYLAYER buttons are disabled.

NOTE The first eight color numbers have the following meanings:

Number | Color
1 | Red
2 | Yellow
3 | Green
4 | Cyan (light blue)
5 | Blue
6 | Magenta (pink)
7 | Black
8 | Gray

Tell me about...

(command cmd [arguments] ...)

(getvar sysvar)

(help [filename [topic [flag]]])

(setvar sysvar value)


dos_orderlist

(dos_orderlist title prompt list [strings])

Displays a layer list in a sizeable window dialog box , and you can reorder the items in the list by dragging or by clicking up/down/top/bottom button.

Parameters

title
A string of the title for the dialog box.

prompt
A string of the dialog prompt.

list

A list of string that contains the strings to be displayed in the list of the dialog box.

strings

If not specified or T, a list of ordered strings is returned, if nil, alist of intergers that identify the ordered strings is returned.

Returns

A list of the selected strings if successful.
nil on error or cancel.

Example

Code | Result
(dos_subdir) | (setq list1 (list "Layer1" "Layer2" "Layer3" "Layer4" "Layer5" "Layer6")) (dos_orderlist "Layers" "Drag to reorder layers" list1)


vlax-get-acad-object

(vlax-get-acad-object)

Returns the top level ZWCAD application object (all of the ActiveX objects' root) for the current ZWCAD session.

This function always returns a VLA-object, and it needn't any arguments.

Examples

Code | Result
(vlax-get-acad-object) | #<VLA-OBJECT IZWCADApplication 5ac3d9c>


vlax-object-released-p

(vlax-object-released-p obj)

Determines whether the specified argument with VLA object data type has been released.

Attentions

Erasing a VLA-object (using command ERASE or vla-erase) does not release the object. A VLA-object is not released until you invoke vlax-release-object on the object, or normal AutoLISP garbage collection occurs, or the drawing database is destroyed at the end of the drawing session.

If obj argument represents a VLA object and it has been released, this function returns T, otherwise nil. If this argument doesn't represent VLA object, ZWCAD will reports "error: bad argument type".

The function accepts one argument:

Argument | Meaning
obj | A VLA object.

Examples

Code Result
(setq obj (vlax-ename->vla-object
        (car (entsel "\nselect a line: "))
      )
)
(vlax-object-released-p obj)
nil

The obj argument represents a line object, and the argument isn't released.

(setq obj (vlax-ename->vla-object
        (car (entsel "\nselect a line: "))
      )
)
(vlax-release-object obj)
(vlax-object-released-p obj)
T

The obj argument represents a line object, and the argument has been released by vlax-release-object function.


vlr-current-reaction-name

(vlr-current-reaction-name)

Returns the name (symbol) of the event linked to the current reactor object.

This function returns a symbol representing the event that triggered the current reactor object.

The function doesn't accept any argument.

Examples

Code | Result
(vl-load-com) (setq appobjvlr (vlr-acdb-reactor nil '((:vlr-objectAppended . objectAppended)))) ;;;define the callback function (defun objectAppended(reactor_object obj) (alert (vl-princ-to-string (vlax-current-reaction-name))) ) | When you draw any entity, ZWCAD will open a dialog as following automatically: