6. Blocks and block functions

This chapter describes block structures and functions that allow you to group objects and thus create complex objects, edit (modify) blocks, create a library of typical elements and how to use it.

6.1. Basic information

A block is a complex object created by grouping selected elements. Block identifiers are its name (type) or the disk file name of the typical content library. An additional block identifier stored in the directory can be a " block description ".

AlfaCAD treats the block as a single complex entity. The block can be moved, deleted, rotated, changed its scale, etc. by selecting any component of the block.

Block functions (so-called " block functions ") are available in the / Block / main menu option.
You can build a block from elements from the current drawing. You can create your own library of blocks (library elements) and use it to create other drawings by inserting blocks to a specific location.

When inserting a block into a drawing, the user get direct access to it (e.g. to copy it) by selecting one of the block types in the drawing from the menu. Thus, by introducing, for example, a block containing a horizontal cross-section of the window into the drawing (e.g. by selecting the / Block // Import / function ), that window can be inserted into other places in the drawing without the need to re-import the block from the catalog.

If a block imported from a directory or the last copy of this block in a drawing is modified, the next time that modified block is referenced, it will be taken in its modified form. This allows, for example, to easily adapt an imported block to the needs of a given drawing, without the need to create another block in the catalog, with quick access to it.

6.2. Blocks and layers

A block can be made up of elements placed on different layers and drawn with different colors and line thicknesses of different types. Color, thickness and line type are attributes of each block element and are not modified when grouping elements into a block, saving to the clipboard and saving (exporting) a block to the directory, or copying from the clipboard or importing a block from the directory and inserting into a drawing.

Although each block element may lie on a different layer during its creation (grouping and export to the directory), when a block is imported from disk, all block elements are placed either on the current layer or on the original layers, i.e. those on which a given object was located in the moment of grouping, saving to the clipboard or exporting to a disk directory.

It depends on switching off or on the option / Fixed layers / in the / Block / option of auxiliary menu . Enabling the "Fixed layers" option allows preservation of the adopted layer structure in the drawing, but it requires the consistency of layers between the drawings from which the block was exported and the drawing to which it is imported. Of course, the program cannot check the compatibility of layers, because the name of the layer itself is not important, but its actual purpose. If the highest layer number of a block element is higher than the highest layer number in the drawing, the block is still inserted with the layers preserved, and any missing layers in the drawing are automatically initialized with the default configuration parameters.

The block can be transferred (completely) to another layer using the edit function / Change / .

6.3. Compound blocks

A block can contain other blocks. So you can group basic elements (primitives) and save blocks that are views of different gears, pivots, bearings, shafts, etc. From such blocks you can build a gearbox drawing. After grouping these blocks, a compound block can be created as a drawing of a gearbox. This block can be saved to disk, thus expanding the library of catalog elements.

The block complexity is unlimited. Compound blocks can then be exploded into simpler blocks. This allows for any block to be decomposed, modified and recomposed into block of any other complexity. The block structure is not the final form of a group of elements, therefore the developed library of typical elements may be subject to any changes and updates in the future.

6.4. Grouping objects into a block

Grouping elements into a block can be performed in three ways. One of them allows to link the elements on the drawing with each other assigning an appropriate name interpreted as " block type ", and indicating the " block insertion point " (base point).

Grouping elements in a drawing into blocks is performed in / Group / block function . The grouping procedure requires indicating drawing elements and a base point (similar to moving, copying, copying, etc.). Before composing items into a block, the program asks for the "block type". Type is any string name up to 255 characters long. This name should be unique throughout the drawing, although it is not an absolute requirement.

If the block type is defined (non-empty string), the block can be retrieved (for copying) by selecting the appropriate block type from the menu (the function / Block // List / is used for this ). Hence, it is recommended to give different blocks unique type names. The consequence of defining a block type with a text value identical to the type of another block existing in the drawing is replacing the existing block from the list of block types available in the menu. Obviously, this does not affect the graphic form of the drawing or its structure, and thus the possibility of implementing any editing functions, but it makes direct access to blocks by their type difficult.

The second way is to indicate in the drawing the elements from which the block will be created and saved to the set with the given name in any directory on the disk. Such a block, in addition to the base point and type, can have a so-called "block description" helpful in identifying the block searched for in disk catalogs. This description is displayed in the top line of the screen in the function / Block // Import / . The basic elements indicated in this method are not grouped into a block in the drawing.

The third way is to copy - and then - paste the block into the drawing. This procedure is similar to exporting and importing a block except that neither the "block description" nor the disk file name is specified. Block is stored in the so-called clipboard. After a block is inserted into the drawing and if a non-empty type name was given when the block was copied, it can be appear in the list of blocks. Block copied into the clipboard can be pasted into any open AlfaCAD windows, so it let to copy the block from one drawing to another without saving block in the directory.

6.5. Saving the block in the "clipboard"

Grouping elements in the form of a block and storing in the so-called “clipboard” is implemented in the / Block / main menu function , and then the / Copy / option . The procedure requires indicating the elements and a base point (similarly to the function of moving, copying, changing the scale, etc.) and then the block type.

It is not necessary to specify the block type. However, if we want to have access to it through the list of blocks after inserting a block into the drawing, it is worth entering this type name. It should be a unique name, not used yet for another block on drawing.

The function can be used to use a clipboard to transfer blocks between drawings (or within the same drawing).

6.6. Inserting a block from the "clipboard"

The saved block is placed on the drawing in the function / Block // Paste / . Before the block is placed in the drawing, it can be dynamically moved across the sheet. At the same time, all modes of block insertion point location in relation to other objects are available. In the additional auxiliary menu / Block / the following options are available:

A block can be inserted multiple times without needs to repeat the function. Each time, the scale, rotation and or mirroring operation can be performed to modify the position of each copy of the block. To exit function press {RMB} or {Esc}.

6.7. Saving a block in a disk file (export)

Grouping of elements in a disk block is performed int the function / Block / of the main menu, and then the option /Export block/ . The grouping procedure requires indicating of drawing elements and a base point (similar to moving, copying, changing the scale, etc.), giving the name of disk file , then the block type and its description .

The name of the block disk file is given in the file dialog window similarly to the function / File // Save as / . It is recommended to specify file names without an extension. Block file name gets the standard '.ALX' extension, for example: 'ENGINE.ALX'.

When writing a block file to a disk, the program checks whether a file with this name exists on the disk (on the chosen device and directory). If exists, its name is changed by adding or changing the extension to '.BAK' and then saving the block file with given name. This enables the previous version of the block to be imported as an archive copy.

The default block folder is the folder declared in the " Blocks " variable in the [DIRECTORY] group of the ALFACAD.INI configuration file.

6.8. Reading a block from a disk file (import)

Placing a block in the drawing being an element of the library of blocks stored in disk directories is performed in the function / Block // Import block/ . In the disk files dialog window, similarly to the drawing loading procedure (/ File / / Open /), select the appropriate disk, directory and block disk file. The block will be imported and during its dynamic display, the block description will be visible in the upper line of the screen as an additional identifier.

After a block is read from a disk file, the block can be dynamically moved across the sheet before it is placed in the drawing. At the same time, all modes of block insertion point location in relation to other objects are available. In the additional auxiliary menu / Block / the following options are available:

An imported block can be inserted into a drawing many times. Each time, the scale, rotation and or mirroring operation can be performed to modify the position of each copy of the block. To exit function press {RMB} or {Esc}.

The default block folder is the folder declared in the " Blocks " variable in the [DIRECTORY] group of the ALFACAD.INI configuration file.

6.9. Block libraries

Blocks stored in disk files can constitute a library of typical elements used for creation of new drawings. When a block of a given type is entered into a drawing, this block is added to the internal drawing library with the possibility of reusing the inserted block in order to place it again in another place in the drawing.

The blocks are accessed by option / List / of function / Block / in main menu. The appropriate block is selected from the drop-down menu containing the types of all block types in the current drawing.

If there are several blocks with the same type name in the drawing as a result of copying a block or multiple import of the same block from the disk or as a result of declaring in the function / Group / for several blocks of the same type, only the last created or copied or recently imported from disk will appear in the list of blocks.

Selecting one of the types causes retrieval of a given block with the adoption of a base point defined for it, and dynamic display of the block while waiting for the insertion point of the block copy. The base point of the block assumes the position of the current cursor position. In the block function / Paste/, / Import / and / List / , the options / Scale / , / Rotation / , / mirror Y / , / mirror X / and / Divide / are available in the auxiliary menu.

Since the length of the menu list row is limited to 60 characters, longer strings are not indicated in the type declaration, unless required by other application functions.

Blocks saved in disk files, apart from the basic elements included in the block and its type, also contain a "description" of the block in the form of a string with a maximum length of 255 characters. The description of the block is displayed in the top line of the screen when determining the block insertion point in the drawing. This allows for a more complete control of the correctness of the performed operation.

A block description may contain additional information about the block, not included in its type name, but it is not included in the blocks library in blocks folder.

6.10. Breaking the block into elements (explosion)

Block function / Explode / allows you to decompose a block, polyline or a dimensional block (complex linear dimension, arc or circle dimension, circle etc.) into independent basic elements (primitives) or simpler blocks. This procedure converts the polyline into single lines and arcs. Exploding a block or dimension does not make any visible changes to the drawing.

In order to break down (explode) a complex object, it is necessary to indicate these objects in a generally accepted way. Simple elements (primitives) will of course be ignored because they are "elements" of the drawing and do not contain simpler elements.

After selecting the blocks to be exploded, in order to carry out the explosion procedure, select the / Block / auxiliary menu option and then the / Explode/ option . The selected blocks will be exploded and the program waits for the next blocks to be selected or the {RMB} or {Esc} key ending the function. Execution of the command / Explode / simplifies the block structure of the indicated objects by one degree. This means that performing this procedure in relation to a block composed of other blocks breaks the object down into blocks, not individual objects, unless the graphic primitives also constitute components of the exploded object. Thus, the explosion procedure can be performed for a complex block structure many times, until the block is broken only into simple elements (primitives).

The necessity to use the auxiliary menu ( / Block // Explode / ) in order to decompose the indicated block was introduced to avoid accidental destruction of the block structure of the drawing, which has a significant impact on the ease of its editing.

The / Explode / function allows blocks to explode consecutively without having to select the function again. The procedure ends after the resignation from indicating the next block, which is achieved after pressing {RMB} or {Esc}.

Breaking the block into simpler elements is accompanied by removing the attribute describing the type of the exploded block.

6.11. Frozen blocks

The concept of " frozen " blocks was introduced mainly for the drawing sheet blocks described in later chapters, and for electrical diagrams. These blocks are mostly electrical symbols and drawings of electrical devices. Obviously, frozen blocks can be used on any other drawing, wherever extra protection of library blocks against accidental exploding is necessary or welcome.

The purpose of "freezing" is to prevent the block from accidentally breaking in the function / Block // Explode / while executing this function on other, normal blocks.

The block is frozen by specifying in the name of the block type (in the function / Block / / Group / , / Copy / and /Export/ ) the first character " * " (asterisk) or " $ " (dollar).

In order to break a "frozen" block (eg to modify a library symbol), instead of the function / Block // Explode / use the function / Block // * explode frozen / .

An attempt to break a block frozen in the function / Block // Explode / is signaled with an appropriate message and the block is not exploded to simpler or primitive blocks.

6.12. Editing blocks

Blocks are subject to editing procedures similar to graphic primitives. When indicating objects in editing procedures using the pointfinder, it is sufficient to indicate any object included in the block or its fragment.

If no object was indicated directly, just the frame is market to select objects, if the " window " selection mode is active, all elements of each object included in the block must be in the block's window frame.

If the cross indicating mode is active, it is sufficient to frame any fragment of any block element.

Some editing functions can be performed directly on individual block objects, changing its internal structure, but without changing the block structure itself. Such functions include: / Edit text / , / Break / , / Trim / , / Extend / , / Fille / and / Chamf / and editing a dimension block . The other edit functions performed on a single block element require the block to be exploded first using the / Explode / block function .

After exploding and modifying (e.g. deleting) a given element, objects that were previously in a block can be regrouped using the / Group / block function . In this case, you must re-enter the type of the block that was lost due to its explosion.

6.12.1. Text editing

Any text that is part of a block can be edited like free text (not related to the block) and according to the same rules. Text editing concerns changing the text value, position in the drawing (and at the same time the position in relation to the base point of the block), text line direction, font height, width factor, character tilt attribute, type, justification, "hidden" attributes, font pattern as well as color and layer drawing.

The ability to edit the text of a block can be used to modify an imported block (as a catalog item) in order to adapt it to the needs of the current drawing, without breaking (exploding) the block into graphic primitives. Keeping the block form despite the modifications made allows for direct block operations, such as copying, moving, rotating, etc.

This property also affects the way libraries of typical elements are created. This is because it allows to enter texts in blocks (e.g. designations of elements) in a general form, prepared for further editing, prior to placing the block multiple times on a given drawing (copying).

6.12.2. Breaking (cutting), trimming, extending, filleting and chamfering

As with text editing, the break (cut), trim, extend, fillet, and chamfer procedures can be performed on block feature objects.

These operations do not change the block structure of the drawing. For the filleting and chamfering procedure, if both filleted or chamfered line segments are block elements, an additional filleting arc or chamfer line is automatically attached to the block. If one of the sections is not an element of the block, the additional section or arc is not added to the block, and the block is modified only in terms of changing the length of the element being the subject to filleting or chamfering.

If a given block has a complex structure (its elements are graphic primitives and other simple or complex blocks), then the additional arcs and segments resulting from filleting or chamfering are added to the lowest-order block in the structure of a complex block, whose the elements are being the subjects to filleting or chamfering.

In the breaking (cutting) procedure, additional objects (line segments or arcs) resulting from cutting line segments or arcs are attached to the block, and in the case of a complex block, to the lowest-order block in the structure of a complex block, whose the elements are lines or arcs were cut.

6.12.3. Editing a dimensioning block

Dimension blocks, like user-created blocks, can be modified to edit annotative text, cut, trim, and stretch lines and arcs, and even filleting and chamfering. This feature can be used, for example, to cut a dimension line to place descriptive text at the height of the dimension line, between extension lines. Cutting a dimension line can also be useful when making cuts for creating half-dimensions.

If there is a need to execute another editing function on a selected element of a dimension block, the block must be exploded first using the / Explode / block function.

6.13. Block attributes

Block attributes are "type" and "description", which are textual information about the block.

The " block type " is permanently linked to its structure and is stored in the drawing database.

The " block description " is additional information stored in the block's disk file and is used to fully identify it during the execution of the / Block // Import / function.

A block with a complex structure can contain several attributes (types) located at different levels of complexity.

Block attributes are not visible in the drawing. They are identifiers in the function / Block // List / and are displayed in the block type menu. Choosing a block type allows you to relocate the block without searching for it in the block library disk directories.

All blocks of unique type name are listed in / Blok / / List / function, no matter some of them are the elements of more complex blocks. So if block 'A' is grouped together with block 'B' into block 'C', all 3 blocks 'A','B', and 'C' will be listed, so each of interior block can be placed into the drawing as a new copy of it, despite it's a component of another block of higher complexity.

6.14. Editing block attributes

Editing block attributes in a drawing is possible by breaking the block into elements and regrouping the elements into a block with new type name of the newly created block.

An explosion is basically not necessary. Grouping can only include one block with a previously declared type. This increases the complexity of the block, but you can quickly rename its type. Still previous type of the block will also appear in the list, but can be later overwritten by the same type name of another newly created or inserted block.

Attributes of existing disk file blocks can be overwritten in the / Export / function . If block is exported to the file, and the name of the file already exists, block type and description of in existing block file is restored as default type and description, and then can be preserved or re-edited. This helps to correct blocks during creation of library of typical elements (like electrical symbols, machine parts etc).

6.15. Deleting DXF blocks

" DXF blocks " should be understood as blocks placed in a drawing as a result of its conversion from DXF format in the function / File // Import // DXF/ or /DWG/ or function / Block // Import DXF block /. Definitions of blocks (template blocks) are placed on their exclusive layer number 255. They are copied with an appropriate shift vector, possible rotation or change of scale into the layer declared in the DXF tag INSERT.

After completing the conversion of the drawing, template blocks are basically unnecessary, because they have already been used to create the drawing in the drawing conversion procedure. However, there are cases where these blocks should be left, e.g. to allow the continuation of an unfinished drawing. They are also define original, unchanged template blocks.

Template blocks cannot be removed from the drawing in a generally accepted manner, because layer 255 is inactive and therefore invisible. This can be done with the function / Block // Delete DXF blocks / . The function requires confirmation of the intention to delete DXF blocks permanently.

Removing DXF template blocks can greatly reduce the memory consumption of the drawing and speed up editing operations.

6.16. Import of DXF blocks

The functions of importing and exporting drawings in DXF format will be described in chapter 12.4 and 12.5. In this chapter about block operations, DXF block import function is described only. Although there is no fundamental difference between the DXF drawing and DXF block, block import, unlike drawing import, does not initialize a new drawing with layers, drawing sheet format and scale, and other parameters before all drawing elements are loaded, instead places all elements read from the DXF file on the current layers of an existing drawing, grouping them all into a new block.

As with AlfaCAD block import, the auxiliary menu offers the following options:

described earlier in chapter 6.6.

This feature allows you to use block libraries created in other graphics programs.

6.17. Inserting a graphic image

A graphic block in AlfaCAD is understood as a graphic image in one of the commonly used formats:

AlfaCAD is not an editor for graphic files such as photographs. The graphic files mentioned in this chapter are rather sketches, scanned geodetic base-maps, topographic maps as well as photogrammetric photos.

Graphic files such as scanned geodetic base-maps, depending on the size of the scanner and its resolution, may be large files. AlfaCAD, due to the hybrid nature of the drawing, partly raster, partly vector, minimizes the necessary resources, while maintaining the highest possible accuracy of the raster image presentation. If the graphic file is a bitmap with 1-bit color (black / white scan) or 8-bit (256 color) color, the color palette remains the same. If a raster file with a different color depth is loaded, it is converted to the optimal (closest to the original) 8-bit palette, and the image is saved in the drawing (as one of the graphics primitives) in a compressed but lossless form.

Multiple raster images can be placed in a drawing, each of them is presented and printed with its own color palette, optimal for each image.

Each image can be arbitrarily scaled, independently in the X and Y axis directions, and placed on the drawing at any angle. Calibration procedures available in AlfaCAD allow for precise positioning of the image, as well as subsequent correction using the method of linear isotropic (equalizing) transformation, called Helmert transformation, or linear anisotropic (different-scale) transformation, called affine transformation, based on the indicated cartometric points and scale factors.

After selecting a graphic file in the disk directory, a dialog box is initiated containing information about the graphic resolution [dpi], original image width and height [pxl], image width and height in the given X and Y scale [mm], and the X and Y scale editable in edit fields, rotation angle [deg], and background image fill indicator.

After determining the X and Y scales, and possibly setting the angle of rotation, the acceptance of the parameters initiates the insertion of the graphic file in the drawing, in a given scale, rotated by a given angle.

Changing the scale for the X and Y axes changes the actual size of the image in the drawing, which is visible in the parameters of the width and height of the image [mm], making it easier to know the size of the raster image, and therefore the necessary size of the drawing format.

The picture background fill parameter is applicable to 1-bit raster images, where white (background) color points are omitted from display and only non-white (usually black) color points are displayed. Due to the fact that each raster file can be scaled, as well as the fact that the entire drawing can be presented in a large scale range (1: 1000 to 1000: 1, in practice, the presentation is used in the range of 1: 100 to 100: 1), points rasters are replaced by rectangular areas whose edges are parallel to the local main axes of the raster image, which can be set at any angle to the global or local coordinate system of the drawing. The areas of the rectangles are the de facto scaled points in the raster image.

6.18. Editing a graphic image

The editing functions of the graphic block are available in the / Block / menu in option / Edit image block / and include:

The / Modify dx, dy / function allows you to change the scale in the direction of the main axes of the raster image by changing the point size in the X (dx) and Y (dy) axes. The values of dx and dy are determined when inserting a raster image on the basis of the resolution (dpi) and the given scale in the X and Y axes. The distinction between the dx and dy sizes allows to obtain an anisotropic transformation.

The function / Change parameters / allows you to edit the parameters of a raster image, in the same way as when inserting an image into a drawing. The differentiation of the scale along the X and Y axes allows for an anisotropic transformation.

The function / Calibration / allows for a linear isotropic transformation by selecting two base points on the image, and then selecting two cartographic points on the drawing. The image will be calibrated in such a way that the base points will coincide with the cartographic points, therefore the image will be scaled and rotated by the required angle.

6.19. Graphic image export

The function / Block // image exporT / allows you to extract a raster image from a drawing and save it to a disk file. Since the raster image is stored in a format almost identical to the PCX format, the image is exported to a disk file in that format too. The image retains its original color depth (1 or 8 bit).

The saved raster image can be inserted into another drawing using the / Block // iNsert image / function preserving the color depth, but with the possibility of changing the scale and rotation angle.

6.20. Blocks correction

Function / Block // coRrect blocks /is an auxiliary function that checks the structure of blocks and corrects the structure if necessary. This function is used when loading archive drawings made in previous versions of the program, converted from DXF format, and when an error has occurred during block operations.
As with any program, AlfaCAD is not 100% error-free, CAD programs, along with the entire drawing data management system, are programs of a high degree of complexity. The author of the program makes every effort to eliminate errors, reacting immediately to any signals from program users about errors, as well as performs many tests to avoid errors in subsequent versions of the program. However, when the block structure saved in the drawing has a negative effect on editing due to an error, or it causes the program to malfunction or crash, the block correction function comes with help.

6.21. Fixed layers

The / Block // Fixed layer / function allows you to switch the mode of assigning layer number to elements of an imported block. If the option is set to "No" (default), all block elements are inserted on the current layer. If is set to "Yes", the layer numbers of block elements are preserved. If the layer number of an imported block element does not exist in the drawing, the layer is initialized with default parameters. Since the layer numbers form an ordered sequence of integers, when initiating a new layer for a block import, also the layers with any intermediate numbers must be initialized.

There are several cases where the fixed layers option applies. One is to separate the purpose of layers or groups of layers for different design industries, as well as for different drawing elements or structures, e.g. in electrical diagrams, functional diagrams, maps, network diagrams, etc.

The value of the parameter / Fixed layer / is saved in each drawing as well as in each prototype drawing.

6.22. Catalogs of typical elements

The / Block // Open catalog / function enables quick and convenient access to block directories (e.g. typical elements or symbols).

Directories contain blocks created in AlfaCAD and saved in a directory with a name with the extension .ALF or .AXX. Due to the fact that the default block name extension in the block import function is .ALF, it is recommended to use .AXX extensions for catalogs, common elements etc. accessible via the / Open catalog / function, to distinguish them from other blocks.

The default folder of the blocks directory is the folder declared in the " Catalogs " variable in the [DIRECTORY] group of the ALFACAD.INI configuration file.

After selecting the function, the directory selection dialog is opened with the default directory as the "tree root" of directories. After selecting the appropriate directory from the "tree", pressing the OK button, if the directory contains blocks, i.e. files with the extensions .ALF or AXX, the catalog dialog window is initialized, with visible blocks existing in the folder, scaled to the size of a single dialog button, together with the control buttons for displaying the directory and the return button to select the directory either from the level of the default directory or from the level of the "tree roots" of directories, i.e. selecting any disk or network device and then the directory.

In case of bigger number of catalog items, their displaying is paginated. The number of blocks displayed on one page depends on the size of the AlfaCAD desktop window, so it depends on the size of the screen and the size of the desktop font, as well as on the size of a single button, the size of which can be changed with the [<>] and [> <] buttons . Block file names (excluding the path) are displayed below the button with the block illustration.

The selection of a block to be inserted in the drawing is done by pressing the button, then the dialog box is closed and the imported block is displayed dynamically awaiting positioning in the drawing, similarly to the function / Block // Import /. As with block import, the options / Block / are available in the auxiliary menu:

After selection, the block can be inserted multiple times with different parameters, until pressing the {RMB} or {Esc} key, after which the program returns to the block selection dialog window displaying the last opened directory. Such "looping" of functions speeds up inserting blocks in a drawing, which is particularly important in the case of electrical diagrams, functional diagrams, but also floor plans or facades in architectural drawings when completing the drawing with typical blocks of woodwork or equipment.

To quit the function, press the button with the "Escape" icon.