AutoCAD VBA

Highlighting a Line from a Macro (Macro-izing Line Drawing) (AutoCAD VBA) Part 1

Using the Highlight method, you can specify whether or not a drawing object is to be drawn highlighted. When a line is highlighted, it is drawn using dashed lines. The HighlightLastItemDrawn macro shown in Listing 6.5 takes the last drawing object that was added to the ModelSpace collection and highlights it by calling its Highlight […]

Highlighting a Line from a Macro (Macro-izing Line Drawing) (AutoCAD VBA) Part 2

Highlighting and Coloring All Lines The macros in this section highlight or unhighlight all the lines (or drawing objects) in the ModelSpace collection in one hit. Listing 6.7 shows the HighlightAllItems and UnHighlightAllItems macros. This code should be placed into Module1 of the Line Input project beside the HighlightLastItemDrawn macro; then they will be listed […]

Identifying Lines Selected by the User (Macro-izing Line Drawing) (AutoCAD VBA)

AutoCAD allows users to select a set of drawing objects and then makes these objects into a temporary collection—the SelectionSet collection that belongs to the ThisDrawing object. This set only exists as long as the drawing remains open. This collection can be referenced by a variable declared as being capable of referring to an AcadSelectionSet […]

Scales and Weights for Lines (Macro-izing Line Drawing) (AutoCAD VBA)

So far you’ve seen how to write code for an application that allows the user to select lines, change their type and color, and make them appear highlighted. There are a couple of other things you may want to do in this application; these include scaling the linetype or the line itself, and specifying a […]

Scaling Using a Transformation Matrix (Macro-izing Line Drawing) (AutoCAD VBA)

In this section you’ll learn how scaling can be achieved by calling the TransformBy method with a transformation matrix that includes the scaling factors passed to it as an argument. The scaling factors are the values that determine how large an object grows in the x, y, and z directions; these values can be different. […]

Multiple Parallel Lines (Macro-izing Line Drawing) (AutoCAD VBA)

As you probably already know, multilines come in various styles and are typically used for drawing walls or anything else that requires parallel lines. As you draw a line using the Standard style of multiline, it is accompanied by a second line that is a set distance apart. Exercise 6.1: Line Input Application Listing 6.17 […]

Using Arc Objects (Macro-izing Line Drawing) (AutoCAD VBA)

In VBA the Arc object is created using the AddArc method that requires four arguments to draw the arc. These arguments are the center and radius of the circle on which the arc is based, and the start and end angles that determine the arc’s position and length. This time, let’s prompt the user and […]

Drawing Circles (Macro-izing Solid Areas) (AutoCAD VBA)

This topic introduces VBA techniques for working with solid areas. You’ll learn how to add a circle to your drawing and fill it with color. Also covered are freeform shapes: how to draw them and calculate the area they cover from a VBA macro. The ComboBox control is introduced, and you’ll see how to format […]

Circle of Bricks Application (Macro-izing Solid Areas) (AutoCAD VBA)

When you have a specific effect in mind, filling a circle with a Hatch pattern may not give you the look you want. Suppose you want a circle of brick pavers, for example. Figure 7.3 shows the result of changing SOLID to BRICK at Line 18 of Listing 7.2. Exercise 7.3: Draw Circular Pavers Application […]

Drawing Freeform Shapes (Macro-izing Solid Areas) (AutoCAD VBA)

In this section you’ll see how to develop an application that allows the user to select points defining a shape from the Model Space and fill it with a fill pattern. The user will be allowed to choose the fill pattern, as well as the representation of the selected points in the drawing. Exercise 7.4: […]