|
![]() |
(entlast) returns the name of the last entity in the database
This entity name can be submitted to entget to obtain a full description of the entity. See entget below.
Often used to obtain the name of an entity just created with the command function.
This entity name can be fed to AutoCAD whenever it is prompting for general object selection. See example below under entnext.
(entnext) returns the name of the first entity in the database
(entnext en) returns the name of the next entity after the entity
identified by the variable en. If en is the last entity in the database,
entnext returns nil.
This entity name can be fed to AutoCAD whenever it is prompting for general object selection. For example, after entering ERASE and being prompted to select objects, you could enter !en1 (assuming you have assigned an entity name to variable en1). The name can also be used inside a command function -- (command ".erase" en1 "").
Entity names do not carry over to subsequent editing sessions, but entity
handles do.
(entsel "Pick the entity. ") returns a list with 2 elements:
the entity name and the coordinates of the point at which the entity was
selected. You can retrieve the entity name from this list with car
and the point with cadr. If no prompt is specified, a default prompt,
"Select object: ", is displayed.
(entget en) retrieves the entity identified by the variable en in the form of an association list which uses codes similar to (but not identical to) AutoCAD's DXF group codes
A few sample association lists are given below. A "verbal" description of the entity is given first, then the AutoLISP description in the form of the returned association list. These association lists are not complete; they contain only key elements for illustrative purposes.
Each sublist contains a group number - for example, 8 for layer, 40 for radius or text height, etc. By using the cdr and assoc functions, a value associated with a specified group number can be retrieved. For example, if the above association list for the circle has been set to variable el,
(assoc 40 el) returns (40 . 0.75)
(cdr (assoc 40 el)) returns 0.75
(assoc 10 el) returns (10 3.0 2.0 0.0)
(cdr (assoc 10 el)) returns (3.0 2.0 0.0)
Notice that the cdr of a dotted pair returns an atom, not a list.
(entmod elnew) Assuming the association list elnew has been modified
by use of the subst function, this entmod function modifies the database
to conform with the changes as they now exist in elnew.
(entupd en) updates the entity en
(entdel en) deletes the entity identified by the variable en (or
restores it if it was deleted earlier in the same editing session).
(entmake '((0 . "CIRCLE") (10 2.25 3.25 0.0) (40 . 0.75))) creates
a circle at 2.25, 3.25 with a radius of 0.75. Since the layer, color,
and linetype are not specified, they are set to the current layer, color,
and linetype.
After assigning a handle (hex ID number) to variable eh,
(handent eh) returns the name of the entity in the current editing
session, whether the entity has been deleted or not
After placing text in the drawing, then using (setq el (entget (entlast)))
to assign the text's association list to variable el,
(textbox el) returns a list containing two points which are the
lower left and upper right corners of the box surrounding the text, as
though the text were at zero rotation and inserted at 0,0,0. The
textbox function takes into account the font and style used by the text,
as well as whether the particular text string contains letters that descend
below the baseline.
To analyze proposed text before placing it in a drawing, submit an association
list (including at least the text string) to the textbox function in the
following form:
(textbox '((1 . "Put your text here")))
If only the text string is submitted as illustrated above, the textbox
function adopts the current setting for such things as style (and its associated
font, width factor, obliquing angle, etc.), and height. Or, these
can be explicitly defined in the association list submitted to textbox.