PyAcad 0.4.1

Entity Selection

The functions and constants in this section are defined directly in the ads module.

Entity and selection set related functions not found here are most likely implemented as methods of the acad_ename and acad_sset objects.

Selection Set Functions

ssget([mode][p1][p2][ptlist][filter]) -> acad_sset

Returns a selection set, possibly after the user has selected a number of entities on the screen. The details are similar to the Autolisp function of the same name.

The ptlist and filter arguments are currently ignored.

Note: The interface of this function is likely to be changed to use keyword arguments in the future.

ssnew([acad_ename]) -> acad_sset
Creates a new acad_sset object and returns it. If the optional argument is supplied, then the returned set will contain the entity refered to by it.
ssgetfirst() -> (grip_set, pickfirst_set)
Determines which entities are gripped and selected on screen. Returns a list of two elements, both of which can be None. If not None, Grip_set is an acad_sset object that contains all entities that have grips, and pickfirst_set is an acad_sset object that contains all entities that are selected, but not gripped.
sssetfirst(grip_set, pickfirst_set) -> acad_sset

Sets the selected and gripped entities on screen. The parameters are two acad_sset objects. The entities in grip_set are given grips, the entities in pickfirst_set are selected, but not gripped. The function raises a ValueException if any entitiy is in both sets at the same time.

Do not call this function when Autocad/Intellicad is in the middle of executing a builtin command.

Entity Name Functions

entfirst() -> acad_ename
Returns the an acad_ename object representing the first entity in the drawing database or None if the database is empty. Subsequent entities will be fetched with the "next" method of the acad_ename object.
entlast() -> acad_ename
Returns an acad_ename object representing the last undeleted entity in the drawing database (or None if the database is empty). This is most often used to identify an entity that was just created by command() or entmake(). If the last entity is a complex entity, then this main entity will be returned, and not the last subentity. (use the acad_ename method entnext() to fetch subentities)
entsel([prompt]) -> (acad_ename, point)

Pauses for user input, and returns a list of an acad_ename object and a point (a list of three reals). This is the point that was used to select the entity. The optional string argument specifies a string that entsel() displays before it pauses. If it is omitted, AutoCAD displays the "Select objects" default prompt. If no entity was selected, None is returned. If the user cancels the operation with <ctrl-C> or <Escape>, a KeyboardInterrupt exception is raised.

When the user responds to entsel() by specifying a complex entity, it returns the polyline or block header. This differs from the function nentselp(), which returns the nearest block attribute or polyline vertex.

A prior call to initget() can also enable a string return value.

Not implemented, use nentselp() instead.
nentselp([prompt | point]) -> (acad_ename, point)
nentselp([prompt | point]) -> (acad_ename, point, xform, elist)

This function is very similar entsel() but returns additional data for nested entities and allows the program to specify the pick point. If the point argument is given, nentselp will not prompt the user to select an entity, but will use the specified point as if the user had picked it on screen.

For non-complex toplevel entities, the data returned is identical to that from entsel(). For entities nested in block references or subentities of complex entities, the subentity is returned, and nentselp() additionally returns the entity's transformation matrix xform (a nested list of 4x4 reals), and the names of the entity's container blocks in elist (a list of acad_ename objects). The matrix can be used to transform any points retreived from the entity to world coordinates. The entity list holds the names of all complex entities and blocks the selected entity is nested in, starting at the deepest nesting level, and ending with the toplevel insert entity.

Please refer to the documentation of the Autolisp function (nentselp) for details on how to use the matrix and nesting information.

handent(handle) -> acad_ename

Finds the entity with the specified handle (a string representation of an integer number) and returns it as an acad_ename object. Handles must be turned on in the current drawing. The function will find entities that have been deleted during the current editing session. Such entities can be undeleted with the delete() method of the acad_ename object, which works as a toggle.

If the handle is not valid or it's entity can't be found in the database, a ValueError exception is raised.


Creates an entity according to the information in assoc_list and inserts it in the entity database, or any of the symbol tables depending on the type of the entity. If the created entity is the ENDBLK of a block definition, the name of the new block is returned.

Please refer to the specification of the ads_entmake()/AcDbEntmake() function in the ADS/ARX documentation or the (entmake) function in the Autolisp documentation for the possibilities and limitations when creating entities.

Not implemented yet.