Skip to content

AutoLISP (5 of 5)

vlax-get-property

(vlax-get-property object property)

Reads a property named by a symbol or a string. Returns the same as vla-get-…: points come in a variant.

Example

(vlax-get-property obj 'Layer)

See also

vlax-put-property · vlax-get

vlax-put-property

(vlax-put-property object property value)

Changes a property named by a symbol or a string. Points go in a variant: see vlax-3d-point.

Example

(vlax-put-property obj "Color" 1)

See also

vlax-get-property · vlax-put

vlax-get

(vlax-get object property)

Like vlax-get-property, but with AutoLISP values: points and coordinates are lists, and logical values are -1 and 0.

Example

(vlax-get obj 'StartPoint)   ; (1.0 2.0 0.0)

See also

vlax-put · vlax-get-property

vlax-put

(vlax-put object property value)

Like vlax-put-property, but accepts lists for points and coordinates.

Example

(vlax-put obj 'Center '(10.0 5.0 0.0))

See also

vlax-get · vlax-put-property

vlax-property-available-p

(vlax-property-available-p object property [writable])

Returns T if the object has the property; with writable other than nil, only if it can also be changed.

Example

(vlax-property-available-p obj 'Radius)

See also

vlax-get-property

vlax-read-enabled-p

(vlax-read-enabled-p object)

Returns T if the object can be read, that is, if it has not been erased.

Example

(vlax-read-enabled-p obj)

See also

vlax-write-enabled-p · vlax-erased-p

vlax-write-enabled-p

(vlax-write-enabled-p object)

Returns T if the object can be changed, that is, if it has not been erased.

Example

(vlax-write-enabled-p obj)

See also

vlax-read-enabled-p · vlax-erased-p

vlax-erased-p

(vlax-erased-p object)

Returns T if the entity of the object has been erased.

Example

(vla-Delete obj)
(vlax-erased-p obj)   ; T

See also

vlax-read-enabled-p

vlax-dump-object

(vlax-dump-object object [methods])

Writes the properties of the object and their values on the command line and returns T. The list of methods is not written even if requested.

Example

(vlax-dump-object obj)

See also

vlax-property-available-p

vlax-3d-point

(vlax-3d-point x y [z]) (vlax-3d-point list)

Returns a point in a variant, which is what the vla-… methods and properties ask for. Without z, it is 0.

Example

(vla-AddLine ms (vlax-3d-point 0 0 0) (vlax-3d-point '(10 5 0)))

See also

vlax-make-variant · vlax-put

vlax-make-variant

(vlax-make-variant [value [type]])

Returns a variant holding the value; without type, the one that matches the value (vlax-vbLong, vlax-vbDouble, vlax-vbString…).

Example

(vlax-make-variant 1.5 vlax-vbDouble)

See also

vlax-variant-value · vlax-variant-type

vlax-variant-value

(vlax-variant-value variant)

Returns the value held by the variant.

Example

(vlax-variant-value (vlax-make-variant 5))   ; 5

See also

vlax-variant-type · vlax-safearray->list

vlax-variant-type

(vlax-variant-type variant)

Returns the type of the variant: 5 is a real, 8 a string and 8197 an array of reals, like points.

Example

(vlax-variant-type (vlax-3d-point 0 0 0))   ; 8197

See also

vlax-variant-value

vlax-make-safearray

(vlax-make-safearray type '(lower . upper))

Creates a one-dimensional safe array with those indexes. Fill it with vlax-safearray-fill.

Example

(setq m (vlax-make-safearray vlax-vbDouble '(0 . 3)))
(vlax-safearray-fill m '(0 0 10 5))
(vla-AddLightWeightPolyline ms m)

See also

vlax-safearray-fill · vlax-safearray->list

vlax-safearray-fill

(vlax-safearray-fill array list)

Copies the elements of the list into the array, which must have the same number of them, and returns the array.

Example

(vlax-safearray-fill m '(0 0 10 5))

See also

vlax-make-safearray · vlax-safearray->list

vlax-safearray->list

(vlax-safearray->list array)

Returns the elements of the array in a list.

Example

(vlax-safearray->list (vlax-variant-value (vla-get-Coordinates pol)))

See also

vlax-make-safearray · vlax-variant-value

vlax-for

(vlax-for variable collection expression...)

Evaluates the expressions once for each element of the collection or block, with the variable set to that element, and returns the value of the last one. Afterwards the variable gets its value back.

Example

(vlax-for capa (vla-get-Layers doc)
  (princ (vla-get-Name capa)))

See also

vlax-get-acad-object · foreach

vlax-curve-getStartParam

(vlax-curve-getStartParam curve)

Parameter at the start of the curve. curve is an entity name: LINE, ARC, CIRCLE, ELLIPSE, LWPOLYLINE, POLYLINE (2D or 3D), SPLINE, RAY or XLINE. It works without calling vl-load-com first.

Parameters of each type

They are AutoCAD's, which is what routines expect:

Errors

Anything that is not an entity name gives ; error: unable to get ObjectID: …; an entity that is not a curve (a text, for example) gives ; error: bad argument value: AcDbCurve ….

Example

(vlax-curve-getStartParam (car (entsel)))   ; 0.0 on a polyline; 0.523599 on an arc starting at 30°

See also

vlax-curve-getEndParam · vlax-curve-getStartPoint · vlax-curve-getPointAtParam

vlax-curve-getEndParam

(vlax-curve-getEndParam curve)

Parameter at the end of the curve (see vlax-curve-getStartParam): the length on a line, the number of segments on a polyline, 2π on a circle. nil on the ray and the construction line.

Example

Goes through the vertices of a polyline:

(setq e (car (entsel)) i 0)
(while (<= i (vlax-curve-getEndParam e))
  (print (vlax-curve-getPointAtParam e i))
  (setq i (1+ i)))

See also

vlax-curve-getStartParam · vlax-curve-getEndPoint · vlax-curve-getDistAtParam

vlax-curve-getStartPoint

(vlax-curve-getStartPoint curve)

Start point of the curve, in world coordinates (WCS). nil on the construction line.

Example

(vlax-curve-getStartPoint (entlast))   ; (1.0 2.0 3.0) on a line from 1,2,3 to 11,7,-2

See also

vlax-curve-getEndPoint · vlax-curve-getPointAtParam

vlax-curve-getEndPoint

(vlax-curve-getEndPoint curve)

End point of the curve (WCS). On a closed curve it is the start point; nil on the ray and the construction line.

Example

(equal (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e) 1e-9)   ; T if the curve comes back to its start

See also

vlax-curve-getStartPoint · vlax-curve-isClosed

vlax-curve-getPointAtParam

(vlax-curve-getPointAtParam curve parameter)

Point (WCS) of the curve at that parameter (see vlax-curve-getStartParam), or nil if it is off the curve. As in AutoCAD, the circle, ellipse, spline, ray and construction line do give a point outside their range (they follow their shape).

Example

(vlax-curve-getPointAtParam pline 1.5)   ; middle of the second segment of the polyline

See also

vlax-curve-getParamAtPoint · vlax-curve-getPointAtDist

vlax-curve-getParamAtPoint

(vlax-curve-getParamAtPoint curve point)

Parameter of a point that lies on the curve; nil if it does not. For any point, first find the closest one with vlax-curve-getClosestPointTo.

Example

(vlax-curve-getParamAtPoint pline (vlax-curve-getClosestPointTo pline (getpoint)))

See also

vlax-curve-getPointAtParam · vlax-curve-getDistAtPoint

vlax-curve-getDistAtParam

(vlax-curve-getDistAtParam curve parameter)

Length of the curve from its start to that parameter. With the end parameter it gives the total length.

Example

(vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))   ; length of any curve

See also

vlax-curve-getParamAtDist · vlax-curve-getDistAtPoint

vlax-curve-getParamAtDist

(vlax-curve-getParamAtDist curve distance)

Parameter of the point at that distance from the start, measured along the curve. nil (or whatever AutoCAD does with that type) if the distance is negative or greater than the length.

Example

(vlax-curve-getParamAtDist pline 10.0)

See also

vlax-curve-getDistAtParam · vlax-curve-getPointAtDist

vlax-curve-getPointAtDist

(vlax-curve-getPointAtDist curve distance)

Point (WCS) at that distance from the start, measured along the curve; nil off the curve.

Example

Marks a point every 5 units along a curve:

(setq e (car (entsel)) d 0.0 total (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)))
(while (<= d total)
  (entmake (list '(0 . "POINT") (cons 10 (vlax-curve-getPointAtDist e d))))
  (setq d (+ d 5.0)))

See also

vlax-curve-getDistAtPoint · vlax-curve-getParamAtDist · MEASURE

vlax-curve-getDistAtPoint

(vlax-curve-getDistAtPoint curve point)

Length from the start to a point that lies on the curve; nil if it does not.

Example

(vlax-curve-getDistAtPoint e (vlax-curve-getClosestPointTo e (getpoint "\nPoint: ")))

See also

vlax-curve-getPointAtDist · vlax-curve-getParamAtPoint

vlax-curve-getClosestPointTo

(vlax-curve-getClosestPointTo curve point [extend])

Point of the curve closest to point (2D or 3D, WCS). With extend other than nil, the line and the ray count as infinite lines, the arc as its circle, the partial ellipse as the whole ellipse, and the end segments of a 2D POLYLINE are extended; as in AutoCAD, the LWPOLYLINE, 3D POLYLINE and spline are not extended.

Example

(vlax-curve-getClosestPointTo ln '(0 0) T)   ; foot of the perpendicular to the line's infinite line

See also

vlax-curve-getParamAtPoint · vlax-curve-getDistAtPoint

vlax-curve-getFirstDeriv

(vlax-curve-getFirstDeriv curve parameter)

First derivative (tangent vector) at that parameter, with AutoCAD's values: on a line it is the vector from start to end; on an arc or a circle, with respect to the angle (length = radius); on a straight polyline segment, the segment vector, and on an arc segment, with respect to the angle and in the direction of the polyline.

Example

(angle '(0 0) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e p)))   ; direction of the curve at p

See also

vlax-curve-getSecondDeriv · vlax-curve-getPointAtParam

vlax-curve-getSecondDeriv

(vlax-curve-getSecondDeriv curve parameter)

Second derivative at that parameter, as AutoCAD gives it (on polyline arcs, the first derivative turned 90° to the left; on an LWPOLYLINE with elevation, AutoCAD adds that elevation in Z, and so does LinceCAD).

Example

(vlax-curve-getSecondDeriv circ 0.0)   ; (-r 0.0 0.0) on a circle of radius r

See also

vlax-curve-getFirstDeriv

vlax-curve-getArea

(vlax-curve-getArea curve)

Area enclosed by the curve; if it is open, closing it with the straight line between its ends (like the AREA command). nil if the curve is not planar or has no end (ray, construction line); 0.0 on a line.

Example

(vlax-curve-getArea (car (entsel "\nBoundary: ")))

See also

vlax-curve-isClosed · AREA

vlax-curve-isClosed

(vlax-curve-isClosed curve)

T if the curve is closed: circle, whole ellipse, polyline marked as closed or spline that ends where it starts. An open polyline whose last vertex is on the first one does not count as closed, as in AutoCAD.

Example

(if (vlax-curve-isClosed e) (princ "\nClosed") (princ "\nOpen"))

See also

vlax-curve-isPeriodic · vlax-curve-getArea

vlax-curve-isPeriodic

(vlax-curve-isPeriodic curve)

T if the curve is periodic: circle, ellipse (an elliptical arc too), closed LWPOLYLINE and periodic spline (the closed ones drawn by SPLINE).

Example

(vlax-curve-isPeriodic circ)   ; T

See also

vlax-curve-isClosed · vlax-curve-isPlanar

vlax-curve-isPlanar

(vlax-curve-isPlanar curve)

T if the curve lies in a plane. All of them do except a 3D POLYLINE or a spline whose vertices or control points are not coplanar.

Example

(vlax-curve-isPlanar p3d)   ; nil on a 3D polyline with vertices at different heights

See also

vlax-curve-getArea · vlax-curve-isClosed

load_dialog

(load_dialog file)

Loads a DCL dialog box file and returns a positive number that identifies it, or a negative number if it cannot be found or has errors.

The file is looked for as given, in the drawing folder, in the trusted folders (as load) and in the folder of the last .lsp file loaded, which is where a routine's .dcl files usually are; without an extension .dcl is tried. If it has a syntax error, the program reports it in a box with the line of the error, like AutoCAD.

The DCL language

Each dialog box is a definition name : dialog { ... }. Inside go attributes (label = "Text";, key = "key";, width = 20;) and child tiles, anonymous (: button { key = "b1"; label = "One"; }) or by name (ok_cancel;). A definition can inherit from another (my_button : button { width = 12; }), also from several, and @include "other.dcl" adds the definitions of another file. Comments with // and /* */.

Tiles: dialog, row, column, boxed_row, boxed_column, radio_row, radio_column, boxed_radio_row, boxed_radio_column, button, edit_box, toggle, radio_button, list_box, popup_list, slider, text, paragraph, concatenation, text_part, image, image_button and spacer. Standard prototypes: ok_only, ok_cancel, ok_cancel_help, ok_cancel_help_info, ok_cancel_help_errtile, ok_button, cancel_button, help_button, info_button, errtile (key error), spacer_0, spacer_1, default_button, retirement_button, edit12_box, edit32_box, image_block and icon_image.

Dialog boxes are drawn with the look of LinceCAD's own: width and height (in characters and lines) are minimum sizes and alignment places the tiles of a column.

Example

(setq id (load_dialog "layers.dcl"))
(if (< id 0) (exit))

See also

new_dialog · unload_dialog · start_dialog

unload_dialog

(unload_dialog id)

Unloads a DCL file loaded with load_dialog. Returns nil.

Example

(unload_dialog id)

See also

load_dialog

new_dialog

(new_dialog name id [action [point]])

Prepares the dialog box name of file id and returns T, or nil if it does not exist. Between new_dialog and start_dialog the initial values (set_tile, lists, images) and the actions (action_tile) are given.

action is the expression run by tiles that have no other. point is the position of the box on screen, in pixels; '(-1 -1) centres it.

Example

(if (not (new_dialog "layers" id)) (exit))

See also

start_dialog · done_dialog

start_dialog

(start_dialog)

Shows the dialog box prepared with new_dialog and waits until it closes. Returns the status given by done_dialog: 1 with OK, 0 with Cancel or Esc and -1 if it was closed with term_dialog.

While it is open, each user action runs the expression of its tile. Without their own action, OK (accept) closes with 1 and Cancel with 0; the cancel button closes with 0 even if its action does not call done_dialog. An action can open another dialog box on top.

With a dialog box open, points cannot be asked for nor objects selected (getpoint, entsel, command…): they give the error "function rejected". To select from a dialog box, close it with a status of your own, select and open it again, as in AutoCAD. getvar "CMDACTIVE" has the 8 bit while a dialog box is open.

Example

(setq st 2)
(while (> st 1)
  (new_dialog "point" id)
  (if p (set_tile "x" (rtos (car p))))
  (action_tile "pick" "(done_dialog 4)")
  (setq st (start_dialog))
  (if (= st 4) (setq p (getpoint "\nPoint: "))))

See also

done_dialog · term_dialog · action_tile

done_dialog

(done_dialog [status])

Closes the current dialog box when the running action ends; start_dialog returns status (without it, 0). Returns the position (x y) of the box on screen, to open it later in the same place with new_dialog.

Example

(action_tile "accept" "(setq name (get_tile \"name\")) (done_dialog 1)")

See also

start_dialog · term_dialog

term_dialog

(term_dialog)

Closes all open dialog boxes as if they were cancelled: each start_dialog returns -1. Returns nil.

Example

(defun *error* (m) (term_dialog) (princ m))

See also

done_dialog

action_tile

(action_tile key expression)

Assigns to tile key the expression (a string with one or more AutoLISP expressions) run when the user uses it. Returns T. While it runs these are defined:

The action of a radio button group (radio_row, radio_column) runs when any of its buttons without its own action is chosen; $value is the key of the chosen one.

Example

(action_tile "all" "(mode_tile \"list\" (if (= $value \"1\") 1 0))")

See also

get_tile · client_data_tile · done_dialog

set_tile

(set_tile key value)

Changes the value of tile key (a string): the text of an edit box, "1"/"0" of a toggle or a radio button (which turns off the others of its group), the key of the chosen button of a group, the selected indexes of a list or the text of a text or errtile. Returns the value, or nil if the tile does not exist.

Example

(set_tile "error" "The radius must be positive")

See also

get_tile · mode_tile

get_tile

(get_tile key)

Current value of tile key, as a string; nil if it does not exist or there is no dialog box.

Example

(setq r (atof (get_tile "radius")))

See also

set_tile · get_attr

mode_tile

(mode_tile key mode)

Changes the state of the tile: 0 enables it, 1 disables it (greyed), 2 gives it the focus, 3 also selects its text and 4 flips the highlighting of an image. Returns nil.

Example

(mode_tile "accept" 1)

See also

set_tile

get_attr

(get_attr key attribute)

Value of attribute attribute of the tile as written in the DCL file (it does not change with set_tile), as a string; nil if the tile does not have it.

Example

(get_attr "name" "edit_limit")   ; "12"

See also

get_tile

client_data_tile

(client_data_tile key data)

Stores a string for the tile, which its action receives in $data. Returns nil.

Example

(client_data_tile "b1" "layer-0")

See also

action_tile

start_list

(start_list key [operation [index]])

Starts changing the list of a list_box or popup_list: operation 3 (the default) replaces it, 2 appends and 1 changes element index. The elements are given with add_list and it ends with end_list. Returns the key, or nil if the tile does not exist.

Example

(start_list "layers")
(mapcar 'add_list names)
(end_list)

See also

add_list · end_list

add_list

(add_list string)

Adds (or changes, with operation 1 of start_list) an element of the current list. Returns the string, or nil if there is no current list.

Example

(add_list "Layer 0")

See also

start_list

end_list

(end_list)

Ends the list started with start_list. Returns nil.

Example

(end_list)

See also

start_list

start_image

(start_image key)

Starts drawing in an image or image_button tile; what is drawn with fill_image, vector_image and slide_image is shown when end_image is called. Returns the key, or nil if the tile does not exist.

Example

(start_image "sample")
(fill_image 0 0 (dimx_tile "sample") (dimy_tile "sample") 1)
(end_image)

See also

dimx_tile · end_image

end_image

(end_image)

Ends the drawing started with start_image. Returns nil.

Example

(end_image)

See also

start_image

dimx_tile

(dimx_tile key)

Width of the tile in pixels (image coordinates go from 0 to this value minus 1); 0 if it does not exist.

Example

(setq w (dimx_tile "sample") h (dimy_tile "sample"))

See also

dimy_tile · vector_image

dimy_tile

(dimy_tile key)

Height of the tile in pixels; 0 if it does not exist.

Example

(vector_image 0 (/ (dimy_tile "sample") 2) (dimx_tile "sample") (/ (dimy_tile "sample") 2) 7)

See also

dimx_tile

fill_image

(fill_image x y width height colour)

Fills a rectangle of the current image, in pixels with the origin at the top left. colour is an AutoCAD colour index or -2 (graphics screen background), -15 (dialog background), -16 (dialog text) or -18 (dialog lines). Returns the colour, or nil if there is no current image.

Example

(fill_image 0 0 (dimx_tile "colour") (dimy_tile "colour") 3)

See also

vector_image · start_image

vector_image

(vector_image x1 y1 x2 y2 colour)

Draws a segment in the current image, in pixels with the origin at the top left, with the colours of fill_image. Returns the colour, or nil if there is no current image.

Example

(vector_image 0 0 (dimx_tile "img") (dimy_tile "img") 1)

See also

fill_image · slide_image

slide_image

(slide_image x y width height slide)

Draws an AutoCAD slide in the rectangle of the current image, fitted without distorting it. slide is a .sld file or library(name) for one inside a .slb; they are looked for like other files. Returns the name, or nil if it is not found or there is no current image.

Example

(slide_image 0 0 (dimx_tile "icon") (dimy_tile "icon") "symbols(door)")

See also

start_image · vector_image

exit

(exit)

Ends the routine with the error quit / exit abort (which reaches error).

What comes after it is not run. If the routine has its own error, it receives the message quit / exit abort and can restore variables before leaving; otherwise the message appears on the command line.

Example

(defun c:test () (prompt "\nOne") (exit) (prompt "\nTwo"))
TEST   ; writes «One; error: quit / exit abort»

See also

quit · error · vl-catch-all-apply

quit

(quit)

Same as exit.

It also reaches error with the message quit / exit abort, and what comes after it is not run.

Example

(defun c:test (/ *error*)
  (defun *error* (m) (princ (strcat "\nError: " m)) (princ))
  (quit))

TEST writes Error: quit / exit abort.

See also

exit · error

vl-catch-all-apply

(vl-catch-all-apply function list)

Like apply, but an error neither stops the routine nor calls *error*: it returns an error object, which is checked with vl-catch-all-error-p.

(setq r (vl-catch-all-apply '/ '(1 0)))
(if (vl-catch-all-error-p r) (princ (vl-catch-all-error-message r)))

vl-catch-all-error-p

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

T if the value is an error object of vl-catch-all-apply.

If the call did not fail, the value is the normal result and it gives nil: (vl-catch-all-apply '/ '(4 2)) returns 2.

Example

(vl-catch-all-error-p (vl-catch-all-apply '/ '(1 0)))   ; T
(vl-catch-all-error-p (vl-catch-all-apply '/ '(4 2)))   ; nil

See also

vl-catch-all-apply · vl-catch-all-error-message

vl-catch-all-error-message

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

Message of the error object.

(vl-catch-all-error-message (vl-catch-all-apply '/ '(1 0)))   ; "divide by zero"

The message is the one that would appear on the command line after ; error:, in English as in AutoCAD. Use it to report the failure without stopping the routine.

Example

(setq r (vl-catch-all-apply '/ '(1 0)))
(if (vl-catch-all-error-p r)
  (princ (strcat "\nCould not: " (vl-catch-all-error-message r))))

It writes Could not: divide by zero.

See also

vl-catch-all-apply · vl-catch-all-error-p · error

vl-load-com

(vl-load-com)

In AutoCAD, loads the ActiveX functions. In LinceCAD (see vlax-get-acad-object) they work with or without this call: it returns nil so that routines that call it at the start do not fail.

Keep the call at the top of imported routines: it does no harm and it lets the same file work on both programs.

Besides returning nil, it writes a notice on the command line so that you know why the routine may fail later:

Warning: ActiveX in LinceCAD is partial: curves and the most used properties and methods; no reactors, attributes or dynamic properties.

What happens with the vla- and vlax- functions

All the vlax-curve-… functions are there (see vlax-curve-getStartParam). The others are not defined: calling one gives the "no function definition" error, for example (vlax-get-acad-object). Many routines only use them for things that have an equivalent in classic AutoLISP:

Example

(vl-load-com)   ; nil, and it writes the notice

See also

entget · entmod · tblnext · AutoLISP

ver

(ver)

Version of the interpreter, such as "LinceCAD LISP 0.x.y".

The number is that of the installed LinceCAD version. Use it to let a routine know which program it is running in, because AutoCAD returns another text.

Example

(ver)   ; "LinceCAD LISP 0.9.8-rc3"
(wcmatch (ver) "LinceCAD*")   ; T in LinceCAD

See also

getvar · wcmatch

gc

(gc)

In AutoCAD, frees memory. In LinceCAD it is not needed: it returns nil.

It is kept so that routines that call it still work. LinceCAD frees memory on its own, so it never needs to be called and it has no effect.

Example

(gc)   ; nil

See also

ver

Download LinceCAD Manual contents

Download the free 30-day trial · Open and edit DWG files · AutoCAD LT alternative

Coming from AutoCAD? Check what is compatible · Linux CAD with native DWG