The portability of programs that insert blocks is limited by the need to include, with the program, the required block libraries. This forces the programmer to package the drawings with the code, implementing some kind of batch procedure to help in its installation. The user must take care of setting the required environment variables that insure that the program will find the required drawings. Of course, a change in the structure of directories will render that program useless if the pertinent corrections aren't made to the ACAD paths. The same is valid for changes in file names. Uniformity in the operation of the program is not assured, as the drawings may be subject to tampering by anyone.
A way to overcome these difficulties is to define each time the required blocks, by means of the same program's code. This can be attained in a very efficient way by using the entmake function which creates, through direct access to the drawing's data base, the required new entities. The entmake function is specially adequate to the definition of blocks without the need of previously drawing the component entities. The resulting blocks may contain any valid drawing entity, including text attributes.
This function's syntax is as follows:
where [entity_list] contains the information which is neccessary to the creation of the desired entity in formatted in a way which is similar to that which the function entget returns. A simple way in which the programmer can obtain this list consists in previously drawing the required objects, and then using entget -typing, for instance (entget (car (entsel)))- and copying the resulting entity list. Copying may be done by selecting the text directly from the console window.
Blocks and other complex entities (such as POLYLINES) must be created through several successive calls to the entmake function that define, one by one, their components (vertex, attributes, etc.). When entmake detects the creation of a complex entity, a temporary file is opened, in which the definition's data are stored. Each time entmake is used, the existence of this temporary file is checked and the new information is included. Once the complex entity's definition is concluded, (through the creation of the neccessary SEQEND or ENDBLK entities, according to the type of complex entity definition) data is validated and if it is correct, the entity is added to the drawing's data base. If it succeeds in creating the entity, entmake returns the entity list or, if it is a block, its name. If entmake fails then nil is returned.
To avoid redefining an existing block, if one with the same name already exists, it is advisable to previously explore the blocks table using the tblsearch function.
Entmake can also be used in creating NON-GRAPHICAL objects, such as layers, dimstyles etc.