Creating Complex Entities
 
 
 

To create a complex entity (an old-style polyline or a block), you make multiple calls to entmake, using a separate call for each subentity. When entmake first receives an initial component for a complex entity, it creates a temporary file in which to gather the definition data and extended data, if present. (See Extended Data - xdata .) For each subsequent entmake call, the function checks if the temporary file exists. If it does, the new subentity is appended to the file. When the definition of the complex entity is complete (that is, when entmake receives an appropriate seqend or endblk subentity), the entity is checked for consistency; if valid, it is added to the drawing. The file is deleted when the complex entity is complete or when its creation has been canceled.

No portion of a complex entity is displayed on your drawing until its definition is complete. The entity does not appear in the drawing database until the final seqend or endblk subentity has been passed to entmake . The entlast function cannot retrieve the most recently created subentity for a complex entity that has not been completed. You can cancel the creation of a complex entity by entering entmake with no arguments. This clears the temporary file and returns nil.

As the previous paragraphs imply, entmake can construct only one complex entity at a time. If a complex entity is being created andentmake receives invalid data or an entity that is not an appropriate subentity, both the invalid entity and the entire complex entity are rejected. You can explicitly cancel the creation of a complex entity by calling entmake with no arguments.

The following example contains five entmake functions that create a single complex entity, an old-style polyline. The polyline has a linetype of DASHED and a color of BLUE. It has three vertices located at coordinates (1,1,0), (4,6,0), and (3,2,0). All other optional definition data assume default values. (For this example to work properly, the linetype DASHED must be loaded.)

(entmake '((0 . "POLYLINE")	; Object type
		(62 . 5)			 ; Color
		(6 . "dashed")	 ; Linetype
		(66 . 1)			 ; Vertices follow
) )
(entmake '((0 . "VERTEX")	; Object type
		(10 1.0 1.0 0.0)	 ; Start point
) )
(entmake '((0 . "VERTEX")	; Object type
		(10 4.0 6.0 0.0)	 ; Second point
) )
(entmake '((0 . "VERTEX")	; Object type
		(10 3.0 2.0 0.0)	 ; Third point
) )
(entmake '((0 . "SEQEND")))	; Sequence end 

When defining dotted pairs, as in the above example, there must be a space on both sides of the dot. Otherwise, you will get an invalid dotted pair error message.

Block definitions begin with a block entity and end with an endblk subentity. Newly created blocks are automatically entered into the symbol table where they can be referenced. Block definitions cannot be nested, nor can they reference themselves. A block definition can contain references to other block definitions.

NoteBefore you use entmake to create a block, you should use tblsearch to ensure that the name of the new block is unique. The entmake function does not check for name conflicts in the block definitions table, so it can redefine existing blocks. See Symbol Table and Dictionary Access for information on using tblsearch.

Block references can include an attributes-follow flag (group 66). If present and equal to 1, a series of attribute (attrib) entities is expected to follow the insert object. The attribute sequence is terminated by a seqend subentity.

Old-style polyline entities always include a vertices-follow flag (also group 66). The value of this flag must be 1, and the flag must be followed by a sequence of vertex entities, terminated by a seqend subentity.

Applications can represent polygons with an arbitrarily large number of sides in polyface meshes. However, the AutoCAD entity structure imposes a limit on the number of vertices that a given face entity can specify. You can represent more complex polygons by dividing them into triangular wedges. AutoCAD represents triangular wedges as four-vertex faces where two adjacent vertices have the same value. Their edges should be made invisible to prevent visible artifacts of this subdivision from being drawn. The PFACE command performs this subdivision automatically, but when applications generate polyface meshes directly, the applications must do this themselves.

The number of vertices per face is the key parameter in this subdivision process. The PFACEVMAX system variable provides an application with the number of vertices per face entity. This value is read-only and is set to 4.

Complex entities can exist in either model space or paper space, but not both. If you have changed the current space by invoking either MSPACE or PSPACE (with command ) while a complex entity is being constructed, a subsequent call to entmake cancels the complex entity. This can also occur if the subentity has a 67 group whose value does not match the 67 group of the entity header.