AcadToolbarItem Object Properties

As well as the common Application property, the AcadToolbarItem object supports the following properties. Gets the toolbar associated with the item, if it's a flyout toolbar item. This property's value is read-only. Gets or sets the help string for the menu item, which appears in the AutoCAD status line when a user highlights a menu item. Gets the index for the menu item. The first position in the index is 0. This property's value is read-only. Gets or sets the macro associated with the toolbar...

AcadToolbarItem Object

The AcadToolbarItem object represents a single button or separator on an AutoCAD toolbar. A toolbar button can contain a macro to be executed when it is selected by the user, or it can contain a nested toolbar called a flyout. Separators can't contain macros or flyouts. The Macro property is used to add or change the button's associated macro. The AcadToolbarItem object supports the following methods. Name Description AttachToolbarToFlyout Attaches the toolbar to a toolbar button defined as a...

The LaunchBrowserDialog Method

Use the LaunchBrowserDialog method to perform a Hypertext Transfer Protocol HTTP request, displaying a document using the default Web browser. It can't verify or validate URLs it simply opens the browser and sends the request, exactly the way launching a favorite works in Internet Explorer or launching a bookmark works in Netscape. This method sets OutputURL to the URL the user selects. It returns True if the Web browser successfully launched and the user selected a file, or it returns False to...

The GetCustomByKey Method

Use the GetCustomByKey method to retrieve the custom properties set in the drawing. The GetCustomByKey method returns nothing, and has the following syntax Table 21-6 details this method's parameters. Table 21-6. GetCustomByKey Method Parameters Name Data Type Description Key String The name of the custom property to get Value String The value of the custom property The following example illustrates retrieving a custom property called Key0 Public Sub TestGetCustomInfo Dim Key0 As String Dim...

AcadPlot Object

The AcadPlot object represents the set of methods and properties used for plotting specified layouts. You can display a plot preview, plot to a file or plot to a device, or batch-plot several plot commands. You can set the number of copies of the drawing to be plotted and specify quiet error mode so that the plot session will be uninterrupted. However, it should be noted that you can't create a configured plotter PC3 file using ActiveX. To create a PC3 file, use the Add-a-Plotter wizard in...

A

Table C-2 explains the system variables that start with A ACADLSPASDOC Controls whether the acad.lsp file is loaded into every open drawing or just the first one in the session. This variable's value is also stored in the LoadAcadLspInAllDocuments property of the AcadPreferencesSelection object. ACADPREFIX Stores the directory path specified by the ACAD environment variable, including ACADVER Stores the AutoCAD version number. AutoCAD 2000 15.0, AutoCAD 2000i 15.05, AutoCAD 2002 15.06, AutoCAD...

AcadDimOrdinate Object Properties

The AcadDimOrdinate object inherits all the properties of the AcadEntity object, the AcadObject object, and the AcadDimension object, as well as the common Application property. It also supports the following properties. Gets or sets the rounding of alternative units if the AltUnits property is turned on. This property and the two that follow override the value of the DIMALTZ system variable. Gets or sets whether leading zeros in alternative dimension values are suppressed. The initial value...

Circular Objects

This section demonstrates how to create the various circular objects. You create an Arc object by using the AddArc method. This method takes four arguments that determine the position and size of the arc Set ArcObject Object.AddArc CenterPoint, Radius, StartAngle, EndAngle Table 8-2 provides a brief description of each argument. A three-element array of doubles specifying the center of the arc in the WCS The start angle of the arc given in radians with respect to the X-axis of the WCS The end...

Creating Opening and Saving Projects

To extract, embed, create, save, load, and unload VBA projects, open the VBA Manager dialog box, shown in Figure 1-14. To open it, either type VBAMAN at the AutoCAD command prompt or choose Tools gt Macros gt VBA Manager. You must explicitly load all .dvb projects. AutoCAD loads embedded projects automatically when the drawing containing them is opened, depending upon how you configure AutoCAD's security options. Clicking New creates a new project in the VBAIDE that you can access by clicking...

Using the DimStyle Object

The DimStyle object represents some settings that determine the appearance of a dimension, tolerance, or leader. DimStyle objects are held in the DimStyles collection, and you may access them via the DimStyles collection's Item method. To create a new DimStyle object through code, you need to use the Add method of the DimStyles collection. Set DimStyleObject DimStylesCollection.Add DimStyleName Table 11-1 shows the Add method's parameter. Table 11-1. The Add Method's Parameter DimStyleName...

Getting and Setting Support Paths

Controlling support paths can be important if you're using custom applications during your AutoCAD session. Generally speaking, the default paths set by AutoCAD are probably not adequate because they don't include any paths for customs applications, for example. AutoCAD's saving grace is that you can change the default paths to accommodate your program needs. If you need to know the current path for your support files, you can read the SupportPath property of the PreferencesFiles object...

User Preferences

Tiere are actually two Preferences objects within AutoCAD AcadPreferences and DatabasePreferences. The AcadPreferences object is stored by AutoCAD and applies to all drawing sessions. The DatabasePreferences object also called the Document Preferences is stored with each drawing file and applies only to the drawing in which it was saved. This chapter covers a few aspects of the AcadPreferences object. A quick way to discern the differences between the AcadPreferences and DatabasePreferences...

Views

AutoCAD VBA uses a View object to represent a view. When you create a new drawing, no views are set up. All the views that you save in a drawing become members of the Views collection. The following code iterates through the Views collection and displays the names of saved views. Public Sub DisplayViews Dim objView As AcadView Dim strViewNames As String If ThisDrawing.Views.Count gt 0 Then For Each objView In ThisDrawing.Views strViewNames strViewNames amp objView.Name MsgBox The following...

Adding Separators 1

You can use the AddSeparator method to add a separator to your menu structure or to a toolbar. This method takes a single parameter and returns either a PopupMenuItem object or a ToolbarItem object. Here's the syntax for adding a separator to a toolbar Set ToolbarItemObject ToolbarObject.AddSeparator Index Table 16-15 shows the AddSeparator method's parameter. Table 16-15. The AddSeparator Method's Parameter Name Data Type Description Index Variant The position within the toolbar where the...

AcadPopupMenus Collection Methods

The AcadPopupMenus collection supports four methods. Creates an AcadPopupMenu object and adds it to the collection. Parameter Name As String. Inserts a menu into the menu bar immediately before the position specified by the index. Parameters MenuName As String and Index As Variant Integer or String . If the Index is an Integer, it must be between 0 and N minus 1, where N is the number of pop-up menus in the menu bar. If the Index is a String, the name of the pop-up menu must contain any...

AcLeaderType

The following constants can be values for the Type property of the AcadLeader object.

Blocks Attributes and External References

Blocks collect any number of AutoCAD entities into a single container object. Create a BlockReference object to insert the Block container object also known as a block definition into model space, paper space, or another block definition. Because the BlockReference object refers to the block definition's geometry, it is an efficient means for managing drawing data You can add, move, copy, and so on, the entity collection as a whole. You can create a library of commonly used geometry ready for...

Enabling and Disabling the Startup Dialog Box

Users may or may not want the Startup dialog box as shown in Figure 5-4 when they open an existing drawing or start a new drawing. In AutoCAD 2004 and later, the Startup dialog box is disabled by default. You can control whether this dialog box is displayed using the EnableStartupDialog property of the PreferencesSystem object, as in the following example False The initial value of the EnableStartupDialog property is True for versions up to AutoCAD 2002 only. It is False for AutoCAD 2004 and...

Deleting a Linetype

The Linetype.Delete method removes a Linetype object from the Linetypes collection. This method takes no parameters and has no return value It's possible to delete a linetype practically whenever you choose however, certain line-types may not be deleted. A linetype may not be deleted if It is a ByLayer, ByBlock, or Continuous linetype. It is an Xref-dependent linetype. Just as with layers, if a linetype is used by entities in model space, any paper space layout or any block definition, it can't...

AcadGroups Collection Methods

In addition to the methods inherited from the AcadObject object, the AcadGroups collection supports the following methods. Creates a member object and adds it to the collection. Parameter Name As String. Gets the member object at a given index in a group. Parameter Index As Variant an Integer or a String . If the Index value is a String, it must match an existing group in the collection.

AcadAttributeReference Object

The AcadAttributeReference object represents an object containing text that links to a block or to an instance of the AcadAtribute object. These objects can't be directly created but are added to a drawing when a block containing an attribute definition is inserted. You achieve this by calling the InsertBlock method, which is common to the AcadBlock, AcadModelSpace, and AcadPaperSpace objects. The GetAttributes method of the AcadBlockReference object returns an array of all attribute references...

The ModelSpace and PaperSpace Collections

One of the first things you need to know to use the ModelSpace and PaperSpace collections is which space model or paper is currently active. This information is held in the ActiveSpace property of the Document object. This is an integer property, and it may hold one of the two values shown in Table 8-1, along with that value's associated AutoCAD constants. Table 8-1. ModelSpace and PaperSpace Constants Table 8-1. ModelSpace and PaperSpace Constants The following code snippet uses a message box...

AcadDPolyline Object

The Acad3DPolyline object represents a 3-D polyline of straight-line segments. You create it using the Add3DPoly method of the AcadBlock, AcadModelSpace, or AcadPaperSpace object. The Acad3DPolyline object inherits all the methods of the AcadEntity and AcadObject objects. It also supports the following methods. AppendVertex Appends a vertex to the polyline, which is an array of 3-D coordi nates. Parameter vertex As Variant a three-element array of Doubles . Explode Variant Explodes the polyline...

Add Page Header and Footer

A page header and footer allow you to add some other useful information, such as the path of the drawing or the report creation date. The example illustrates adding a page header and footer to our report. _ Layer Report for amp _ amp amp _ Date Created amp Date amp vbTab amp Total of Layers amp _ _ wdAlignPageNumberRight End With

Adjust the Fonts

You can adjust the fonts used in the report to any font available within Microsoft Word. The following example demonstrates changing the Normal, Header, Footer, and Page Number sections' font to Tahoma and various font sizes Note You'll add the following code snippets to the cmdCreateLayerReport_Click event routine. With mobjWord.ActiveDocument 'set text font and size for each section .Styles Normal .Font.Name Tahoma .Styles Normal .Font.Size 8 .Styles Header .Font.Name Tahoma .Styles Header...

Description Jau

PlotViewportBorders PlotViewportsFirst Specifies whether the plot configuration applies only to model space or to all layouts. If True, it applies only to the model space layout if False, it applies to all layouts. This property's value is read-only. Gets or sets the name of the object. Gets or sets the units for the display of the layout or plot configuration in the user interface. Note that changes to this property won't be visible until the drawing is regenerated. Possible values for the...

Using MInsertBlock Objects

An MInsertBlock object contains a planar array of block references in rows and columns. This section tells how to add and modify MInsertBlock objects. The AddMInsertBlock method works much like InsertBlock, except that the resulting entity is an MInsertBlock object. Just like InsertBlock, this method lets you specify a new entity's insertion point, scale, and rotation angle. It has additional parameters for the arrayed rows and columns. The method has the following syntax Set MInsertBlockObject...

AcadDimRotated Object Properties

The AcadDimRadial object inherits all the properties of the AcadEntity object, the AcadObject object, and the AcadDimension object, as well as the common Application property. It also supports the following properties. Gets or sets the rounding of alternative units if the AltUnits property is turned on. This property and the two that follow override the value of the DIMALTZ system variable. Gets or sets whether leading zeros in alternative dimension values are suppressed. The initial value for...

Deleting Menu Items

To delete a menu item from a PopupMenu object, you simply use the Delete method You can use the following macro to delete menus on the menu bar. The user specifies which menu to delete. The code then iterates through the menu items in that menu and asks the user if he or she wants to delete each item. Figure 16-8. Creating a cascading menu Public Sub DeleteMenu Dim objMenu As AcadPopupMenu Dim objMenuItem As AcadPopupMenuItem Dim strDeleteMenuName As String Dim strMenuName As String...

S

Table C-18 explains the system variables that start with s. SCREENBOXES SCREENMODE SCREENSIZE SDI Stores the current autosave file name. Specifies the directory path for all automatic save files for the session. This variable's value is also stored in the AutoSavePath property of the AcadPreferencesFiles object. Stores the file name and directory path of a drawing after it is saved. Sets the automatic save interval in minutes. This variable's value is also stored in the AutoSaveInterval...

Adding ActiveX Controls and Code Components

When you start a project and add a UserForm module, a common Toolbox appears. It contains a standard collection of ActiveX controls called intrinsic controls. Chapter 3 covers intrinsic controls in more detail. If you want to insert an ActiveX control that is not in the Toolbox, choose Tools gt Additional Controls or right-click in the Toolbox window and choose Additional Controls. The Additional Controls dialog box shown in Figure 1-19 appears. Figure 1-19. The Additional Controls dialog box...

Declaring Variables

Use the Dim statement in a procedure to declare a variable. Here's the syntax Dim lt VariableName gt As DataType Declare the variable's data type in the optional As DataType clause in the Dim statement. A variable's data type determines the kind of information a variable holds, such as String, Integer, or Object. See the Data Types section later in this chapter for more information. You don't have to declare variables as a specific data type before you use them. If you use a variable without...

DocumentLevel Events

Changes to a document or its contents result in document-level events. Adding or editing objects and regeneration of the drawing are just some examples of document-level events. Unlike application-level events, document-level events are available by default in the ThisDrawing module of an AutoCAD project. If you choose the AcadDocument object in the Object list box of the ThisDrawing module, the document-level events are listed in the Procedure list box, as shown in Figure 4-2. Dim RlithEvents...

LockingUnlocking a Layer

You can't select or edit entities on locked layers. However, the objects are still visible as long as the layer is on and thawed, and you can still use them in object snap selection, acting as an aid to the creation and modification of entities on other layers. Although you can't edit or select entities on a locked layer, you may add new entities to it. This feature can be very useful when you create an overlay or for reference data. Locking a layer doesn't preclude you from altering its on...

SecurityParams Object

The SecurityParams object stores settings for drawing security. The SecurityParams object encrypts and digitally signs drawing files. The object properties included provide information about cryptography providers and other settings for drawing security. Additional information about cryptography providers is available on MSDN http msdn.microsoft.com . Action Long Gets or sets the desired security operation to be performed. Use one or more of the following constants for drawing encryption,...

Adding New Menu Items

You can add a new item, represented by a PopupMenuItem object, to a menu through the AddMenuItem method of the PopupMenu object. Set PopupMenuItemObject PopupMenuObject.AddMenuItem Index, Label, Macro Table 16-9 shows the AddMenuItem method's parameters. Table 16-9. The AddMenuItem Method's Parameters Table 16-9. The AddMenuItem Method's Parameters The position within the menu where the pop-up menu item will be added. It can be either an integer between 0 and N, where N is the number of objects...

AcadLineType Object

The AcadLineType object contains line definitions or components consisting of combinations of dashes, dots, spaces, text, and shapes. You can create default linetypes programmatically only using the Add method of the AcadLinetypes collection. However, you can load an existing linetype definition to your drawing by using the Load method of the AcadLinetypes collection. Although there is no limit to the number of linetypes defined in any one drawing, only one can be active at a time. New objects...

AcadMenuGroup Object

The AcadMenuGroup object represents an AutoCAD menu group, which contains menus and toolbars, some or all of which may be currently displayed in AutoCAD. Each menu group contains an AcadPopupMenus collection and an AcadToolbars collection. The former collection contains all the menus within the menu group and can be accessed through the Menus property. The latter contains all the toolbars within the menu group and can be accessed through the Toolbars property. Menu groups are loaded into the...

AcadDSolid Object

The Acad3DSolid object represents a solid object with free-form surface support. You don't create general Acad3DSolid objects, as there's no Add3DSolid method supported by the AcadBlock, AcadModelSpace, and AcadPaperSpace objects. Instead, you use this object to represent a whole series of 3-D shapes for which no specific AutoCAD object exists boxes, cones, cylinders, spheres, wedges, tori donuts , and others. You can then combine these shapes to create more complex solids by joining or...

Using the Leader Object

A Leader object consists of an arrowhead attached to a spline or to straight-line segments. You can use this object to associate text with a drawing object. To add a Leader object to your drawing, use the AddLeader method. Set LeaderObject Object.AddLeader PointsArray, Annotationtype, ArrowType Table 11-21 shows the AddLeader method's parameters. Table 11-21. The AddLeader Method's Parameters Table 11-21. The AddLeader Method's Parameters A three-element array of doubles specifying the 3-D WCS...

Getting and Setting the

The AutoSaveInterval property is a positive integer value representing the number of whole minutes between automatic saves. The timer for automatic saves starts as soon as you make a change to the current drawing. Setting the AutoSaveInterval property to 0 zero means that you'll never get an automatic save operation. The maximum value allowed for the AutoSaveInterval property is 600 minutes. The default value that AutoCAD uses for the time between automatic saves is 120 minutes. You can do a...

Note AutoCAD creates certain blocks for its own purposes such as the special

The following example deletes a block based on user input. Try it on some blocks created with the AddBlock code sample. In general, whenever you delete a collection member, such a block definition, execute a purge to clean up your drawing database. You'll see that you can't delete the block definition until you remove all the block references. Public Sub DeleteBlock Dim strName As String Dim objBlock As AcadBlock On Error Resume Next ' handle exceptions inline strName InputBox Block name to...

AcadDimStyle Object

The AcadDimStyle object represents a group of dimension settings that determine the appearance of new dimensions created in the drawing. It is created by the Add method of the AcadDimStyles collection and is activated through the ActiveDimStyle property of the Document object. To change the style of a dimension, use the StyleName property found on the dimension. To control the settings of the current document overrides, use the dimensioning system variables. When you change a dimensioning...

Controlling Plot Parameters

A number of parameters are normally set using the Plot dialog box shown in Figure 15-4. AutoCAD provides a means to control these settings programmatically. In this section I cover the options that are most commonly modified. All the methods and properties for controlling the plot parameters are available to both the PlotConfiguration and Layout objects. Consequently, when I present the syntax in the following sections, I use the word object to denote either object. You can read or set the...

The MenuGroup Object

Once you've loaded a menu group, its corresponding MenuGroup object is added to the Menu-Groups collection. A MenuGroup object contains two collections, PopupMenus and Toolbars. All the menus within a menu group are members of the PopupMenus collection, and all the toolbars are members of the Toolbars collection. You access these two collections via the Menus and Toolbars properties of the MenuGroup object with the following syntax Set PopupMenusCollection MenuGroupObject.Menus Set...

AcadDocuments Collection

The AcadDocuments collection contains all AutoCAD drawings open in the current session. To add a new member to the collection, use the Add or Open method. To select a specific document, use the Item method. To close all the documents, use the Close method similar to the one found in the AcadDocument object. To close all documents, use the Close method found in this collection. There's no limit to the number of documents you can create in your drawing. However, there can be only one instance of...

AcadDocuments Collection Properties

The AcadDocuments collection supports the common Application property and the Count property but no other properties. AcadDynamicBlockReferenceProperty Object This is an object containing the properties of a dynamic block. Dynamic blocks cannot be created through VBA however, properties of dynamic blocks may be queried. AcadDynamicBlockReferenceProperty Methods The AcadDynamicBlockReferenceProperty object does not support any methods. AcadDynamicBlockReferenceProperty Properties The...

Renaming a Block Object

To rename a block definition, assign a new string value to its Name property. Block references to the block definition are automatically adjusted. Take care to address other possible exceptions that may be thrown, such as an invalid name, existing name, and so on. Note Renaming an AutoCAD-defined layout block or any anonymous block, which is a block whose name begins with an asterisk , may crash AutoCAD. The following example renames a Block definition based on user input Public Sub RenameBlock...

Description App

Gets or sets whether alternative units dimensioning is enabled. It overrides the value of the DIMALT system variable. Gets or sets the units format for alternative units. The initial value for this property is acDimDecimal. It overrides the value of the DIMALTU system variable. For a list of possible values for the AcDimUnits enumerated type, see Appendix B. Gets or sets the number of decimal places in alternative units. It overrides the value of the DIMALTD system variable. For a list of...

AcadCircle Object Properties

The AcadCircle object inherits all the properties of the AcadEntity and AcadObject objects, as well as the common Application property. It also supports the following properties. Gets the area of the circle in square drawing units. This property's value is read-only. Gets or sets the center of the circle as a set of 3-D coordinates. Gets or sets the circumference of the circle. Gets or sets the diameter of the circle. Gets or sets the 3-D Z-axis normal unit vector for the object. Gets or sets...