Introduction

Topics in this section

  • About the AutoCAD ActiveX Technology

    AutoCAD® ActiveX® enables you to manipulate AutoCAD programmatically from within or outside AutoCAD.

  • About the AutoCAD Visual Basic for Applications Interface

    Microsoft VBA is an object-oriented programming environment designed to provide rich development capabilities similar to those of VB.NET.

  • About Using AutoCAD ActiveX and VBA Together

    The AutoCAD ActiveX/VBA interface represents several advantages over other AutoCAD API environments.

  • About the Organization of the ActiveX Documentation

    The ActiveX related information is primarily written for those developing VBA applications for use with AutoCAD.

  • About Sample Code

    The ActiveX Developer and Reference topics contain over 800 example VBA subroutines that demonstrate the usage of ActiveX methods, properties, and events.

  • About Migrating Automation Projects

    In general, an AutoCAD automation project created in the VBA IDE or created with Visual Studio might require some updates before it can be used in AutoCAD 2015.

  • About the ActiveX API History

    There have been a number of changes to the AutoCAD ActiveX API since its first introduction with AutoCAD R14.

Please send us your comment about this page


About the AutoCAD ActiveX Technology (ActiveX)

AutoCAD® ActiveX® enables you to manipulate AutoCAD programmatically from within or outside AutoCAD.

It does this by exposing AutoCAD objects to the “outside world.” Once these objects are exposed, they can be accessed by many different programming languages and environments and by other applications such as Microsoft® Word VBA or Excel VBA.

There are two advantages to implementing an ActiveX interface for AutoCAD:

  • Programmatic access to AutoCAD drawings is opened up to many more programming environments. Before ActiveX Automation, developers were limited to an AutoLISP® or C++ interface.
  • Sharing data with other Windows® applications, such as Microsoft Excel and Word, is made dramatically easier.

An object is the main building block of any ActiveX application. Each exposed object represents a precise part of AutoCAD. There are many different types of objects in the AutoCAD ActiveX interface. For example:

  • Graphical objects such as lines, arcs, text, and dimensions are objects.
  • Style settings such as linetypes and dimension styles are objects.
  • Organizational structures such as layers, groups, and blocks are objects.
  • The drawing displays such as view and viewport are objects.
  • Even the drawing and the AutoCAD application are considered objects.


About the AutoCAD Visual Basic for Applications Interface (VBA/ActiveX)

Microsoft VBA is an object-oriented programming environment designed to provide rich development capabilities similar to those of VB.NET.

The main difference between VBA and VB is that VBA runs in the same process space as AutoCAD, providing an AutoCAD-intelligent and very fast programming environment.

VBA also provides application integration with other VBA-enabled applications. This means that AutoCAD, using other application object libraries, can be an Automation controller for other applications such as Microsoft Word or Excel.

The standalone development editions of VB.NET, which must be purchased separately, complement AutoCAD VBA with additional components, such as an external database engine and report-writing capabilities.

There are four advantages to implementing VBA for AutoCAD:

  • VBA and its environment are easy to learn and use.
  • VBA runs in-process with AutoCAD. This translates to very fast program execution.
  • Dialog box construction is quick and effective. This allows developers to prototype applications and quickly receive feedback on designs.
  • Projects can be standalone or embedded in drawings. This choice allows developers great flexibility in the distribution of their applications.

Topics in this section

  • About How VBA Is Implemented in AutoCAD (VBA/ActiveX)

    VBA sends messages to AutoCAD by the AutoCAD ActiveX Automation interface.


About the AutoCAD Visual Basic for Applications Interface (VBA/ActiveX)
About the AutoCAD Visual Basic for Applications Interface (VBA/ActiveX)
About Using ActiveX Automation with the Microsoft .NET Framework (ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Introduction > About the AutoCAD Visual Basic for Applications Interface (VBA/ActiveX) >

About How VBA Is Implemented in AutoCAD (VBA/ActiveX)

VBA sends messages to AutoCAD by the AutoCAD ActiveX Automation interface.

AutoCAD VBA permits the VBA environment to run simultaneously with AutoCAD and provides programmatic control of AutoCAD through the ActiveX Automation interface. This coupling of AutoCAD, ActiveX Automation, and VBA provides an extremely powerful interface not only for manipulating AutoCAD objects, but for sending data to or retrieving data from other applications.

There are three fundamental elements that define ActiveX and VBA programming in AutoCAD. The first is AutoCAD itself, which has a rich set of objects that encapsulates AutoCAD entities, data, and commands. Because AutoCAD was designed as an open-architecture application with multiple levels of interface, familiarity with AutoCAD programmability is highly desirable in order to use VBA effectively. If you've used AutoLISP to control AutoCAD programmatically, you already have a good understanding of the AutoCAD facilities. However, you will find the VBA object-based approach to be quite different from that of AutoLISP.

The second element is the AutoCAD ActiveX Automation interface, which establishes messages (communication) with AutoCAD objects. Programming in VBA requires a fundamental understanding of ActiveX Automation. A description of the AutoCAD ActiveX Automation interface can be found in the ActiveX and VBA Reference. Even the experienced VB programmer will find the AutoCAD ActiveX Automation interface invaluable for understanding and developing AutoCAD VBA applications.

The third element is the VBA programming environment, which has its own set of objects, keywords, constants, and so forth that provides program flow, control, debugging, and execution. Microsoft's own extensive Help for VBA is included with the AutoCAD VBA Help and is accessible from the VBA IDE by any of the following methods:

  • Pressing F1 on the keyboard
  • Choosing Help from the VBA IDE menu bar
  • Clicking the Question Mark icon on the VBA IDE toolbar

Topics in this section

  • About Using ActiveX Automation with the Microsoft .NET Framework (ActiveX)

    AutoCAD automation objects can be accessed from projects created with Microsoft Visual Studio.

  • FAQ: Why does my VBA project no longer run correctly? (VBA/ActiveX)

    If you install, reinstall, or uninstall Microsoft Office or other VBA enabled applications after installing AutoCAD, reinstall the AutoCAD VBA extension and reboot your system.


About How VBA Is Implemented in AutoCAD (VBA/ActiveX)
About How VBA Is Implemented in AutoCAD (VBA/ActiveX)
FAQ: Why does my VBA project no longer run correctly? (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Introduction > About the AutoCAD Visual Basic for Applications Interface (VBA/ActiveX) > About How VBA Is Implemented in AutoCAD (VBA/ActiveX) >

About Using ActiveX Automation with the Microsoft .NET Framework (ActiveX)

AutoCAD automation objects can be accessed from projects created with Microsoft® Visual Studio®.

To fully access AutoCAD automation objects from Microsoft Visual Studio® .NET, create references to the following files:

  • The AutoCAD 2015 type library, acax20enu.tlb, located at C:\Program Files\Common Files\Autodesk Shared.
  • The AutoCAD/ObjectDBX Common 20.0 type library, axdb20enu.tlb, located at C:\Program Files\Common Files\Autodesk Shared.

These references will make available the following primary interop assemblies:

  • Autodesk.AutoCAD.Interop.dll (for AutoCAD-specific types and Autodesk)
  • AutoCAD.Interop.Common.dll (for types shared by ObjectDBX™ host applications)

The interop assemblies are located in the global assembly cache; they map automation objects to .NET counterparts.

After you reference the type libraries, you can declare AutoCAD-based variables in Microsoft Visual Studio .NET, as in the following examples:

Dim objAcad As Autodesk.AutoCAD.Interop.AcadApplication
Dim objLine As Autodesk.AutoCAD.Interop.Common.AcadLine

You can load a .NET application using the NETLOAD command in AutoCAD.

Additional information about using a .NET application with AutoCAD is available from the Developer Center section of the Autodesk website.


About Using ActiveX Automation with the Microsoft .NET Framework (ActiveX)
About How VBA Is Implemented in AutoCAD (VBA/ActiveX)
About Using AutoCAD ActiveX and VBA Together (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Introduction > About the AutoCAD Visual Basic for Applications Interface (VBA/ActiveX) > About How VBA Is Implemented in AutoCAD (VBA/ActiveX) >

FAQ: Why does my VBA project no longer run correctly? (VBA/ActiveX)

If you install, reinstall, or uninstall Microsoft Office or other VBA enabled applications after installing AutoCAD, reinstall the AutoCAD VBA extension and reboot your system.


About Using AutoCAD ActiveX and VBA Together (VBA/ActiveX)

The AutoCAD ActiveX/VBA interface represents several advantages over other AutoCAD API environments.

The advantages that the AutoCAD ActiveX/VBA interface offer are:

  • Speed. Running in-process with VBA, ActiveX applications are faster than AutoLISP applications.
  • Ease of Use. The programming language and development environment are easy to use and come installed with AutoCAD.
  • Windows Interoperability. ActiveX and VBA are designed to be used with other Windows applications and provide an excellent path for communication of information across applications.
  • Rapid Prototyping. The rapid interface development of VBA provides the perfect environment for prototyping applications, even if those applications will -eventually be developed in another language.
  • Programmer Base. AutoCAD ActiveX and VBA technology provide Visual Basic and VB.NET programmers with the ability to customize AutoCAD and develop applications for it.


About the Organization of the ActiveX Documentation (ActiveX)

The ActiveX related information is primarily written for those developing VBA applications for use with AutoCAD.

The ActiveX topics assume that you have prior working knowledge of the Visual Basic programming language, and does not attempt to duplicate or replace the abundance of documentation available on the Internet or in books. If you need more information on the Visual Basic and VB.NET programming languages or development environment usage, see the Visual Basic for Applications Help file or the Visual Studio Help system developed by Microsoft, available from the Help menus in the interactive development environments (IDEs).

If you are using ActiveX with a development environment other than VBA and a programming language other than VB or VB.NET, you will need to adapt the information and example code that is presented.


About Sample Code (VBA/ActiveX)

The ActiveX Developer and Reference topics contain over 800 example VBA subroutines that demonstrate the usage of ActiveX methods, properties, and events.

There are also many sample applications provided in the AutoCAD Sample directory. These sample applications show a wide range of functionality, from extracting AutoCAD drawing data into Microsoft Excel spreadsheets to drawing and performing stress analysis on an electrical transmission tower.

These samples also show how to combine the versatility of the Visual Basic for Applications programming environment with the power of the AutoCAD ActiveX interface to create customized applications.

Additionally, example code in the ActiveX Developer and Reference topics can be copied from the Help files, pasted directly into the AutoCAD VBA environment, and then executed with one requirement: the current active drawing in AutoCAD must be a blank drawing open to model space.

Topics in this section

  • To run the examples from the AutoCAD Help system (VBA/ActiveX)

    Explains how to run VBA sample code that is part of the AutoCAD Help system.


To run the examples from the AutoCAD Help system (VBA/ActiveX)

Explains how to run VBA sample code that is part of the AutoCAD Help system.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Visual Basic Editor.
  2. Copy the example code from the Help topic, and paste it into an empty VBA code module or the ThisDrawing class module.
  3. Verify that AutoCAD has a blank drawing open to model space.
  4. At the AutoCAD Command prompt, enter vbaman and press Enter.
  5. In the Macros dialog box, choose the macro and click Run.


About Migrating Automation Projects (VBA/ActiveX)

In general, an AutoCAD automation project created in the VBA IDE or created with Visual Studio might require some updates before it can be used in AutoCAD 2015.

AutoCAD 2015 automation projects use a new type library (acax20enu.tlb). The type library is located in C:\Program Files\Common Files\Autodesk Shared.

AutoCAD 2015 automation projects also use a new version-dependent ProgID for the CreateObject, GetObject, and GetInterfaceObject methods. For example, if you are using the CreateObject function in an AutoCAD automation project, you use CreateObject("AutoCAD.Application.20") to create an instance of AutoCAD 2015. Use CreateObject("AutoCAD.Application") to create an instance of the most recently executed AutoCAD or AutoCAD-based product if more than one product is installed.

New Objects

No new objects were added.

Changed Objects

The following table describes the changes made to existing objects.

AutoCAD 2014 | AutoCAD 2015 | Description of change
IAcadApplication IAcadDatabase IAcadDocument IAcadIDPair IAcadMLeader IAcadObject IAcadPViewport IAcadTable IAcadTableStyle IAcadUtility IAcadView | IAcadApplication IAcadDatabase IAcadDocument IAcadIDPair IAcadMLeader IAcadObject IAcadPViewport IAcadTable IAcadTableStyle IAcadUtility IAcadView | Methods and properties specific to Windows 64-bit are now obsolete and no longer available. Replace the obsolete method or property.

32-bit Projects on Windows 64-bit

Starting with AutoCAD 2014, AutoCAD uses VBA 7.1 which offers native 64-bit support. Earlier releases of AutoCAD 64-bit used and executed VBA 32-bit in an external process which caused performance issues. Projects developed for earlier releases require some considerations to work correctly with AutoCAD 2014. You need to take the following into consideration when migrating VBA projects from an earlier release:

  • No changes needed if you only need to support your project on Windows 32-bit.
  • Separate projects need to be maintained for Windows 32-bit and Windows 64-bit because not all API libraries are available on both platforms. You can export and import code and class modules to share code between multiple projects.
  • Controls used on forms originally created for Windows 32-bit might need to be updated or replaced with a 64-bit alterative to execute correctly on Windows 64-bit.
  • Methods and properties created specifically to allow VBA 32-bit to work with AutoCAD 64-bit are now obsolete and have been removed. Replace the use of the obsolete method and property with the correct method and property, often removing "32" from the name of the method or property is enough.


About the ActiveX API History (ActiveX)

There have been a number of changes to the AutoCAD ActiveX API since its first introduction with AutoCAD R14.

Use the following topics for a full history of the additions, changes, and removals made to the ActiveX API.

Topics in this section

  • AutoCAD 2000 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2000 and AutoCAD 2000-based products.

  • AutoCAD 2000i API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2000i and AutoCAD 2000i-based products.

  • AutoCAD 2002 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2002 and AutoCAD 2002-based products.

  • AutoCAD 2004 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2004 and AutoCAD 2004-based products.

  • AutoCAD 2005 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2005 and AutoCAD 2005-based products.

  • AutoCAD 2006 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2006 and AutoCAD 2006-based products.

  • AutoCAD 2007 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2007 and AutoCAD 2007-based products.

  • AutoCAD 2008 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2008 and AutoCAD 2008-based products.

  • AutoCAD 2009 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2009 and AutoCAD 2009-based products.

  • AutoCAD 2010 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2010 and AutoCAD 2010-based products.

  • AutoCAD 2011 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2011 and AutoCAD 2011-based products.

  • AutoCAD 2012 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2012 and AutoCAD 2012-based products.

  • AutoCAD 2013 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2013 and AutoCAD 2013-based products.

  • AutoCAD 2014 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2014 and AutoCAD 2014-based products.

  • AutoCAD 2015 API History Reference (ActiveX)

    Additions and changes made to the ActiveX API in AutoCAD 2015 and AutoCAD 2015-based products.


AutoCAD 2000 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2000 and AutoCAD 2000-based products.

Constants

The following have been removed:

AutoCADConstants
        acTrue = 1;
        acFalse = 0;
        acOn = 1;
        acOff = 0;
        ac3dFace = 1;
        ac3dPolyline = 2;
        ac3dSolid = 3;
        acArc = 4;
        acAttribute = 5;
        acAttributeReference = 6;
        acBlockReference = 7;
        acCircle = 8;
        acDimAligned = 9;
        acDimAngular = 10;
        acDimDiametric = 12;
        acDimOrdinate = 13;
        acDimRadial = 14;
        acDimRotated = 15;
        acEllipse = 16;
        acHatch = 17;
        acLeader = 18;
        acLine = 19;
        acMtext = 21;
        acPoint = 22;
        acPolyline = 23;
        acPolylineLight = 24;
        acPolymesh = 25;
        acRaster = 26;
        acRay = 27;
        acRegion = 28;
        acShape = 29;
        acSolid = 30;
        acSpline = 31;
        acText = 32;
        acTolerance = 33;
        acTrace = 34;
        acPViewport = 35;
        acXline = 36;
        acGroup = 37;
        acModelSpace = 1;
        acPaperSpace = 0;
        acPreferenceClassic = 0;
        acPreferenceCustom = 1;
        acPlotOrientationPortrait = 0;
        acPlotOrientationLandscape = 1;
        acByBlock = 0;
        acRed = 1;
        acYellow = 2;
        acGreen = 3;
        acCyan = 4;
        acBlue = 5;
        acMagenta = 6;
        acWhite = 7;
        acByLayer = 256;
        acAttachmentPointTopLeft = 1;
        acAttachmentPointTopCenter = 2;
        acAttachmentPointTopRight = 3;
        acAttachmentPointMiddleLeft = 4;
        acAttachmentPointMiddleCenter = 5;
        acAttachmentPointMiddleRight = 6;
        acAttachmentPointBottomLeft = 7;
        acAttachmentPointBottomCenter = 8;
        acAttachmentPointBottomRight = 9;
        acLeftToRight = 1;
        acRightToLeft = 2;
        acTopToBottom = 3;
        acBottomToTop = 4;
        acLineNoArrow = 0;
        acSplineNoArrow = 1;
        acLineWithArrow = 2;
        acSplineWithArrow = 3;
        acAttributeModeInvisible = 1;
        acAttributeModeConstant = 2;
        acAttributeModeVerify = 4;
        acAttributeModePreset = 8;
        acHorizontalAlignmentLeft = 0;
        acHorizontalAlignmentCenter = 1;
        acHorizontalAlignmentRight = 2;
        acHorizontalAlignmentAligned = 3;
        acHorizontalAlignmentMiddle = 4;
        acHorizontalAlignmentFit = 5;
        acVerticalAlignmentBaseline = 0;
        acVerticalAlignmentBottom = 1;
        acVerticalAlignmentMiddle = 2;
        acVerticalAlignmentTop = 3;
        acTextFlagBackward = 2;
        acTextFlagUpsideDown = 4;
        acSelectionSetWindow = 0;
        acSelectionSetCrossing = 1;
        acSelectionSetFence = 2;
        acSelectionSetPrevious = 3;
        acSelectionSetLast = 4;
        acSelectionSetAll = 5;
        acSelectionSetWindowPolygon = 6;
        acSelectionSetCrossingPolygon = 7;
        acHatchPatternTypeUserDefined = 0;
        acHatchPatternTypePreDefined = 1;
        acHatchPatternTypeCustomDefined = 2;
        acHatchLoopTypeDefault = 0;
        acHatchLoopTypeExternal = 1;
        acHatchLoopTypePolyline = 2;
        acHatchLoopTypeDerived = 4;
        acHatchLoopTypeTextbox = 8;
        acHatchStyleNormal = 0;
        acHatchStyleOuter = 1;
        acHatchStyleIgnore = 2;
        acOsnapEnd = 1;
        acOsnapMid = 2;
        acOsnapCenter = 3;
        acOsnapNode = 4;
        acOsnapQuadrant = 5;
        acOsnapInsert = 6;
        acOsnapPerpendicular = 7;
        acOsnapTangent = 8;
        acOsnapNear = 9;
        acSimplePoly = 0;
        acFitCurvePoly = 1;
        acQuadSplinePoly = 2;
        acCubicSplinePoly = 3;
        acViewport2Horizontal = 0;
        acViewport2Vertical = 1;
        acViewport3Left = 2;
        acViewport3Right = 3;
        acViewport3Horizontal = 4;
        acViewport3Vertical = 5;
        acViewport3Above = 6;
        acViewport3Below = 7;
        acViewport4 = 8;
        acActiveViewport = 0;
        acAllViewports = 1;
        acAmericanEnglish = "enu";
        acAustralianEnglish = "ena";
        acBritishEnglishIse = "ens";
        acBritishEnglishIze = "enz";
        acCatalan = "ca";
        acCzech = "cs";
        acDanish = "da";
        acDutchPrim = "nl";
        acDutchSec = "nls";
        acFinnish = "fi";
        acFrenchUnaccentCap = "fr";
        acFrenchAccentCap = "fra";
        acGermanScharfesS = "de";
        acGermanDoppleS = "ded";
        acItalian = "it";
        acNorwegianBokmal = "no";
        acNorwegianNynorsk = "non";
        acPortugueseIberian = "pt";
        acPortugueseBrazilian = "ptb";
        acRussianInfrequentIo = "ru";
        acRussianFrequentIo = "rui";
        acSpanishUnaccentCap = "es";
        acSpanishAccentCap = "esa";
        acSwedish = "sv";
        acUnion = 0;
        acIntersection = 1;
        acSubtraction = 2;
        acExtendNone = 0;
        acExtendThisEntity = 1;
        acExtendOtherEntity = 2;
        acExtendBoth = 3;
        acDegrees = 0;
        acDegreeMinuteSeconds = 1;
        acGrads = 2;
        acRadians = 3;
        acSurveyorUnits = 4;
        acScientific = 1;
        acDecimal = 2;
        acEngineering = 3;
        acArchitectural = 4;
        acFractional = 5;
        acWorld = 0;
        acUCS = 1;
        acDisplayDCS = 2;
        acPaperSpaceDCS = 3;
        acEnglish = 0;
        acMetric = 1;
        acDemandLoadDisabled = 0;
        acDemandLoadEnabled = 1;
        acDemandLoadEnabledWithCopy = 2;
        acPartialPreview = 0;
        acFullPreview = 1;
        acSimpleMesh = 0;
        acQuadSurfaceMesh = 5;
        acCubicSurfaceMesh = 6;
        acBezierSurfaceMesh = 8;
        acZoomScaledAbsolute = 0;
        acZoomScaledRelative = 1;
        acZoomScaledRelativePSpace = 2;
        acDragDoNotDisplay = 0;
        acDragDisplayOnRequest = 1;
        acDragDisplayAutomatically = 2;
        acDemanLoadDisable = 0;
        acDemandLoadOnObjectDetect = 1;
        acDemandLoadCmdInvoke = 2;
        acFontRegular = 0;
        acFontItalic = 1;
        acFontBold = 2;
        acFontBoldItalic = 3;
        acProxyNotShow = 0;
        acProxyShow = 1;
        acProxyBoundingBox = 2;
        acKeyboardRunningObjSnap = 0;
        acKeyboardEntry = 1;
        acKeyboardProxyNoScripts = 2;

Enums

AcBoolean (New)
        acFalse = 0
        acTrue = 1
AcOnOff (New)
        acOff = 0
        acOn = 1
AcEntityName (New)
        ac3dFace = 1
        ac3dPolyline = 2
        ac3dSolid = 3
        acArc = 4
        acAttribute = 5
        acAttributeReference = 6
        acBlockReference = 7
        acCircle = 8
        acDimAligned = 9
        acDimAngular = 10
        acDimDiametric = 12
        acDimOrdinate = 13
        acDimRadial = 14
        acDimRotated = 15
        acEllipse = 16
        acHatch = 17
        acLeader = 18
        acLine = 19
        acMtext = 21
        acPoint = 22
        acPolyline = 23
        acPolylineLight = 24
        acPolymesh = 25
        acRaster = 26
        acRay = 27
        acRegion = 28
        acShape = 29
        acSolid = 30
        acSpline = 31
        acText = 32
        acTolerance = 33
        acTrace = 34
        acPViewport = 35
        acXline = 36
        acGroup = 37
        acMInsertBlock = 38
        acPolyfaceMesh = 39
        acMLine = 40
        acDim3PointAngular = 41
        acExternalReference = 42
AcActiveSpace (New)
        acPaperSpace = 0
        acModelSpace = 1
AcKeyboardAccelerator (New)
        acPreferenceClassic = 0
        acPreferenceCustom = 1
AcPlotOrientation (New)
        acPlotOrientationPortrait = 0
        acPlotOrientationLandscape = 1
AcColor (New)
        acByBlock = 0
        acRed = 1
        acYellow = 2
        acGreen = 3
        acCyan = 4
        acBlue = 5
        acMagenta = 6
        acWhite = 7
        acByLayer = 256
AcAttachmentPoint (New)
        acAttachmentPointTopLeft = 1
        acAttachmentPointTopCenter = 2
        acAttachmentPointTopRight = 3
        acAttachmentPointMiddleLeft = 4
        acAttachmentPointMiddleCenter = 5
        acAttachmentPointMiddleRight = 6
        acAttachmentPointBottomLeft = 7
        acAttachmentPointBottomCenter = 8
        acAttachmentPointBottomRight = 9
AcDrawingDirection (New)
        acLeftToRight = 1
        acRightToLeft = 2
        acTopToBottom = 3
        acBottomToTop = 4
        acByStyle = 5
AcLeaderType (New)
        acLineNoArrow = 0
        acSplineNoArrow = 1
        acLineWithArrow = 2
        acSplineWithArrow = 3
AcAttributeMode (New)
        acAttributeModeNormal = 0
        acAttributeModeInvisible = 1
        acAttributeModeConstant = 2
        acAttributeModeVerify = 4
        acAttributeModePreset = 8
AcHorizontalAlignment (New)
        acHorizontalAlignmentLeft = 0
        acHorizontalAlignmentCenter = 1
        acHorizontalAlignmentRight = 2
        acHorizontalAlignmentAligned = 3
        acHorizontalAlignmentMiddle = 4
        acHorizontalAlignmentFit = 5
AcVerticalAlignment (New)
        acVerticalAlignmentBaseline = 0
        acVerticalAlignmentBottom = 1
        acVerticalAlignmentMiddle = 2
        acVerticalAlignmentTop = 3
AcTextGenerationFlag (New)
        acTextFlagBackward = 2
        acTextFlagUpsideDown = 4
AcSelect (New)
        acSelectionSetWindow = 0
        acSelectionSetCrossing = 1
        acSelectionSetFence = 2
        acSelectionSetPrevious = 3
        acSelectionSetLast = 4
        acSelectionSetAll = 5
        acSelectionSetWindowPolygon = 6
        acSelectionSetCrossingPolygon = 7
AcPatternType (New)
        acHatchPatternTypeUserDefined = 0
        acHatchPatternTypePreDefined = 1
        acHatchPatternTypeCustomDefined = 2
AcLoopType (New)
        acHatchLoopTypeDefault = 0
        acHatchLoopTypeExternal = 1
        acHatchLoopTypePolyline = 2
        acHatchLoopTypeDerived = 4
        acHatchLoopTypeTextbox = 8
AcHatchStyle (New)
        acHatchStyleNormal = 0
        acHatchStyleOuter = 1
        acHatchStyleIgnore = 2
AcPolylineType (New)
        acSimplePoly = 0
        acFitCurvePoly = 1
        acQuadSplinePoly = 2
        acCubicSplinePoly = 3
Ac3DPolylineType (New)
        acSimple3DPoly = 0
        acQuadSpline3DPoly = 1
        acCubicSpline3DPoly = 2
AcViewportSplitType (New)
        acViewport2Horizontal = 0
        acViewport2Vertical = 1
        acViewport3Left = 2
        acViewport3Right = 3
        acViewport3Horizontal = 4
        acViewport3Vertical = 5
        acViewport3Above = 6
        acViewport3Below = 7
        acViewport4 = 8
AcRegenType (New)
        acActiveViewport = 0
        acAllViewports = 1
AcBooleanType (New)
        acUnion = 0
        acIntersection = 1
        acSubtraction = 2
AcExtendOption (New)
        acExtendNone = 0
        acExtendThisEntity = 1
        acExtendOtherEntity = 2
        acExtendBoth = 3
AcAngleUnits (New)
        acDegrees = 0
        acDegreeMinuteSeconds = 1
        acGrads = 2
        acRadians = 3
AcUnits (New)
        acDefaultUnits = 0xffffffff
        acScientific = 1
        acDecimal = 2
        acEngineering = 3
        acArchitectural = 4
        acFractional = 5
AcCoordinateSystem (New)
        acWorld = 0
        acUCS = 1
        acDisplayDCS = 2
        acPaperSpaceDCS = 3
        acOCS = 4
AcMeasurementUnits (New)
        acEnglish = 0
        acMetric = 1
AcXRefDemandLoad (New)
        acDemandLoadDisabled = 0
        acDemandLoadEnabled = 1
        acDemandLoadEnabledWithCopy = 2
AcPreviewMode (New)
        acPartialPreview = 0
        acFullPreview = 1
AcPolymeshType (New)
        acSimpleMesh = 0
        acQuadSurfaceMesh = 5
        acCubicSurfaceMesh = 6
        acBezierSurfaceMesh = 8
AcZoomScaleType (New)
        acZoomScaledAbsolute = 0
        acZoomScaledRelative = 1
        acZoomScaledRelativePSpace = 2
AcDragDisplayMode (New)
        acDragDoNotDisplay = 0
        acDragDisplayOnRequest = 1
        acDragDisplayAutomatically = 2
AcARXDemandLoad (New)
        acDemanLoadDisable = 0
        acDemandLoadOnObjectDetect = 1
        acDemandLoadCmdInvoke = 2
AcTextFontStyle (New)
        acFontRegular = 0
        acFontItalic = 1
        acFontBold = 2
        acFontBoldItalic = 3
AcProxyImage (New)
        acProxyNotShow = 0
        acProxyShow = 1
        acProxyBoundingBox = 2
AcKeyboardPriority (New)
        acKeyboardRunningObjSnap = 0
        acKeyboardEntry = 1
        acKeyboardEntryExceptScripts = 2
AcMenuGroupType (New)
        acBaseMenuGroup = 0
        acPartialMenuGroup = 1
AcMenuFileType (New)
        acMenuFileCompiled = 0
        acMenuFileSource = 1
AcMenuItemType (New)
        acMenuItem = 0
        acMenuSeparator = 1
        acMenuSubMenu = 2
AcToolbarItemType (New)
        acToolbarButton = 0
        acToolbarSeparator = 1
        acToolbarControl = 2
        acToolbarFlyout = 3
AcToolbarDockStatus (New)
        acToolbarDockTop = 0
        acToolbarDockBottom = 1
        acToolbarDockLeft = 2
        acToolbarDockRight = 3
        acToolbarFloating = 4
AcLineWeight (New)
        acLnWt000 = 0
        acLnWt005 = 5
        acLnWt009 = 9
        acLnWt013 = 13
        acLnWt015 = 15
        acLnWt018 = 18
        acLnWt020 = 20
        acLnWt025 = 25
        acLnWt030 = 30
        acLnWt035 = 35
        acLnWt040 = 40
        acLnWt050 = 50
        acLnWt053 = 53
        acLnWt060 = 60
        acLnWt070 = 70
        acLnWt080 = 80
        acLnWt090 = 90
        acLnWt100 = 100
        acLnWt106 = 106
        acLnWt120 = 120
        acLnWt140 = 140
        acLnWt158 = 158
        acLnWt200 = 200
        acLnWt211 = 211
        acLnWtByLayer = 0xffffffff
        acLnWtByBlock = 0xfffffffe
        acLnWtByLwDefault = 0xfffffffd
AcWindowState (New)
        acNorm = 1
        acMin = 2
        acMax = 3
AcPlotPaperUnits (New)
        acInches = 0
        acMillimeters = 1
        acPixels = 2
AcPlotRotation (New)
        ac0degrees = 0
        ac90degrees = 1
        ac180degrees = 2
        ac270degrees = 3
AcPlotType (New)
        acDisplay = 0
        acExtents = 1
        acLimits = 2
        acView = 3
        acWindow = 4
        acLayout = 5
AcPlotScale (New)
        acScaleToFit = 0
        ac1_128in_1ft = 1
        ac1_64in_1ft = 2
        ac1_32in_1ft = 3
        ac1_16in_1ft = 4
        ac3_32in_1ft = 5
        ac1_8in_1ft = 6
        ac3_16in_1ft = 7
        ac1_4in_1ft = 8
        ac3_8in_1ft = 9
        ac1_2in_1ft = 10
        ac3_4in_1ft = 11
        ac1in_1ft = 12
        ac3in_1ft = 13
        ac6in_1ft = 14
        ac1ft_1ft = 15
        ac1_1 = 16
        ac1_2 = 17
        ac1_4 = 18
        ac1_8 = 19
        ac1_10 = 20
        ac1_16 = 21
        ac1_20 = 22
        ac1_30 = 23
        ac1_40 = 24
        ac1_50 = 25
        ac1_100 = 26
        ac2_1 = 27
        ac4_1 = 28
        ac8_1 = 29
        ac10_1 = 30
        ac100_1 = 31
AcAlignment (New)
        acAlignmentLeft = 0
        acAlignmentCenter = 1
        acAlignmentRight = 2
        acAlignmentAligned = 3
        acAlignmentMiddle = 4
        acAlignmentFit = 5
        acAlignmentTopLeft = 6
        acAlignmentTopCenter = 7
        acAlignmentTopRight = 8
        acAlignmentMiddleLeft = 9
        acAlignmentMiddleCenter = 10
        acAlignmentMiddleRight = 11
        acAlignmentBottomLeft = 12
        acAlignmentBottomCenter = 13
        acAlignmentBottomRight = 14
ACAD_COLOR (New)
ACAD_LAYER (New)
ACAD_LTYPE (New)
ACAD_NULL (New)
ACAD_DISTANCE (New)
ACAD_ANGLE (New)
ACAD_LWEIGHT (New)
ACAD_NOUNITS (New)
ACAD_POINT (New)
AcLineSpacingStyle (New)
        acLineSpacingStyleAtLeast = 1
        acLineSpacingStyleExactly = 2
AcDimPrecision (New)
        acDimPrecisionZero = 0
        acDimPrecisionOne = 1
        acDimPrecisionTwo = 2
        acDimPrecisionThree = 3
        acDimPrecisionFour = 4
        acDimPrecisionFive = 5
        acDimPrecisionSix = 6
        acDimPrecisionSeven = 7
        acDimPrecisionEight = 8
AcDimUnits (New)
        acDimScientific = 1
        acDimDecimal = 2
        acDimEngineering = 3
        acDimArchitecturalStacked = 4
        acDimFractionalStacked = 5
        acDimArchitectural = 6
        acDimFractional = 7
        acDimWindowsDesktop = 8
AcDimLUnits (New)
        acDimLScientific = 1
        acDimLDecimal = 2
        acDimLEngineering = 3
        acDimLArchitectural = 4
        acDimLFractional = 5
        acDimLWindowsDesktop = 6
AcDimArrowheadType (New)
        acArrowDefault = 0
        acArrowClosedBlank = 1
        acArrowClosed = 2
        acArrowDot = 3
        acArrowArchTick = 4
        acArrowOblique = 5
        acArrowOpen = 6
        acArrowOrigin = 7
        acArrowOrigin2 = 8
        acArrowOpen90 = 9
        acArrowOpen30 = 10
        acArrowDotSmall = 11
        acArrowDotBlank = 12
        acArrowSmall = 13
        acArrowBoxBlank = 14
        acArrowBoxFilled = 15
        acArrowDatumBlank = 16
        acArrowDatumFilled = 17
        acArrowIntegral = 18
        acArrowNone = 19
        acArrowUserDefined = 20
AcDimCenterType (New)
        acCenterMark = 0
        acCenterLine = 1
        acCenterNone = 2
AcDimFit (New)
        acTextAndArrows = 0
        acArrowsOnly = 1
        acTextOnly = 2
        acBestFit = 3
AcDimFractionType (New)
        acHorizontal = 0
        acDiagonal = 1
        acNotStacked = 2
AcDimHorizontalJustification (New)
        acHorzCentered = 0
        acFirstExtensionLine = 1
        acSecondExtensionLine = 2
        acOverFirstExtension = 3
        acOverSecondExtension = 4
AcDimVerticalJustification (New)
        acVertCentered = 0
        acAbove = 1
        acOutside = 2
        acJIS = 3
AcDimTextMovement (New)
        acDimLineWithText = 0
        acMoveTextAddLeader = 1
        acMoveTextNoLeader = 2
AcDimToleranceMethod (New)
        acTolNone = 0
        acTolSymmetrical = 1
        acTolDeviation = 2
        acTolLimits = 3
        acTolBasic = 4
AcDimToleranceJustify (New)
        acTolBottom = 0
        acTolMiddle = 1
        acTolTop = 2
AcViewportScale (New)
        acVpScaleToFit = 0
        acVpCustomScale = 1
        acVp1_1 = 2
        acVp1_2 = 3
        acVp1_4 = 4
        acVp1_8 = 5
        acVp1_10 = 6
        acVp1_16 = 7
        acVp1_20 = 8
        acVp1_30 = 9
        acVp1_40 = 10
        acVp1_50 = 11
        acVp1_100 = 12
        acVp2_1 = 13
        acVp4_1 = 14
        acVp8_1 = 15
        acVp10_1 = 16
        acVp100_1 = 17
        acVp1_128in_1ft = 18
        acVp1_64in_1ft = 19
        acVp1_32in_1ft = 20
        acVp1_16in_1ft = 21
        acVp3_32in_1ft = 22
        acVp1_8in_1ft = 23
        acVp3_16in_1ft = 24
        acVp1_4in_1ft = 25
        acVp3_8in_1ft = 26
        acVp1_2in_1ft = 27
        acVp3_4in_1ft = 28
        acVp1in_1ft = 29
        acVp3in_1ft = 30
        acVp6in_1ft = 31
        acVp1ft_1ft = 32
AcISOPenWidth (New)
        acPenWidth013 = 13
        acPenWidth018 = 18
        acPenWidth025 = 25
        acPenWidth035 = 35
        acPenWidth050 = 50
        acPenWidth070 = 70
        acPenWidth100 = 100
        acPenWidth140 = 140
        acPenWidth200 = 200
        acPenWidthUnk = 0xffffffff
AcSaveAsType (New)
        acUnknown = 0xffffffff
        acR12_dxf = 1
        acR13_dwg = 4
        acR13_dxf = 5
        acR14_dwg = 8
        acR14_dxf = 9
        acR15_dwg = 12
        acR15_dxf = 13
        acR15_Template = 14
        acNative = 12
AcPrinterSpoolAlert (New)
        acPrinterAlwaysAlert = 0
        acPrinterAlertOnce = 1
        acPrinterNeverAlertLogOnce = 2
        acPrinterNeverAlert = 3
AcPlotPolicyForNewDwgs (New)
        acPolicyNewDefault = 0
        acPolicyNewLegacy = 1
AcPlotPolicyForLegacyDwgs (New)
        acPolicyLegacyDefault = 0
        acPolicyLegacyQuery = 1
        acPolicyLegacyLegacy = 2
AcOleQuality (New)
        acOQLineArt = 0
        acOQText = 1
        acOQGraphics = 2
        acOQPhoto = 3
        acOQHighPhoto = 4
AcLoadPalette (New)
        acPaletteByDrawing = 0
        acPaletteBySession = 1
AcInsertUnits (New)
        acInsertUnitsUnitless = 0
        acInsertUnitsInches = 1
        acInsertUnitsFeet = 2
        acInsertUnitsMiles = 3
        acInsertUnitsMillimeters = 4
        acInsertUnitsCentimeters = 5
        acInsertUnitsMeters = 6
        acInsertUnitsKilometers = 7
        acInsertUnitsMicroinches = 8
        acInsertUnitsMils = 9
        acInsertUnitsYards = 10
        acInsertUnitsAngstroms = 11
        acInsertUnitsNanometers = 12
        acInsertUnitsMicrons = 13
        acInsertUnitsDecimeters = 14
        acInsertUnitsDecameters = 15
        acInsertUnitsHectometers = 16
        acInsertUnitsGigameters = 17
        acInsertUnitsAstronomicalUnits = 18
        acInsertUnitsLightYears = 19
        acInsertUnitsParsecs = 20
AcAlignmentPointAcquisition (New)
        acAlignPntAcquisitionAutomatic = 0
        acAlignPntAcquisitionShiftToAcquire = 1
AcInsertUnitsAction (New)
        acInsertUnitsPrompt = 0
        acInsertUnitsAutoAssign = 1
AcPlotPolicy (New)
        acPolicyNamed = 0
        acPolicyLegacy = 1
AcDrawingAreaShortCutMenu
        acNoDrawingAreaShortCutMenu = 0
        acUseDefaultDrawingAreaShortCutMenu = 1
AcDrawingAreaSCMDefault
        acRepeatLastCommand = 0
        acSCM = 1
AcDrawingAreaSCMEdit
        acEdRepeatLastCommand = 0
        acEdSCM = 1
AcDrawingAreaSCMCommand
        acEnter = 0
        acEnableSCMOptions = 1
        acEnableSCM = 2

Classes

IAcadObject (Changed)
        Handle - Property
        ObjectName - Property (New)
        Name - Property (Removed)
        GetXData - Method
        SetXData - Method
        Delete - Method (New)
        ObjectID - Property
        Application - Property
        Database - Property (New)
        HasExtensionDictionary - Property (New)
        GetExtensionDictionary - Method (New)
        OwnerID - Property (New)
        Document - Property (New)
IAcadDatabase (New)
        ModelSpace - Property
        PaperSpace - Property
        Blocks - Property
        CopyObjects - Method
        Groups - Property
        DimStyles - Property
        Layers - Property
        Linetypes - Property
        Dictionaries - Property
        RegisteredApplications - Property
        TextStyles - Property
        UserCoordinateSystems - Property
        Views - Property
        Viewports - Property
        ElevationModelSpace - Property
        ElevationPaperSpace - Property
        Limits - Property
        HandleToObject - Method
        ObjectIdToObject - Method
        Layouts - Property
        PlotConfigurations - Property
        Preferences - Property
IAcadModelSpace (Changed)
        Item - Method
        Count - Property
        Name - Property
        Origin - Property (New)
        AddCustomObject - Method
        Add3DFace - Method
        Add3DMesh - Method
        Add3DPoly - Method
        AddArc - Method
        AddAttribute - Method
        AddBox - Method
        AddCircle - Method
        AddCone - Method
        AddCylinder - Method
        AddDimAligned - Method
        AddDimAngular - Method
        AddDimDiametric - Method
        AddDimRotated - Method
        AddDimOrdinate - Method
        AddDimRadial - Method
        AddEllipse - Method
        AddEllipticalCone - Method
        AddEllipticalCylinder - Method
        AddExtrudedSolid - Method
        AddExtrudedSolidAlongPath - Method
        AddLeader - Method
        AddMText - Method
        AddPoint - Method
        AddLightWeightPolyline - Method
        AddPolyline - Method
        AddRay - Method
        AddRegion - Method
        AddRevolvedSolid - Method
        AddShape - Method
        AddSolid - Method
        AddSphere - Method
        AddSpline - Method
        AddText - Method
        AddTolerance - Method
        AddTorus - Method
        AddTrace - Method
        AddWedge - Method
        AddXline - Method
        InsertBlock - Method
        AddHatch - Method
        AddRaster - Method
        AddLine - Method
        IsLayout - Property (New)
        Layout - Property (New)
        IsXRef - Property (New)
        AddMInsertBlock - Method (New)
        AddPolyfaceMesh - Method (New)
        AddMLine - Method (New)
        AddDim3PointAngular - Method (New)
        XRefDatabase - Property (New)
        AttachExternalReference - Method (New)
        Unload - Method (New)
        Reload - Method (New)
        Bind - Method (New)
        Detach - Method (New)
        Handle - Property (Removed)
IAcadBlock (Changed)
        Item - Method
        Count - Property
        Name - Property
        Origin - Property
        AddCustomObject - Method
        Add3DFace - Method
        Add3DMesh - Method
        Add3DPoly - Method
        AddArc - Method
        AddAttribute - Method
        AddBox - Method
        AddCircle - Method
        AddCone - Method
        AddCylinder - Method
        AddDimAligned - Method
        AddDimAngular - Method
        AddDimDiametric - Method
        AddDimRotated - Method
        AddDimOrdinate - Method
        AddDimRadial - Method
        AddEllipse - Method
        AddEllipticalCone - Method
        AddEllipticalCylinder - Method
        AddExtrudedSolid - Method
        AddExtrudedSolidAlongPath - Method
        AddLeader - Method
        AddMText - Method
        AddPoint - Method
        AddLightWeightPolyline - Method
        AddPolyline - Method
        AddRay - Method
        AddRegion - Method
        AddRevolvedSolid - Method
        AddShape - Method
        AddSolid - Method
        AddSphere - Method
        AddSpline - Method
        AddText - Method
        AddTolerance - Method
        AddTorus - Method
        AddTrace - Method
        AddWedge - Method
        AddXline - Method
        InsertBlock - Method
        AddHatch - Method
        AddRaster - Method
        AddLine - Method
        IsLayout - Property (New)
        Layout - Property (New)
        IsXRef - Property (New)
        AddMInsertBlock - Method (New)
        AddPolyfaceMesh - Method (New)
        AddMLine - Method (New)
        AddDim3PointAngular - Method (New)
        XRefDatabase - Property (New)
        AttachExternalReference - Method (New)
        Unload - Method (New)
        Reload - Method (New)
        Bind - Method (New)
        Detach - Method (New)
        Delete - Property (Removed)
        Handle - Property (Removed)
IAcadEntity (Changed)
        Handle - Property (Removed)
        Color - Property
        Layer - Property
        Linetype - Property
        LinetypeScale - Property
        Visible - Property
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method
        ArrayRectangular - Method
        Highlight - Method
        Copy - Method
        Erase - Method (Removed)
        Move - Method
        Rotate - Method
        Rotate3D - Method
        Mirror - Method
        Mirror3D - Method(0x00010213)]
        ScaleEntity - Method
        TransformBy - Method
        Update - Method
        GetBoundingBox - Method
        IntersectWith - Method
        PlotStyleName - Property (New)
        Lineweight - Property (New)
        Hyperlinks - Property (New)
        EntityName - Property (New)
        EntityType - Property (New)
        ObjectID - Property (Removed)
        Application - Property (Removed)
IAcadHyperlinks (New)
        Item - Method
        Count - Property
        Application - Property
        Add - Method
IAcadHyperlink (New)
        URL - Property
        URLDescription - Property
        Application - Property
        Delete - Method
        URLNamedLocation - Property
IAcad3DFace (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Coordinates - Property (New)
        VisibilityEdge1 - Property (New)
        VisibilityEdge2 - Property (New)
        VisibilityEdge3 - Property (New)
        VisibilityEdge4 - Property (New)
        GetInvisibleEdge - Method
        SetInvisibleEdge - Method
        Coordinate - Property (New)
IAcadPolygonMesh (New)
        Coordinates - Property
        MClose - Property
        NClose - Property
        MDensity - Property
        NDensity - Property
        MVertexCount - Property
        NVertexCount - Property
        Type - Property
        AppendVertex - Method
        Explode - Method
        Coordinate - Property
IAcad3DPolyline (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Coordinates - Property
        AppendVertex - Method
        Explode - Method
        Coordinate - Property (New)
        Type - Property (New)
        Closed - Property
IAcadArc (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Area - Property
        Center - Property
        Radius - Property
        StartAngle - Property
        EndAngle - Property
        TotalAngle - Property (New)
        ArcLength - Property (New)
        StartPoint - Property
        EndPoint - Property
        Normal - Property
        Thickness - Property
        Offset - Method
IAcadAttribute (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        FieldLength - Property
        Height - Property
        Alignment - Property (New)
        HorizontalAlignment - Property
        InsertionPoint - Property
        Normal - Property
        ObliqueAngle - Property
        PromptString - Property
        Rotation - Property
        ScaleFactor - Property
        StyleName - Property
        TagString - Property
        TextAlignmentPoint - Property
        TextGenerationFlag - Property
        TextString - Property
        Thickness - Property
        VerticalAlignment - Property
        Mode - Property
        UpsideDown - Property (New)
        Backward - Property (New)
        Invisible - Property (New)
        Constant - Property (New)
        Verify - Property (New)
        Preset - Property (New)
IAcadAttributeReference (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Highlight - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        FieldLength - Property
        Height - Property
        HorizontalAlignment - Property
        InsertionPoint - Property
        Normal - Property
        ObliqueAngle - Property
        Rotation - Property
        ScaleFactor - Property
        StyleName - Property
        TagString - Property
        TextAlignmentPoint - Property
        TextGenerationFlag - Property
        TextString - Property
        Thickness - Property
        VerticalAlignment - Property
        Alignment - Property
        UpsideDown - Property
        Backward - Property
        Invisible - Property
        Constant - Property
IAcad3DSolid (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Centroid - Property
        MomentOfInertia - Property
        PrincipalDirections - Property
        PrincipalMoments - Property
        ProductOfInertia - Property
        RadiiOfGyration - Property
        Volume - Property
        Boolean - Method
        CheckInterference - Method
        SectionSolid - Method
        SliceSolid - Method
IAcadRegion (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Area - Property
        Centroid - Property
        MomentOfInertia - Property
        Normal - Property
        Perimeter - Property
        PrincipalDirections - Property
        PrincipalMoments - Property
        ProductOfInertia - Property
        RadiiOfGyration - Property
        Boolean - Method
        Explode - Method
IAcadCircle (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Area - Property
        Center - Property
        Radius - Property
        Normal - Property
        Thickness - Property
        Offset - Method
        Diameter - Property (New)
        Circumference - Property (New)
IAcadDimAligned (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Normal - Property
        Rotation - Property
        TextPosition - Property
        TextRotation - Property
        TextString - Property
        StyleName - Property
        ExtLine1Point - Property
        ExtLine2Point - Property
        AltUnits - Property (New)
        AltUnitsPrecision - Property (New)
        AltUnitsScale - Property (New)
        AltRoundDistance - Property (New)
        AltTolerancePrecision - Property (New)
        AltUnitsFormat - Property (New)
        AltTextPrefix - Property (New)
        AltTextSuffix - Property (New)
        DimensionLineColor - Property (New)
        ExtensionLineColor - Property (New)
        PrimaryUnitsPrecision - Property (New)
        DimensionLineExtend - Property (New)
        ExtensionLineExtend - Property (New)
        Fit - Property (New)
        FractionFormat - Property (New)
        HorizontalTextPosition - Property (New)
        LinearScaleFactor - Property (New)
        UnitsFormat - Property (New)
        ExtensionLineWeight - Property (New)
        RoundDistance - Property (New)
        DimLine1Suppress - Property (New)
        DimLine2Suppress - Property (New)
        ExtLine1Suppress - Property (New)
        ExtLine2Suppress - Property (New)
        DimLineInside - Property (New)
        TextInsideAlign - Property (New)
        TextInside - Property (New)
        ForceLineInside - Property (New)
        TextOutsideAlign - Property (New)
        ExtensionLineOffset - Property (New)
        AltSuppressLeadingZeros - Property (New)
        AltSuppressTrailingZeros - Property (New)
        AltSuppressZeroFeet - Property (New)
        AltSuppressZeroInches - Property (New)
        AltToleranceSuppressLeadingZeros - Property (New)
        AltToleranceSuppressTrailingZeros - Property (New)
        AltToleranceSuppressZeroFeet - Property (New)
        AltToleranceSuppressZeroInches - Property (New)
        SuppressZeroFeet - Property (New)
        SuppressZeroInches - Property (New)
        ToleranceSuppressZeroFeet - Property (New)
        ToleranceSuppressZeroInches - Property (New)
        DimensionLineWeight - Property (New)
        ArrowheadSize - Property (New)
        Arrowhead1Type - Property (New)
        Arrowhead2Type - Property (New)
        Measurement - Property (New)
        Arrowhead1Block - Property (New)
        Arrowhead2Block - Property (New)
IAcadDimension (New)
        Normal - Property
        Rotation - Property
        TextPosition - Property
        TextRotation - Property
        TextOverride - Property
        StyleName - Property
        TextColor - Property
        DecimalSeparator - Property
        TextGap - Property
        TextPrefix - Property
        TextSuffix - Property
        ScaleFactor - Property
        VerticalTextPosition - Property
        TolerancePrecision - Property
        ToleranceHeightScale - Property
        ToleranceLowerLimit - Property
        TextMovement - Property
        ToleranceDisplay - Property
        ToleranceJustification - Property
        ToleranceUpperLimit - Property
        TextStyle - Property
        TextHeight - Property
        SuppressLeadingZeros - Property
        SuppressTrailingZeros - Property
        ToleranceSuppressLeadingZeros - Property
        ToleranceSuppressTrailingZeros - Property
IAcadDimAngular (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Normal - Property
        Rotation - Property
        TextPosition - Property
        TextRotation - Property
        TextString - Property
        StyleName - Property
        ExtLine1StartPoint - Property
        ExtLine1EndPoint - Property
        ExtLine2StartPoint - Property
        ExtLine2EndPoint - Property
        AngleFormat - Property (New)
        DimensionLineColor - Property (New)
        ExtensionLineColor - Property (New)
        ExtensionLineExtend - Property (New)
        Fit - Property (New)
        HorizontalTextPosition - Property (New)
        ExtensionLineWeight - Property (New)
        DimLine1Suppress - Property (New)
        DimLine2Suppress - Property (New)
        ExtLine1Suppress - Property (New)
        ExtLine2Suppress - Property (New)
        DimLineInside - Property (New)
        TextInsideAlign - Property (New)
        TextInside - Property (New)
        ForceLineInside - Property (New)
        TextOutsideAlign - Property (New)
        TextPrecision - Property (New)
        ExtensionLineOffset - Property (New)
        DimensionLineWeight - Property (New)
        ArrowheadSize - Property (New)
        Arrowhead1Type - Property (New)
        Arrowhead2Type - Property (New)
        Measurement - Property (New)
        Arrowhead1Block - Property (New)
        Arrowhead2Block - Property (New)
IAcadDimDiametric (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Normal - Property
        Rotation - Property
        TextPosition - Property
        TextRotation - Property
        TextString - Property
        StyleName - Property
        LeaderLength - Property
        AltUnits - Property (New)
        AltUnitsPrecision - Property (New)
        AltUnitsScale - Property (New)
        AltRoundDistance - Property (New)
        AltTolerancePrecision - Property (New)
        AltUnitsFormat - Property (New)
        AltTextPrefix - Property (New)
        AltTextSuffix - Property (New)
        DimensionLineColor - Property (New)
        PrimaryUnitsPrecision - Property (New)
        FractionFormat - Property (New)
        Fit - Property (New)
        LinearScaleFactor - Property (New)
        UnitsFormat - Property (New)
        RoundDistance - Property (New)
        DimLine1Suppress - Property (New)
        DimLine2Suppress - Property (New)
        TextInsideAlign - Property (New)
        TextInside - Property (New)
        ForceLineInside - Property (New)
        TextOutsideAlign - Property (New)
        CenterType - Property (New)
        CenterMarkSize - Property (New)
        AltSuppressLeadingZeros - Property (New)
        AltSuppressTrailingZeros - Property (New)
        AltSuppressZeroFeet - Property (New)
        AltSuppressZeroInches - Property (New)
        AltToleranceSuppressLeadingZeros - Property (New)
        AltToleranceSuppressTrailingZeros - Property (New)
        AltToleranceSuppressZeroFeet - Property (New)
        AltToleranceSuppressZeroInches - Property (New)
        SuppressZeroFeet - Property (New)
        SuppressZeroInches - Property (New)
        ToleranceSuppressZeroFeet - Property (New)
        ToleranceSuppressZeroInches - Property (New)
        DimensionLineWeight - Property (New)
        ArrowheadSize - Property (New)
        Arrowhead1Type - Property (New)
        Arrowhead2Type - Property (New)
        Measurement - Property (New)
        Arrowhead1Block - Property (New)
        Arrowhead2Block - Property (New)
IAcadDimRotated (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Normal - Property
        Rotation - Property
        TextPosition - Property
        TextRotation - Property
        TextString - Property
        StyleName - Property
        AltUnits - Property (New)
        AltUnitsPrecision - Property (New)
        AltUnitsScale - Property (New)
        AltRoundDistance - Property (New)
        AltTolerancePrecision - Property (New)
        AltUnitsFormat - Property (New)
        AltTextPrefix - Property (New)
        AltTextSuffix - Property (New)
        DimensionLineColor - Property (New)
        ExtensionLineColor - Property (New)
        PrimaryUnitsPrecision - Property (New)
        DimensionLineExtend - Property (New)
        ExtensionLineExtend - Property (New)
        Fit - Property (New)
        FractionFormat - Property (New)
        HorizontalTextPosition - Property (New)
        LinearScaleFactor - Property (New)
        UnitsFormat - Property (New)
        ExtensionLineWeight - Property (New)
        RoundDistance - Property (New)
        DimLine1Suppress - Property (New)
        DimLine2Suppress - Property (New)
        ExtLine1Suppress - Property (New)
        ExtLine2Suppress - Property (New)
        DimLineInside - Property (New)
        TextInsideAlign - Property (New)
        TextInside - Property (New)
        ForceLineInside - Property (New)
        TextOutsideAlign - Property (New)
        ExtensionLineOffset - Property (New)
        AltSuppressLeadingZeros - Property (New)
        AltSuppressTrailingZeros - Property (New)
        AltSuppressZeroFeet - Property (New)
        AltSuppressZeroInches - Property (New)
        AltToleranceSuppressLeadingZeros - Property (New)
        AltToleranceSuppressTrailingZeros - Property (New)
        AltToleranceSuppressZeroFeet - Property (New)
        AltToleranceSuppressZeroInches - Property (New)
        SuppressZeroFeet - Property (New)
        SuppressZeroInches - Property (New)
        ToleranceSuppressZeroFeet - Property (New)
        ToleranceSuppressZeroInches - Property (New)
        DimensionLineWeight - Property (New)
        ArrowheadSize - Property (New)
        Arrowhead1Type - Property (New)
        Arrowhead2Type - Property (New)
        Measurement - Property (New)
        Arrowhead1Block - Property (New)
        Arrowhead2Block - Property (New)
IAcadDimOrdinate (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Normal - Property
        Rotation - Property
        TextPosition - Property
        TextRotation - Property
        TextString - Property
        StyleName - Property
        AltUnits - Property (New)
        AltUnitsPrecision - Property (New)
        AltUnitsScale - Property (New)
        AltRoundDistance - Property (New)
        AltTolerancePrecision - Property (New)
        AltUnitsFormat - Property (New)
        AltTextPrefix - Property (New)
        AltTextSuffix - Property (New)
        ExtensionLineColor - Property (New)
        PrimaryUnitsPrecision - Property (New)
        FractionFormat - Property (New)
        LinearScaleFactor - Property (New)
        UnitsFormat - Property (New)
        ExtensionLineWeight - Property (New)
        RoundDistance - Property (New)
        ExtensionLineOffset - Property (New)
        AltSuppressLeadingZeros - Property (New)
        AltSuppressTrailingZeros - Property (New)
        AltSuppressZeroFeet - Property (New)
        AltSuppressZeroInches - Property (New)
        AltToleranceSuppressLeadingZeros - Property (New)
        AltToleranceSuppressTrailingZeros - Property (New)
        AltToleranceSuppressZeroFeet - Property (New)
        AltToleranceSuppressZeroInches - Property (New)
        SuppressZeroFeet - Property (New)
        SuppressZeroInches - Property (New)
        ToleranceSuppressZeroFeet - Property (New)
        ToleranceSuppressZeroInches - Property (New)
        ArrowheadSize - Property (New)
        Measurement - Property (New)
IAcadDimRadial (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Normal - Property
        Rotation - Property
        TextPosition - Property
        TextRotation - Property
        TextString - Property
        StyleName - Property
        LeaderLength - Property
        AltUnits - Property (New)
        AltUnitsPrecision - Property (New)
        AltUnitsScale - Property (New)
        AltRoundDistance - Property (New)
        AltTolerancePrecision - Property (New)
        AltUnitsFormat - Property (New)
        AltTextPrefix - Property (New)
        AltTextSuffix - Property (New)
        CenterType - Property (New)
        CenterMarkSize - Property (New)
        DimensionLineColor - Property (New)
        PrimaryUnitsPrecision - Property (New)
        FractionFormat - Property (New)
        Fit - Property (New)
        LinearScaleFactor - Property (New)
        UnitsFormat - Property (New)
        RoundDistance - Property (New)
        DimLineSuppress - Property (New)
        TextInsideAlign - Property (New)
        TextInside - Property (New)
        ForceLineInside - Property (New)
        TextOutsideAlign - Property (New)
        AltSuppressLeadingZeros - Property (New)
        AltSuppressTrailingZeros - Property (New)
        AltSuppressZeroFeet - Property (New)
        AltSuppressZeroInches - Property (New)
        AltToleranceSuppressLeadingZeros - Property (New)
        AltToleranceSuppressTrailingZeros - Property (New)
        AltToleranceSuppressZeroFeet - Property (New)
        AltToleranceSuppressZeroInches - Property (New)
        SuppressZeroFeet - Property (New)
        SuppressZeroInches - Property (New)
        ToleranceSuppressZeroFeet - Property (New)
        ToleranceSuppressZeroInches - Property (New)
        DimensionLineWeight - Property (New)
        ArrowheadSize - Property (New)
        ArrowheadType - Property (New)
        Measurement - Property (New)
        ArrowheadBlock - Property (New)
IAcadEllipse (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Area - Property
        StartPoint - Property
        EndPoint - Property
        Center - Property
        StartAngle - Property
        EndAngle - Property
        StartParameter - Property
        EndParameter - Property
        MajorAxis - Property
        MinorAxis - Property
        Normal - Property
        RadiusRatio - Property
        Offset - Method
        MajorRadius - Property (New)
        MinorRadius - Property (New)
IAcadLeader (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Coordinates - Property
        Normal - Property
        StyleName - Property
        Type - Property
        Evaluate - Method
        Coordinate - Property (New)
        Annotation - Property (New)
        ArrowheadSize - Property (New)
        ArrowheadType - Property (New)
        DimensionLineColor - Property (New)
        DimensionLineWeight - Property (New)
        ScaleFactor - Property (New)
        VerticalTextPosition - Property (New)
        TextGap - Property (New)
        ArrowheadBlock - Property (New)
IAcadMtext (Removed)
        Handle - Property
        EntityName - Property
        Color - Property
        Layer - Property
        Linetype - Property
        LinetypeScale - Property
        Visible - Property
        GetXData - Method
        SetXData - Method
        ArrayPolar - Method
        ArrayRectangular - Method
        Highlight - Method
        Copy - Method
        Erase - Method
        Move - Method
        Rotate - Method
        Rotate3D - Method
        Mirror - Method
        Mirror3D - Method
        ScaleEntity- Method
        TransformBy - Method
        Update - Method
        GetBoundingBox - Method
        IntersectWith - Method
        ObjectID - Property
        EntityType - Property
        Application - Property
        AttachmentPoint - Property
        DrawingDirection - Property
        Height - Property
        InsertionPoint - Property
        Normal - Property
        Rotation - Property
        StyleName - Property
        TextString - Property
        Width - Property
IAcadMText (New/Renamed from IAcadMtext)
        TextString - Property
        StyleName - Property
        AttachmentPoint - Property
        DrawingDirection - Property
        Width - Property
        Height - Property
        Rotation - Property
        InsertionPoint - Property
        Normal - Property
        LineSpacingFactor - Property
        LineSpacingStyle - Property
IAcadPoint (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Coordinates - Property
        Normal - Property
        Thickness - Property
IAcadLWPolyline (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Area - Property
        Closed - Property
        Coordinates - Property
        Normal - Property
        Thickness - Property
        AddVertex - Method
        Explode - Method
        GetBulge - Method
        SetBulge - Method
        GetWidth - Method
        SetWidth - Method
        Offset - Method
        ConstantWidth - Property (New)
        Elevation - Property (New)
        Coordinate - Property (New)
        LinetypeGeneration - Property (New)
IAcadPolyline (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Area - Property
        Closed - Property
        Coordinates - Property
        Normal - Property
        Thickness - Property
        Type - Property
        AppendVertex - Method
        Explode - Method
        GetBulge - Method
        SetBulge - Method
        GetWidth - Method
        SetWidth - Method
        Offset - Method
        ConstantWidth - Property (New)
        Elevation - Property (New)
        LinetypeGeneration - Property (New)
        Coordinate - Property (New)
IAcadRay (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        BasePoint - Property
        DirectionVector - Property
        SecondPoint - Property (New)
IAcadShape (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Height - Property
        InsertionPoint - Property
        Name - Property
        Normal - Property
        ObliqueAngle - Property
        Rotation - Property
        ScaleFactor - Property
        Thickness - Property
IAcadSolid (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Coordinates - Property
        Normal - Property
        Thickness - Property
        Coordinate - Property (New)
IAcadSpline (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Area - Property
        Closed - Property
        Degree - Property
        EndTangent - Property
        FitTolerance - Property
        IsRational - Property
        NumberOfControlPoints - Property
        NumberOfFitPoints - Property
        StartTangent - Property
        SetControlPoint - Method
        GetControlPoint - Method
        SetFitPoint - Method
        GetFitPoint - Method
        SetWeight - Method
        GetWeight - Method
        AddFitPoint - Method
        DeleteFitPoint - Method
        ElevateOrder - Method
        Offset - Method
        PurgeFitData - Method
        Reverse - Method
        ControlPoints - Property (New)
        FitPoints - Property (New)
        IsPlanar - Property (New)
        IsPeriodic - Property (New)
        Knots - Property (New)
        Weights - Property (New)
IAcadText (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Height - Property
        HorizontalAlignment - Property
        InsertionPoint - Property
        Normal - Property
        ObliqueAngle - Property
        Rotation - Property
        ScaleFactor - Property
        StyleName - Property
        TextAlignmentPoint - Property
        TextGenerationFlag - Property
        TextString - Property
        Thickness - Property
        VerticalAlignment - Property
        Alignment - Property (New)
        UpsideDown - Property (New)
        Backward - Property (New)
IAcadTolerance (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        DirectionVector - Property
        InsertionPoint - Property
        Normal - Property
        StyleName - Property
        TextString - Property
        TextColor - Property (New)
        TextStyle - Property (New)
        TextHeight - Property (New)
        ScaleFactor - Property (New)
        DimensionLineColor - Property (New)
IAcadTrace (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Coordinates - Property
        Normal - Property
        Thickness - Property
        Coordinate - Property (New)
IAcadXline (Change)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        BasePoint - Property
        DirectionVector - Property
        Offset - Method
        SecondPoint - Property (New)
IAcadBlockReference (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        InsertionPoint - Property
        Name - Property
        Normal - Property
        Rotation - Property
        XScaleFactor - Property
        YScaleFactor - Property
        Explode - Method
        GetAttributes - Method
        HasAttributes - Property
        ZScaleFactor - Property
        GetConstantAttributes - Method (New)
IAcadHatch (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Normal - Property
        Elevation - Property
        AssociativeHatch - Property (Now Supports In/Out)
        NumberOfLoops - Property
        PatternType - Property
        PatternName - Property
        PatternAngle - Property
        PatternScale - Property
        PatternSpace - Property
        PatternDouble - Property
        HatchStyle - Property
        SetPattern - Method
        AppendOuterLoop - Method
        AppendInnerLoop - Method
        InsertLoopAt - Method
        GetLoopAt - Method
        Evaluate - Method
        ISOPenWidth - Property (New)
IAcadRaster (Removed)
        Handle - Property
        EntityName - Property
        Color - Property
        Layer - Property
        Linetype - Property
        LinetypeScale - Property
        Visible - Property
        GetXData - Method
        SetXData - Method
        ArrayPolar - Method
        ArrayRectangular - Method
        Highlight - Method
        Copy - Method
        Erase - Method
        Move - Method
        Rotate - Method
        Rotate3D - Method
        Mirror - Method
        Mirror3D - Method
        ScaleEntity- Method
        TransformBy - Method
        Update - Method
        GetBoundingBox - Method
        IntersectWith - Method
        ObjectID - Property
        EntityType - Property
        Application - Property
        ImageFile - Property
        Origin - Property
        ImageVisibility - Property
        ClippingEnabled - Property
        Transparency - Property
        Brightness - Property
        Contrast - Property
        Fade - Property
        ClipBoundary - Property
        Height - Property
        Width - Property
IAcadRasterImage (New/Renamed from IAcadRaster)
        Brightness - Property
        Contrast - Property
        Fade - Property
        Origin - Property
        Rotation - Property
        ImageWidth - Property
        ImageHeight - Property
        Name - Property
        ImageFile - Property
        ImageVisibility - Property
        ClippingEnabled - Property
        Transparency - Property
        ClipBoundary - Property
        Height - Property
        Width - Property
        ShowRotation - Property
        ScaleFactor - Property
IAcadLine (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        StartPoint - Property
        EndPoint - Property
        Normal - Property
        Thickness - Property
        Offset - Method
        Delta - Property (New)
        Length - Property (New)
        Angle - Property (New)
IAcadLayout (New)
        Block - Property
        TabOrder - Property
IAcadPlotConfiguration (New)
        Name - Property
        ConfigName - Property
        CanonicalMediaName - Property
        PaperUnits - Property
        PlotViewportBorders - Property
        ShowPlotStyles - Property
        PlotRotation - Property
        CenterPlot - Property
        PlotHidden - Property
        PlotType - Property
        ViewToPlot - Property
        UseStandardScale - Property
        StandardScale - Property
        GetCustomScale - Method
        SetCustomScale - Method
        ScaleLineweights - Property
        PlotWithLineweights - Property
        PlotViewportsFirst - Property
        StyleSheet - Property
        GetPaperMargins - Method
        GetPaperSize - Method
        PlotOrigin - Property
        GetWindowToPlot - Method
        SetWindowToPlot - Method
        PlotWithPlotStyles - Property
        ModelType - Property
        CopyFrom - Method
        GetCanonicalMediaNames - Method
        GetPlotDeviceNames - Method
        GetPlotStyleTableNames - Method
        RefreshPlotDeviceInfo - Method
        GetLocaleMediaName - Method
IAcadMInsertBlock (New)
        Columns - Property
        ColumnSpacing - Property
        Rows - Property
        RowSpacing - Property
IAcadPolyfaceMesh (New)
        Coordinates - Property
        Coordinate - Property
        NumberOfVertices - Property
        NumberOfFaces - Property
        Faces - Method
IAcadMLine (New)
        StyleName - Property
        Coordinates - Property
IAcadDim3PointAngular (New)
        ExtLine1EndPoint - Property
        ExtLine2EndPoint - Property
        AngleVertex - Property
        TextPrecision - Property
        AngleFormat - Property
        DimensionLineColor - Property
        ExtensionLineColor - Property
        ExtensionLineExtend - Property
        Fit - Property
        HorizontalTextPosition - Property
        ExtensionLineWeight - Property
        DimLine1Suppress - Property
        DimLine2Suppress - Property
        ExtLine1Suppress - Property
        ExtLine2Suppress - Property
        DimLineInside - Property
        TextInsideAlign - Property
        TextInside - Property
        ForceLineInside - Property
        TextOutsideAlign - Property
        ExtensionLineOffset - Property
        DimensionLineWeight - Property
        ArrowheadSize - Property
        Arrowhead1Type - Property
        Arrowhead2Type - Property
        Measurement - Property
        Arrowhead1Block - Property
        Arrowhead2Block - Property
IAcadExternalReference (New)
        Path - Property
IAcadPaperSpace (Changed)
        Count - Property (Removed)
        Application - Property (Removed)
        AddLine - Method (Removed)
        AddCustomObject - Method (Removed)
        Add3DFace - Method (Removed)
        Add3DMesh - Method (Removed)
        Add3DPoly - Method (Removed)
        AddArc - Method (Removed)
        AddAttribute - Method (Removed)
        AddBox - Method (Removed)
        AddCircle - Method (Removed)
        AddCone - Method (Removed)
        AddCylinder - Method (Removed)
        AddDimAligned - Method (Removed)
        AddDimAngular - Method (Removed)
        AddDimDiametric - Method (Removed)
        AddDimRotated - Method (Removed)
        AddDimOrdinate - Method (Removed)
        AddDimRadial - Method (Removed)
        AddEllipse - Method (Removed)
        AddEllipticalCone - Method (Removed)
        AddEllipticalCylinder - Method (Removed)
        AddExtrudedSolid - Method (Removed)
        AddExtrudedSolidAlongPath - Method (Removed)
        AddLeader - Method (Removed)
        AddMText - Method (Removed)
        AddPoint - Method (Removed)
        AddLightWeightPolyline - Method (Removed)
        AddPolyline - Method (Removed)
        AddRay - Method (Removed)
        AddRegion - Method (Removed)
        AddRevolvedSolid - Method (Removed)
        AddShape - Method (Removed)
        AddSolid - Method (Removed)
        AddSphere - Method (Removed)
        AddSpline - Method (Removed)
        AddText - Method (Removed)
        AddTolerance - Method (Removed)
        AddTorus - Method (Removed)
        AddTrace - Method (Removed)
        AddWedge - Method (Removed)
        AddXline - Method (Removed)
        InsertBlock - Method (Removed)
        AddHatch - Method (Removed)
        AddRaster - Method (Removed)
        Name - Property (Removed)
        AddPViewport - Method
        Handle - Property (Removed)
IAcadPViewport (Changed)
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property (Removed)
        Layer - Property (Removed)
        Linetype - Property (Removed)
        LinetypeScale - Property (Removed)
        Visible - Property (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        ArrayPolar - Method (Removed)
        ArrayRectangular - Method (Removed)
        Highlight - Method (Removed)
        Copy - Method (Removed)
        Erase - Method (Removed)
        Move - Method (Removed)
        Rotate - Method (Removed)
        Rotate3D - Method (Removed)
        Mirror - Method (Removed)
        Mirror3D - Method (Removed)
        ScaleEntity- Method (Removed)
        TransformBy - Method (Removed)
        Update - Method (Removed)
        GetBoundingBox - Method (Removed)
        IntersectWith - Method (Removed)
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Center - Property
        Direction - Property
        GridOn - Property
        Height - Property
        Width - Property
        SnapBasePoint - Property
        SnapOn - Property
        SnapRotationAngle - Property
        UCSIconOn - Property
        UCSIconAtOrigin - Property
        GetGridSpacing - Method
        SetGridSpacing - Method
        GetSnapSpacing - Method
        SetSnapSpacing - Method
        Display - Property
        TwistAngle - Property
        LensLength - Property
        RemoveHiddenLines - Property
        Target - Property
        ZoomExtents - Method
        ZoomAll - Method
        ZoomCenter - Method
        ZoomScaled - Method
        ZoomWindow - Method
        ZoomPickWindow - Method
        ViewportOn - Property (New)
        Clipped - Property (New)
        DisplayLocked - Property (New)
        StandardScale - Property (New)
        CustomScale - Property (New)
        StyleSheet - Property (New)
        UCSPerViewport - Property (New)
        ArcSmoothness - Property (New)
IAcadBlocks (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadGroups (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadGroup (Changed)
        Item - Method
        Count - Property
        Handle - Property (Removed)
        EntityName - Property (Removed)
        Color - Property
        Layer - Property
        Linetype - Property
        LinetypeScale - Property
        Visible - Property
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Highlight - Method
        ObjectID - Property (Removed)
        EntityType - Property (Removed)
        Application - Property (Removed)
        Name - Property
        AppendItems - Method
        RemoveItems - Method
        Delete - Method (Removed)
        Update - Method
        PlotStyleName - Property (New)
        Lineweight - Property (New)
IAcadDimStyles (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadDimStyle (Changed)
        Application - Property (Removed)
        Name - Property
        Delete - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Handle - Property (Removed)
        CopyFrom - Method (New)
IAcadLayers (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadLayer (Changed)
        Application - Property (Removed)
        Color - Property
        Freeze - Property
        LayerOn - Property
        Linetype - Property
        Lock - Property
        Name - Property
        Delete - Method
        GetXData - Method
        SetXData - Method
        Handle - Property
        Plottable - Property (New)
        ViewportDefault - Property (New)
        PlotStyleName - Property (New)
        Lineweight - Property (New)
IAcadLineTypes (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
        Load - Method
IAcadLineType (Changed)
        Application - Property (Removed)
        Description - Property
        Name - Property
        Delete - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Handle - Method (Removed)
IAcadDictionaries (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadDictionary (Changed)
        Application - Property (Removed)
        Name - Property
        AddObject - Method
        GetName - Method
        GetObject - Method
        Remove - Method
        Rename - Method
        Replace - Method
        Delete - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Handle - Property (Removed)
        Item - Method (Removed)
        Count - Property (Removed)
        AddXRecord - Method (Removed)
IAcadXRecord (New)
        Name - Property
        GetXRecordData - Method
        SetXRecordData - Method
        TranslateIDs - Property
IAcadRegisteredApplications (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadRegisteredApplication (Changed)
        Application - Property (Removed)
        Name - Property
        Delete - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Handle - Property (Removed)
IAcadTextStyles (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadTextStyle (Changed)
        Application - Property (Removed)
        BigFontFile - Property
        FontFile - Property
        Height - Property
        LastHeight - Property
        Name - Property
        ObliqueAngle - Property
        TextGenerationFlag - Property
        Width - Property
        Delete - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Handle - Property (Removed)
        GetFont - Method
        SetFont - Method
IAcadUCSs (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadUCS (Changed)
        Application - Property (Removed)
        Name - Property
        Origin - Property
        XVector - Property
        YVector - Property
        Delete - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        GetUCSMatrix - Method
        Handle - Property (Removed)
IAcadViews (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
IAcadView (Changed)
        Application - Property (Removed)
        Center - Property
        Height - Property
        Width - Property
        Target - Property
        Direction - Property
        Name - Property
        Delete - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Handle - Property (Removed)
IAcadViewports (Changed)
        Item - Method
        Count - Property
        Application - Property (Removed)
        Add - Method
        Delete - Method (Removed)
        DeleteConfiguration - Method (New)
IAcadViewport (Changed)
        Application - Property (Removed)
        Center - Property
        Height - Property
        Width - Property
        Target - Property
        Direction - Property
        Name - Property
        GridOn - Property
        OrthoOn - Property
        SnapBasePoint - Property
        SnapOn - Property
        SnapRotationAngle - Property
        StatusId - Property (Removed)
        UCSIconOn - Property
        UCSIconAtOrigin - Property
        LowerLeftCorner - Property
        UpperRightCorner - Property
        Split - Method
        GetGridSpacing - Method
        SetGridSpacing - Method
        GetSnapSpacing - Method
        SetSnapSpacing - Method
        SetView - Method
        ZoomExtents - Method (Removed)
        ZoomAll - Method (Removed)
        ZoomCenter - Method (Removed)
        ZoomScaled - Method (Removed)
        ZoomWindow - Method (Removed)
        ZoomPickWindow - Method (Removed)
        GetXData - Method (Removed)
        SetXData - Method (Removed)
        Handle - Property (Removed)
        ArcSmoothness - Property (New)
IAcadLayouts (New)
        Item - Method
        Count - Property
        Add - Method
IAcadPlotConfigurations (New)
        Item - Method
        Count - Property
        Add - Method
IAcadDatabasePreferences (New)
        Application - Property
        SolidFill - Property
        XRefEdit - Property
        XRefLayerVisibility - Property
        OLELaunch - Property
        AllowLongSymbolNames - Property
        ObjectSortBySelection - Property
        ObjectSortBySnap - Property
        ObjectSortByRedraws - Property
        ObjectSortByRegens - Property
        ObjectSortByPlotting - Property
        ObjectSortByPSOutput - Property
        ContourLinesPerSurface - Property
        DisplaySilhouette - Property
        MaxActiveViewports - Property
        RenderSmoothness - Property
        SegmentPerPolyline - Property
        TextFrameDisplay - Property
        Lineweight - Property
        LineWeightDisplay - Property
IAcadObjectEvents (New)
        Modified - Event
IAcadIdPair (New)
        IsCloned - Property
        IsOwnerXlated - Property
        IsPrimary - Property
        Key - Property
        Value - Property
        Application - Property
_DAcadApplicationEvents (New)
        SysVarChanged - Event
        NewDrawing - Event
        AppActivate - Event
        AppDeactivate - Event
        WindowMovedOrResized - Event
        BeginModal - Event
        EndModal - Event
        BeginQuit - Event
        BeginFileDrop - Event
        ARXLoaded - Event
        ARXUnloaded - Event
        BeginPlot - Event
        EndPlot - Event
        BeginSave - Event
        EndSave - Event
        BeginOpen - Event
        EndOpen - Event
        BeginCommand - Event
        EndCommand - Event
        BeginLisp - Event
        EndLisp - Event
        LispCancelled - Event
        WindowChanged - Event
IAcadDocument (Changed)
        ModelSpace - Property
        PaperSpace - Property
        Blocks - Property
        Plot - Property
        Application - Property
        ActiveLayer - Property
        ActiveLinetype - Property
        ActiveDimStyle - Property
        ActiveTextStyle - Property
        ActiveUCS - Property
        ActiveViewport - Property
        ActivePViewport - Property
        ActiveSpace - Property
        SelectionSets - Property
        Groups - Property
        DimStyles - Property]
        Layers - Property
        Linetypes - Property
        Dictionaries - Property
        RegisteredApplications - Property
        TextStyles - Property
        UserCoordinateSystems - Property
        Views - Property
        Viewports - Property
        ActiveSelectionSet - Property
        FullName - Property
        Name - Property
        Path - Property
        ElevationModelSpace - Property
        ElevationPaperSpace - Property
        Limits - Property
        ObjectSnapMode - Property
        ReadOnly - Property
        Saved - Property
        MSpace - Property
        Open - Method
        AuditInfo - Method
        Import - Method
        Export - Method
        HandleToObject - Method
        ObjectIdToObject - Method
        New - Method
        Regen - Method
        Save - Method
        SaveAs - Method
        PurgeAll - Method
        GetVariable - Method
        SetVariable - Method
        LoadShapeFile - Method
        Wblock - Method
        Utility - Property
IAcadPlot (Changed)
        Application - Property
        PlotOrientation - Property (Removed)
        PlotScale - Property (Removed)
        Rotation - Property (Removed)
        HideLines - Property (Removed)
        Origin - Property (Removed)
        PaperSize - Property (Removed)
        PlotUnits - Property (Removed)
        AdjustAreaFill - Property (Removed)
        PlotWithConfigFile - Property (Removed)
        PlotExtents - Method (Removed)
        PlotLimits - Method (Removed)
        PlotPreview - Method (Removed)
        PlotToFile - Method
        PlotToDevice - Method
        PlotView - Method (Removed)
        PlotWindow - Method (Removed)
        LoadPC2 - Method (Removed)
        SavePC2 - Method (Removed)
        QuietErrorMode - Property (New)
        NumberOfCopies - Property (New)
        BatchPlotProgress - Property (New)
        DisplayPlotPreview - Property (New)
        SetLayoutsToPlot - Method (New)
        StartBatchMode - Method (New)
IAcadApplication (Changed)
        Visible - Property
        Quit - Method
        Name - Property
        Application - Property
        ActiveDocument - Property
        Caption - Property
        FullName - Property
        Height - Property
        Left - Property (Removed)
        Path - Property
        Top - Property (Removed)
        Version - Property
        Width - Property
        LocaleId - Property
        Preferences - Property
        ListAds - Method (Removed)
        ListArx - Method
        LoadAds - Method (Removed)
        LoadArx - Method
        GetInterfaceObject - Method
        UnloadAds - Method (Removed)
        UnloadArx - Method
        Update - Method
        StartUndoMark - Method
        EndUndoMark - Method
        WindowLeft - Property (New)
        WindowTop - Property (New)
        StatusId - Property (New)
        VBE - Property (New)
        MenuGroups - Property (New)
        MenuBar - Property (New)
        LoadDVB - Method (New)
        UnloadDVB - Method (New)
        Documents - Property (New)
        Eval - Method (New)
        WindowState - Property (New)
        RunMacro - Method (New)
        ZoomExtents - Method (New)
        ZoomAll - Method (New)
        ZoomCenter - Method (New)
        ZoomScaled - Method (New)
        ZoomWindow - Method (New)
        ZoomPickWindow - Method (New)
        GetAcadState - Method (New)
        ZoomPrevious - Method (New)
IAcadPreferences (Changed)
        Application - Property
        SupportPath - Property (Removed)
        DriversPath - Property (Removed)
        MenuFile - Property (Removed)
        AltTabletMenuFile - Property (Removed)
        HelpFilePath - Property (Removed)
        AutoSaveFile - Property (Removed)
        LogFileName - Property (Removed)
        DefaultInternetURL - Property (Removed)
        ConfigFile - Property (Removed)
        LicenseServer - Property (Removed)
        TextEditor - Property (Removed)
        MainDictionary - Property (Removed)
        CustomDictionary - Property (Removed)
        AltFontFile - Property (Removed)
        FontFileMap - Property (Removed)
        PrintFile - Property (Removed)
        PrintSpoolExecutable - Property (Removed)
        PostScriptPrologFile - Property (Removed)
        PrintSpoolerPath - Property (Removed)
        TemplateDwgPath - Property (Removed)
        TempFilePath - Property (Removed)
        TempXrefPath - Property (Removed)
        XrefDemandLoad - Property (Removed)
        TextFrameDisplay - Property (Removed)
        DisplaySilhouette - Property (Removed)
        RenderSmoothness - Property (Removed)
        ContourLinesPerSurface - Property (Removed)
        SegmentPerPolyline - Property (Removed)
        MaxActiveViewports - Property (Removed)
        IncrementalSavePercent - Property (Removed)
        PersistentLisp - Property (Removed)
        EnableStartupDialog - Property (Removed)
        ShowRasterImage - Property (Removed)
        KeyboardAccelerator - Property (Removed)
        FullCRCValidation - Property (Removed)
        AutoAudit - Property (Removed)
        LogFileOn - Property (Removed)
        SavePreviewThumbnail - Property (Removed)
        AutoSaveInterval - Property (Removed)
        CreateBackup - Property (Removed)
        BeepOnError - Property (Removed)
        MaxNumOfSymbols - Property (Removed)
        DisplayScreenMenu - Property (Removed)
        DisplayScrollBars - Property (Removed)
        MaxAutoCADWindow - Property (Removed)
        DockedVisibleLines - Property (Removed)
        HistoryLines - Property (Removed)
        GraphicsWinBackgrndColor - Property (Removed)
        GraphicsTextBackgrndColor - Property (Removed)
        GraphicsTextColor - Property (Removed)
        TextWinBackgrndColor - Property (Removed)
        TextWinTextColor - Property (Removed)
        CrosshairColor - Property (Removed)
        MonochromeVectors - Property (Removed)
        GraphicFont - Property (Removed)
        GraphicFontStyle - Property (Removed)
        GraphicFontSize - Property (Removed)
        TextFont - Property (Removed)
        TextFontStyle - Property (Removed)
        TextFontSize - Property (Removed)
        SetProjectFilePath - Method (Removed)
        GetProjectFilePath - Method (Removed)
        ImportProfile - Method (Removed)
        ExportProfile - Method (Removed)
        DeleteProfile - Method (Removed)
        ResetProfile - Method (Removed)
        ArcSmoothness - Property (Removed)
        CursorSize - Property (Removed)
        MeasurementUnits - Property (Removed)
        DemandLoadARXApp - Property (Removed)
        DisplayDraggedObject - Property (Removed)
        TextureMapPath - Property (Removed)
        ActiveProfile - Property (Removed)
        ProxyImage - Property (Removed)
        ShowProxyDialogBox - Property (Removed)
        KeyboardPriority - Property (Removed)
        TempFileExtension - Property (Removed)
        Files - Property (New)
        Display - Property (New)
        OpenSave - Property (New)
        Output - Property (New)
        System - Property (New)
        User - Property (New)
        Drafting - Property (New)
        Selection - Property (New)
        Profiles - Property (New)
IAcadPreferencesFiles (New)
        Application - Property
        SupportPath - Property
        DriversPath - Property
        MenuFile - Property
        HelpFilePath - Property
        DefaultInternetURL - Property
        ConfigFile - Property
        LicenseServer - Property
        TextEditor - Property
        MainDictionary - Property
        CustomDictionary - Property
        AltFontFile - Property
        FontFileMap - Property
        PrintFile - Property
        PrintSpoolExecutable - Property
        PostScriptPrologFile - Property
        PrintSpoolerPath - Property
        AutoSavePath - Property
        TemplateDwgPath - Property
        LogFilePath - Property
        TempFilePath - Property
        TempXrefPath - Property
        TextureMapPath - Property
        AltTabletMenuFile - Property
        SetProjectFilePath - Method
        GetProjectFilePath - Method
        PrinterConfigPath - Property
        PrinterDescPath - Property
        PrinterStyleSheetPath - Property
        WorkspacePath - Property
        ObjectARXPath - Property
IAcadPreferencesDisplay (New)
        Application - Property
        LayoutDisplayMargins - Property
        LayoutDisplayPaper - Property
        LayoutDisplayPaperShadow - Property
        LayoutShowPlotSetup - Property
        LayoutCreateViewport - Property
        DisplayScrollBars - Property
        DisplayScreenMenu - Property
        CursorSize - Property
        DockedVisibleLines - Property
        ShowRasterImage - Property
        GraphicsWinModelBackgrndColor - Property
        ModelCrosshairColor - Property
        GraphicsWinLayoutBackgrndColor - Property
        TextWinBackgrndColor - Property
        TextWinTextColor - Property
        LayoutCrosshairColor - Property
        AutoTrackingVecColor - Property
        TextFont - Property
        TextFontStyle - Property
        TextFontSize - Property
        HistoryLines - Property
        MaxAutoCADWindow - Property
        DisplayLayoutTabs - Property
        ImageFrameHighlight - Property
        TrueColorImages - Property
        XRefFadeIntensity - Property
IAcadPreferencesOpenSave (New)
        Application - Property
        SavePreviewThumbnail - Property
        IncrementalSavePercent - Property
        AutoSaveInterval - Property
        CreateBackup - Property
        FullCRCValidation - Property
        LogFileOn - Property
        TempFileExtension - Property
        XrefDemandLoad - Property
        DemandLoadARXApp - Property
        ProxyImage - Property
        ShowProxyDialogBox - Property
        AutoAudit - Property
        SaveAsType - Property
        MRUNumber - Property
IAcadPreferencesOutput (New)
        Application - Property
        DefaultOutputDevice - Property
        PrinterSpoolAlert - Property
        PrinterPaperSizeAlert - Property
        PlotLegacy - Property
        OLEQuality - Property
        UseLastPlotSettings - Property
        PlotPolicy - Property
        DefaultPlotStyleTable - Property
        DefaultPlotStyleForObjects - Property
        DefaultPlotStyleForLayer - Property
IAcadPreferencesSystem (New)
        Application - Property
        SingleDocumentMode - Property
        DisplayOLEScale - Property
        StoreSQLIndex - Property
        TablesReadOnly - Property
        EnableStartupDialog - Property
        BeepOnError - Property
        ShowWarningMessages - Property
        LoadAcadLspInAllDocuments - Property
IAcadPreferencesUser (New)
        Application - Property
        KeyboardAccelerator - Property
        KeyboardPriority - Property
        HyperlinkDisplayCursor - Property
        HyperlinkDisplayTooltip - Property
        ADCInsertUnitsDefaultSource( - Property
        ADCInsertUnitsDefaultTarget - Property
        ShortCutMenuDisplay - Property
        SCMDefaultMode - Property
        SCMEditMode - Property
        SCMCommandMode - Property
IAcadPreferencesDrafting (New)
        Application - Property
        AutoSnapMarker - Property
        AutoSnapMagnet - Property
        AutoSnapTooltip - Property
        AutoSnapAperture - Property
        AutoSnapApertureSize - Property
        AutoSnapMarkerColor - Property
        AutoSnapMarkerSize - Property
        PolarTrackingVector - Property
        FullScreenTrackingVector - Property
        AutoTrackTooltip - Property
        AlignmentPointAcquisition - Property
IAcadPreferencesSelection (New)
        Application - Property
        PickFirst - Property
        PickAdd - Property
        PickDrag - Property
        PickAuto - Property
        PickBoxSize - Property
        DisplayGrips - Property
        DisplayGripsWithinBlocks - Property
        GripColorSelected - Property
        GripColorUnselected - Property
        GripSize - Property
        PickGroup - Property
IAcadPreferencesProfiles (New)
        Application - Property
        ActiveProfile - Property
        ImportProfile - Method
        ExportProfile - Method
        DeleteProfile - Method
        ResetProfile - Method
        RenameProfile - Method
        CopyProfile - Method
        GetAllProfileNames - Method
IAcadMenuGroups (New)
        Item - Method
        Count - Property
        Application - Property
        Parent - Property
        Load - Method
IAcadMenuGroup (New)
        Application - Property
        Parent - Property
        Name - Property
        Type - Property
        MenuFileName - Property
        Menus - Property
        Toolbars - Property
        Unload - Method
        Save - Method
        SaveAs - Method
IAcadPopupMenus (New)
        Item - Method
        Count - Property
        Application - Property
        Parent - Property
        Add - Method
        InsertMenuInMenuBar - Method
        RemoveMenuFromMenuBar - Method
IAcadPopupMenu (New)
        Item - Method
        Count - Property
        Application - Property
        Parent - Property
        Name - Property
        NameNoMnemonic - Property
        ShortcutMenu - Property
        OnMenuBar - Property
        AddMenuItem - Method
        AddSubMenu - Method
        AddSeparator - Method
        InsertInMenuBar - Method
        RemoveFromMenuBar - Method
        TagString - Property
IAcadPopupMenuItem (New)
        Application - Property
        Parent - Property
        Label - Property
        TagString - Property
        Enable - Property
        Check - Property
        Type - Property
        SubMenu - Property
        Macro - Property
        Index - Property
        Caption - Property
        HelpString - Property
        Delete - Method
        EndSubMenuLevel - Property
IAcadToolbars (New)
        Item - Method
        Count - Property
        Application - Property
        Parent - Property
        LargeButtons - Property
        Add - Method
IAcadToolbar (New)
        Item - Method
        Count - Property
        Application - Property
        Parent - Property
        Name - Property
        Visible - Property
        DockStatus - Property
        LargeButtons - Property
        left - Property
        top - Property
        Width - Property
        Height - Property
        FloatingRows - Property
        HelpString - Property
        AddToolbarButton - Method
        AddSeparator - Method
        Dock - Method
        Float - Method
        Delete - Method
        TagString - Property
IAcadToolbarItem (New)
        Application - Property
        Parent - Property
        Name - Property
        TagString - Property
        Type - Property
        Flyout - Property
        Macro - Property
        Index - Property
        HelpString - Property
        GetBitmaps - Method
        SetBitmaps - Method
        AttachToolbarToFlyout - Method
        Delete - Method
IAcadMenuBar (New)
        Item - Method
        Count - Property
        Application - Property
        Parent - Property
IAcadDocuments (New)
        Item - Method
        Count - Property
        Application - Property
        Add - Method
        Open - Method
        Close - Method
IAcadState (New)
        Application - Property
        IsQuiescent - Property
IAcadSelectionSets (Changed)
        Item - Method
        Count - Property
        Application - Property
        Add - Method
        Delete - Method (Removed)
IAcadSelectionSet
        Item - Method
        Count - Property
        Name - Property
        Highlight - Method
        Erase - Method
        Update - Method
        Application - Property
        AddItems - Method
        RemoveItems - Method
        Clear - Method
        Select - Method
        SelectAtPoint - Method
        SelectByPolygon - Method
        SelectOnScreen - Method
        Delete - Method
IAcadUtility (Changed)
        AngleToReal - Method
        AngleToString - Method
        DistanceToReal - Method
        RealToString - Method
        TranslateCoordinates - Method
        InitializeUserInput - Method
        GetInteger - Method
        GetReal - Method
        GetInput - Method
        GetKeyword - Method
        GetString - Method
        GetAngle - Method
        AngleFromXAxis - Method
        GetCorner - Method
        GetDistance - Method
        GetOrientation - Method
        GetPoint - Method
        PolarPoint - Method
        CreateTypedArray - Method
        GetEntity - Method
        Prompt - Method (New)
        GetSubEntity - Method (New)
        IsURL - Method (New)
        GetRemoteFile - Method (New)
        PutRemoteFile - Method (New)
        IsRemoteFile - Method (New)
        LaunchBrowserDialog - Method (New)
_DAcadDocumentEvents (Changed)
        BeginSave - Event
        EndSave - Event
        BeginOpen - Event (Removed)
        EndOpen - Event (Removed)
        BeginQuit - Event (Removed)
        BeginCommand - Event
        EndCommand - Event
        BeginLisp - Event (New)
        EndLisp - Event (New)
        LispCancelled - Event (New)
        SelectionChanged - Event (New)
        Activate - Event (New)
        Deactivate - Event (New)
        BeginRightClick - Event (New)
        BeginShortcutMenuDefault - Event (New)
        BeginShortcutMenuEdit - Event (New)
        BeginShortcutMenuCommand - Event (New)
        BeginShortcutMenuGrip - Event (New)
        BeginShortcutMenuOsnap - Event (New)
        EndShortcutMenu - Event (New)
        BeginDoubleClick - Event (New)
        ObjectAdded - Event (New)
        ObjectErased - Event (New)
        ObjectModified - Event (New)
        BeginPlot - Event (New)
        EndPlot - Event (New)
        WindowMovedOrResized - Event (New)
        LayoutSwitched - Event (New)
        WindowChanged - Event (New)
        BeginClose - Event (New)


AutoCAD 2000i API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2000i and AutoCAD 2000i-based products.

Enums

AcLayerStateMask (New)
        acLsNone = 0
        acLsOn = 1
        acLsFrozen = 2
        acLsLocked = 4
        acLsPlot = 8
        acLsNewViewport = 16
        acLsColor = 32
        acLsLineType = 64
        acLsLineWeight = 128
        acLsPlotStyle = 256
        acLsAll = 65535

Classes

IAcadLayerStateManager (New)
        SetDatabase - Method
        Mask - Property
        Save - Method
        Restore - Method
        Delete - Method
        Rename - Method
        Import - Method
        Export - Method


AutoCAD 2000i API History Reference (ActiveX)
About the ActiveX API History (ActiveX)
AutoCAD 2004 API History Reference (ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Introduction > About the ActiveX API History (ActiveX) >

AutoCAD 2002 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2002 and AutoCAD 2002-based products.

Enums

No changes

Classes

No changes


AutoCAD 2004 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2004 and AutoCAD 2004-based products.

Enums

AcViewportScale (Change)
        acVp1and1_2in_1ft = 30 (Changed)
        acVp3in_1ft = 31 (Changed)
        acVp6in_1ft = 32 (Changed)
        acVp1ft_1ft = 33 (New)
AcSaveAsType (Changed)
        ac2000_dwg = 12 (New)
        ac2000_dxf = 13 (New)
        ac2000_Template = 14 (New)
        ac2004_dwg = 24 (New)
        ac2004_dxf = 25 (New)
        ac2004_Template = 26 (New)
        acNative = 24 (Changed)
        acR18_dwg = 24 (New)
        acR18_dxf = 25 (New)
        acR18_Template = 26 (New)
AcShadePlot (New)
        acShadePlotAsDisplayed = 0
        acShadePlotWireframe = 1
        acShadePlotHidden = 2
        acShadePlotRendered = 3
AcHatchObjectType (New)
        acHatchObject = 0
        acGradientObject = 1
AcGradientPatternType (New)
        acPreDefinedGradient = 0
        acUserDefinedGradient = 1
AcColorMethod (New)
        acColorMethodByLayer = 192
        acColorMethodByBlock = 193
        acColorMethodByRGB = 194
        acColorMethodByACI = 195
        acColorMethodForeground = 197
AcadSecurityParamsType (New)
        ACADSECURITYPARAMS_ENCRYPT_DATA = 1
        ACADSECURITYPARAMS_ENCRYPT_PROPS = 2
        ACADSECURITYPARAMS_SIGN_DATA = 16
        ACADSECURITYPARAMS_ADD_TIMESTAMP = 32
AcadSecurityParamsConstants (New)
        ACADSECURITYPARAMS_ALGID_RC4 = 26625

Classes

IAcadDatabase (Changed)
        FileDependencies - Property (New)
        SummaryInfo - Property (New)
IAcadBlock (Changed)
        InsertBlock - Method (Changed - Password parameter)
        AddHatch - Method (Changed - Hatch object type parameter)
        AddMInsertBlock - Method (Changed - Password parameter)
        AttachExternalReference - Method (Changed - Password parameter)
IAcadEntity (Changed)
        TrueColor - Property (New)
IAcadAcCmColor (New)
        EntityColor - Property
        ColorName - Property
        BookName - Property
        SetNames - Method
        Delete - Method
        Red - Property
        Blue - Property
        Green - Property
        SetRGB - Method
        ColorMethod - Property
        ColorIndex - Property
        SetColorBookColor - Method
IAcad3DPolyline (Changed)
        Length - Property (New)
IAcadDimension (Changed)
        TextColor - Property (New)
IAcadMText (Changed)
        LineSpacingDistance - Property (New)
IAcadLWPolyline (Changed)
        Length - Property (New)
IAcadPolyline (Changed)
        Length - Property (New)
IAcadTolerance (Changed)
        TextColor - Property (New)
IAcadHatch (Changed)
        GradientColor1 - Property (New)
        GradientColor2 - Property (New)
        GradientAngle - Property (New)
        GradientCentered - Property (New)
        GradientName - Property (New)
        HatchObjectType - Property (New)
IAcadPViewport (Changed)
        RemoveHiddenLines - Property (Hidden)
        ShadePlot - Property (New)
IAcadGroup (Changed)
        TrueColor - Property (New)
        color - Property (Hidden)
IAcadLayer
        color - Property (Hidden)
        TrueColor - Property (New)
IAcadFileDependencies (New)
        Item - Method
        Application - Property
        Count - Property
        CreateEntry - Method
        IndexOf - Method
        RemoveEntry - Method
        UpdateEntry - Method
IAcadFileDependency (New)
        FullFileName - Property
        FileName - Property
        FoundPath - Property
        FingerprintGuid - Property
        VersionGuid - Property
        Feature - Property
        IsModified - Property
        AffectsGraphics - Property
        Index - Property
        TimeStamp - Property
        FileSize - Property
        ReferenceCount - Property
IAcadSummaryInfo (New)
        Author - Property
        Comments - Property
        HyperlinkBase - Property
        Keywords - Property
        LastSavedBy - Property
        RevisionNumber - Property
        Subject - Property
        Title - Property
        NumCustomInfo - Method
        GetCustomByIndex - Method
        GetCustomByKey - Method
        SetCustomByIndex - Method
        SetCustomByKey - Method
        AddCustomInfo - Method
        RemoveCustomByIndex - Method
        RemoveCustomByKey - Method
IAcadSecurityParams (New)
        Action - Property
        Password - Property
        ProviderType - Property
        ProviderName - Property
        Algorithm - Property
        KeyLength - Property
        Subject - Property
        Issuer - Property
        SerialNumber - Property
        Comment - Property
        TimeServer - Property
IAcadDocument (Changed)
        Open - Method (Changed - Password parameter)
        SaveAs - Method (Changed - Password parameter)
IAcadApplication (Changed)
        HWND - Property (New)
IAcadPreferencesFiles (Changed)
        LicenseServer - Property (Changed to hidden)
        ObjectARXPath - Property (Changed to hidden)
        ColorBookPath - Property (New)
        ToolPalettePath - Property (New)
IAcadPreferencesUser (Changed)
        SCMTimeMode - Property (New)
        SCMTimeValue - Property (New)
IAcadDocuments (Changed)
        Open - Method (Changed - Password parameter)


AutoCAD 2005 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2005 and AutoCAD 2005-based products.

Enums

AcEntityName (Changed)
        acTable = 43 (New)
AcTableDirection (New)
        acTableTopToBottom = 0
        acTableBottomToTop = 1
AcCellAlignment (New)
        acTopLeft = 1
        acTopCenter = 2
        acTopRight = 3
        acMiddleLeft = 4
        acMiddleCenter = 5
        acMiddleRight = 6
        acBottomLeft = 7
        acBottomCenter = 8
        acBottomRight = 9
AcRowType (New)
        acUnknownRow = 0
        acDataRow = 1
        acTitleRow = 2
        acHeaderRow = 4
AcGridLineType (New)
        acInvalidGridLine = 0
        acHorzTop = 1
        acHorzInside = 2
        acHorzBottom = 4
        acVertLeft = 8
        acVertInside = 16
        acVertRight = 32
AcCellType (New)
        acUnknownCell = 0
        acTextCell = 1
        acBlockCell = 2
AcCellEdgeMask (New)
        acTopMask = 1
        acRightMask = 2
        acBottomMask = 4
        acLeftMask = 8
AcRotationAngle (New)
        acDegreesUnknown = 0xffffffff
        acDegrees000 = 0
        acDegrees090 = 1
        acDegrees180 = 2
        acDegrees270 = 3
AcSelectType (New)
        acTableSelectWindow = 1
        acTableSelectCrossing = 2
AcOleType (New)
        acOTLink = 1
        acOTEmbedded = 2
        acOTStatic = 3
AcOlePlotQuality (New)
        acOPQMonochrome = 0
        acOPQLowGraphics = 1
        acOPQHighGraphics = 2
AcTableStyleOverrides (New)
        acTitleSuppressed = 1
        acHeaderSuppressed = 2
        acFlowDirection = 3
        acHorzCellMargin = 4
        acVertCellMargin = 5
        acTitleRowColor = 6
        acHeaderRowColor = 7
        acDataRowColor = 8
        acTitleRowFillNone = 9
        acHeaderRowFillNone = 10
        acDataRowFillNone = 11
        acTitleRowFillColor = 12
        acHeaderRowFillColor = 13
        acDataRowFillColor = 14
        acTitleRowAlignment = 15
        acHeaderRowAlignment = 16
        acDataRowAlignment = 17
        acTitleRowTextStyle = 18
        acHeaderRowTextStyle = 19
        acDataRowTextStyle = 20
        acTitleRowTextHeight = 21
        acHeaderRowTextHeight = 22
        acDataRowTextHeight = 23
        acTitleHorzTopColor = 40
        acTitleHorzInsideColor = 41
        acTitleHorzBottomColor = 42
        acTitleVertLeftColor = 43
        acTitleVertInsideColor = 44
        acTitleVertRightColor = 45
        acHeaderHorzTopColor = 46
        acHeaderHorzInsideColor = 47
        acHeaderHorzBottomColor = 48
        acHeaderVertLeftColor = 49
        acHeaderVertInsideColor = 50
        acHeaderVertRightColor = 51
        acDataHorzTopColor = 52
        acDataHorzInsideColor = 53
        acDataHorzBottomColor = 54
        acDataVertLeftColor = 55
        acDataVertInsideColor = 56
        acDataVertRightColor = 57
        acTitleHorzTopLineWeight = 70
        acTitleHorzInsideLineWeight = 71
        acTitleHorzBottomLineWeight = 72
        acTitleVertLeftLineWeight = 73
        acTitleVertInsideLineWeight = 74
        acTitleVertRightLineWeight = 75
        acHeaderHorzTopLineWeight = 76
        acHeaderHorzInsideLineWeight = 77
        acHeaderHorzBottomLineWeight = 78
        acHeaderVertLeftLineWeight = 79
        acHeaderVertInsideLineWeight = 80
        acHeaderVertRightLineWeight = 81
        acDataHorzTopLineWeight = 82
        acDataHorzInsideLineWeight = 83
        acDataHorzBottomLineWeight = 84
        acDataVertLeftLineWeight = 85
        acDataVertInsideLineWeight = 86
        acDataVertRightLineWeight = 87
        acTitleHorzTopVisibility = 100
        acTitleHorzInsideVisibility = 101
        acTitleHorzBottomVisibility = 102
        acTitleVertLeftVisibility = 103
        acTitleVertInsideVisibility = 104
        acTitleVertRightVisibility = 105
        acHeaderHorzTopVisibility = 106
        acHeaderHorzInsideVisibility = 107
        acHeaderHorzBottomVisibility = 108
        acHeaderVertLeftVisibility = 109
        acHeaderVertInsideVisibility = 110
        acHeaderVertRightVisibility = 111
        acDataHorzTopVisibility = 112
        acDataHorzInsideVisibility = 113
        acDataHorzBottomVisibility = 114
        acDataVertLeftVisibility = 115
        acDataVertInsideVisibility = 116
        acDataVertRightVisibility = 117
        acCellAlign = 130
        acCellBackgroundFillNone = 131
        acCellBackgroundColor = 132
        acCellContentColor = 133
        acCellTextStyle = 134
        acCellTextHeight = 135
        acCellTopGridColor = 136
        acCellRightGridColor = 137
        acCellBottomGridColor = 138
        acCellLeftGridColor = 139
        acCellTopGridLineWeight = 140
        acCellRightGridLineWeight = 141
        acCellBottomGridLineWeight = 142
        acCellLeftGridLineWeight = 143
        acCellTopVisibility = 144
        acCellRightVisibility = 145
        acCellBottomVisibility = 146
        acCellLeftVisibility = 147

Classes

IAcadSortentsTable (New)
        MoveToBottom - Method
        MoveToTop - Method
        MoveBelow - Method
        MoveAbove - Method
        SwapOrder - Method
        Block - Method
        GetFullDrawOrder - Method
        GetRelativeDrawOrder - Method
        SetRelativeDrawOrder - Method
IAcadLayer2 (New)
        Description - Property
        Used - Property
IAcadView2 (New)
        CategoryName - Property
        LayoutId - Property
        LayerState - Property
        HasVpAssociation - Property
IAcadTableStyle (New)
        Name - Property
        Description - Property
        BitFlags - Property
        FlowDirection - Property
        HorzCellMargin - Property
        VertCellMargin - Property
        TitleSuppressed - Property
        HeaderSuppressed - Property
        GetTextStyle - Method
        SetTextStyle - Method
        GetTextHeight - Method
        SetTextHeight - Method
        GetAlignment - Method
        SetAlignment - Method
        GetColor - Method
        SetColor - Method
        GetBackgroundColor - Method
        SetBackgroundColor - Method
        GetBackgroundColorNone - Method
        SetBackgroundColorNone - Method
        GetGridLineWeight - Method
        SetGridLineWeight - Method
        GetGridColor - Method
        SetGridColor - Method
        GetGridVisibility - Method
        SetGridVisibility - Method
IAcadLayers2 (New)
        GenerateUsageData - Method
IAcadMText2 (New)
        BackgroundFill - Property
        FieldCode - Method
IAcadText2 (New)
        FieldCode - Method
IAcadPViewport2 (New)
        ModelView - Property
        SheetView - Property
        LabelBlockId - Property
        HasSheetView - Property
        SyncModelView - Method
IAcadTable (New)
        StyleName - Property
        Rows - Property
        Columns - Property
        FlowDirection - Property
        Width - Property
        Height - Property
        VertCellMargin - Property
        HorzCellMargin - Property
        InsertionPoint - Property
        GetColumnWidth - Method
        SetColumnWidth - Method
        ColumnWidth - Method
        GetRowHeight - Method
        SetRowHeight - Method
        RowHeight - Method
        GetMinimumColumnWidth - Method
        GetMinimumRowHeight - Method
        MinimumTableWidth - Property
        MinimumTableHeight - Property
        Direction - Property
        TitleSuppressed - Property
        HeaderSuppressed - Property
        GetAlignment - Method
        SetAlignment - Method
        GetBackgroundColorNone - Method
        SetBackgroundColorNone - Method
        GetBackgroundColor - Method
        SetBackgroundColor - Method
        GetContentColor - Method
        SetContentColor - Method
        GetTextStyle - Method
        SetTextStyle - Method
        GetTextHeight - Method
        SetTextHeight - Method
        GetGridLineWeight - Method
        SetGridLineWeight - Method
        GetGridColor - Method
        SetGridColor - Method
        GetGridVisibility - Method
        SetGridVisibility - Method
        TableStyleOverrides - Property
        ClearTableStyleOverrides - Method
        GetCellType - Method
        SetCellType - Method
        GetCellExtents - Method
        GetAttachmentPoint - Method
        GetCellAlignment - Method
        SetCellAlignment - Method
        GetCellBackgroundColorNone - Method
        SetCellBackgroundColorNone - Method
        GetCellBackgroundColor - Method
        SetCellBackgroundColor - Method
        GetCellContentColor - Method
        SetCellContentColor - Method
        GetCellStyleOverrides - Method
        DeleteCellContent - Method
        GetRowType - Method
        GetText - Method
        SetText - Method
        GetCellTextStyle - Method
        SetCellTextStyle - Method
        GetCellTextHeight - Method
        SetCellTextHeight - Method
        GetTextRotation - Method
        SetTextRotation - Method
        GetAutoScale - Method
        SetAutoScale - Method
        GetBlockTableRecordId - Method
        SetBlockTableRecordId - Method
        GetBlockScale - Method
        SetBlockScale - Method
        GetBlockRotation - Method
        SetBlockRotation - Method
        GetBlockAttributeValue - Method
        SetBlockAttributeValue - Method
        GetCellGridLineWeight - Method
        SetCellGridLineWeight - Method
        GetCellGridColor - Method
        SetCellGridColor - Method
        GetCellGridVisibility - Method
        SetCellGridVisibility - Method
        InsertColumns - Method
        DeleteColumns - Method
        InsertRows - Method
        DeleteRows - Method
        MergeCells - Method
        UnmergeCells - Method
        IsMergedCell - Method
        GetFieldId - Method
        SetFieldId - Method
        GenerateLayout - Method
        RecomputeTableBlock - Method
        HitTest - Method
        Select - Method
        SelectSubRegion - Method
        ReselectSubRegion - Method
        GetSubSelection - Method
        SetSubSelection - Method
        ClearSubSelection - Method
        HasSubSelection - Property
IAcadOle (New)
        InsertionPoint - Property
        Rotation - Property
        Width - Property
        Height - Property
        ScaleWidth - Property
        ScaleHeight - Property
        LockAspectRatio - Property
        OleItemType - Property
        OlePlotQuality - Property
        OleSourceApp - Property
IAcadBlock2 (New)
        AddTable - Method
        Path - Property
IAcadModelSpace2 (New)
        AddTable - Method
IAcadPaperSpace2 (New)
        AddTable - Method
_DAcadApplicationEvents (Changed)
        BeginFileDrop - Event (Changed the last parameter to accept and return a value)
IAcadPreferencesFiles2 (New)
        QNewTemplateFile - Property (New)
        PlotLogFilePath - Property (New)
        PageSetupOverridesTemplateFile - Property (New)
IAcadPreferencesOutput2 (New)
        ContinuousPlotLog - Property (New)
        AutomaticPlotLog - Property (New)
        DefaultPlotToFilePath - Property (New)
_DAcadDocumentEvents (Changed)
        BeginDocClose - Event (New)


AutoCAD 2006 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2006 and AutoCAD 2006-based products.

Enums

AcEntityName (Changed)
        acDimArcLength = 44 (New)
        acDimRadialLarge = 45 (New)
AcDimArcLengthSymbol (New)
        acSymInFront = 0
        acSymAbove = 1
        acSymNone = 2
AcViewportScale (Changed)
        acVp1_1 = 2 (Removed)
        acVp1_2 = 3 (Removed)
        acVp1_4 = 4 (Removed)
        acVp1_8 = 5 (Removed)
        acVp1_10 = 6 (Removed)
        acVp1_16 = 7 (Removed)
        acVp1_20 = 8 (Removed)
        acVp1_30 = 9 (Removed)
        acVp1_40 = 10 (Removed)
        acVp1_50 = 11 (Removed)
        acVp1_100 = 12 (Removed)
        acVp2_1 = 13 (Removed)
        acVp4_1 = 14 (Removed)
        acVp8_1 = 15 (Removed)
        acVp10_1 = 16 (Removed)
        acVp100_1 = 17 (Removed)
        acVp1_128in_1ft = 18 (Removed)
        acVp1_64in_1ft = 19 (Removed)
        acVp1_32in_1ft = 20 (Removed)
        acVp1_16in_1ft = 21 (Removed)
        acVp3_32in_1ft = 22 (Removed)
        acVp1_8in_1ft = 23 (Removed)
        acVp3_16in_1ft = 24 (Removed)
        acVp1_4in_1ft = 25 (Removed)
        acVp3_8in_1ft = 26 (Removed)
        acVp1_2in_1ft = 27 (Removed)
        acVp3_4in_1ft = 28 (Removed)
        acVp1in_1ft = 29 (Removed)
        acVp1and1_2in_1ft = 30 (Removed)
        acVp3in_1ft = 31 (Removed)
        acVp6in_1ft = 32 (Removed)
        acVp1ft_1ft = 33 (Removed)
        acVp1 = 2 (New)
        acVp2 = 3 (New)
        acVp3 = 4 (New)
        acVp4 = 5 (New)
        acVp5 = 6 (New)
        acVp6 = 7 (New)
        acVp7 = 8 (New)
        acVp8 = 9 (New)
        acVp9 = 10 (New)
        acVp10 = 11 (New)
        acVp11 = 12 (New)
        acVp12 = 13 (New)
        acVp13 = 14 (New)
        acVp14 = 15 (New)
        acVp15 = 16 (New)
        acVp16 = 17 (New)
        acVp17 = 18 (New)
        acVp18 = 19 (New)
        acVp19 = 20 (New)
        acVp20 = 21 (New)
        acVp21 = 22 (New)
        acVp22 = 23 (New)
        acVp23 = 24 (New)
        acVp24 = 25 (New)
        acVp25 = 26 (New)
        acVp26 = 27 (New)
        acVp27 = 28 (New)
        acVp28 = 29 (New)
        acVp29 = 30 (New)
        acVp30 = 31 (New)
        acVp31 = 32 (New)
        acVp32 = 33 (New)
        acVp33 = 34 (New)
        acVp34 = 35 (New)
        acVp35 = 36 (New)
        acVp36 = 37 (New)
        acVp37 = 38 (New)
        acVp38 = 39 (New)
        acVp39 = 40 (New)
        acVp40 = 41 (New)
        acVp41 = 42 (New)
        acVp42 = 43 (New)
        acVp43 = 44 (New)
        acVp44 = 45 (New)
        acVp45 = 46 (New)
        acVp46 = 47 (New)
        acVp47 = 48 (New)
        acVp48 = 49 (New)
        acVp49 = 50 (New)
        acVp50 = 51 (New)
        acVp51 = 52 (New)
        acVp52 = 53 (New)
        acVp53 = 54 (New)
        acVp54 = 55 (New)
        acVp55 = 56 (New)
        acVp56 = 57 (New)
        acVp57 = 58 (New)
        acVp58 = 59 (New)
        acVp59 = 60 (New)
        acVp60 = 61 (New)
        acVp61 = 62 (New)
        acVp62 = 63 (New)
        acVp63 = 64 (New)
        acVp64 = 65 (New)
        acVp65 = 66 (New)
        acVp66 = 67 (New)
        acVp67 = 68 (New)
        acVp68 = 69 (New)
        acVp69 = 70 (New)
        acVp70 = 71 (New)
        acVp71 = 72 (New)
        acVp72 = 73 (New)
        acVp73 = 74 (New)
        acVp74 = 75 (New)
        acVp75 = 76 (New)
        acVp76 = 77 (New)
        acVp77 = 78 (New)
        acVp78 = 79 (New)
        acVp79 = 80 (New)
        acVp80 = 81 (New)
        acVp81 = 82 (New)
        acVp82 = 83 (New)
        acVp83 = 84 (New)
        acVp84 = 85 (New)
        acVp85 = 86 (New)
        acVp86 = 87 (New)
        acVp87 = 88 (New)
        acVp88 = 89 (New)
        acVp89 = 90 (New)
        acVp90 = 91 (New)
        acVp91 = 92 (New)
        acVp92 = 93 (New)
        acVp93 = 94 (New)
        acVp94 = 95 (New)
        acVp95 = 96 (New)
        acVp96 = 97 (New)
        acVp97 = 98 (New)
        acVp98 = 99 (New)
        acVp99 = 100 (New)
        acVp100 = 101 (New)
AcMLineJustification (New)
        acTop = 0
        acZero = 1
        acBottom = 2
AcBlockScaling (New)
        acAny = 0
        acUniform = 1
AcDynamicBlockReferencePropertyUnitsType (New)
        acNoUnits = 0
        acAngular = 1
        acDistance = 2
        acArea = 3

Classes

IAcadDynamicBlockReferenceProperty (New)
        PropertyName - Property
        ReadOnly - Property
        Show - Property
        Description - Property
        AllowedValues - Property
        Value - Property
        UnitsType - Property
IAcadAttribute2 (New)
        LockPosition - Property
IAcadAttributeReference2 (New)
        LockPosition - Property
IAcadBlockReference2 (New)
        EffectiveName - Property
        IsDynamicBlock - Property
        GetDynamicBlockProperties - Method
        ResetBlock - Method
        ConvertToAnonymousBlock - Method
        ConvertToStaticBlock - Method
        XEffectiveScaleFactor - Property
        YEffectiveScaleFactor - Property
        ZEffectiveScaleFactor - Property
        InsUnits - Property
        InsUnitsFactor - Property
IAcadHatch2 (New)
        Area - Property
        Origin - Property
IAcadMInsertBlock2 (New)
        EffectiveName - Property
        IsDynamicBlock - Property
        GetDynamicBlockProperties - Method
        ResetBlock - Method
        ConvertToAnonymousBlock - Method
        ConvertToStaticBlock - Method
        XEffectiveScaleFactor - Property
        YEffectiveScaleFactor - Property
        ZEffectiveScaleFactor - Property
        InsUnits - Property
        InsUnitsFactor - Property
IAcadMLine2 (New)
        Justification - Property
        MLineScale - Property
IAcadExternalReference2 (New)
        XEffectiveScaleFactor - Property
        YEffectiveScaleFactor - Property
        ZEffectiveScaleFactor - Property
        InsUnits - Property
        InsUnitsFactor - Property
IAcadTable2 (New)
        RegenerateTableSuppressed - Property
IAcadDimArcLength (New)
        AltUnits - Property
        AltUnitsPrecision - Property
        AltUnitsScale - Property
        AltRoundDistance - Property
        AltTolerancePrecision - Property
        AltUnitsFormat - Property
        AltTextPrefix - Property
        AltTextSuffix - Property
        DimensionLineColor - Property
        ExtensionLineColor - Property
        PrimaryUnitsPrecision - Property
        DimensionLineExtend - Property
        ExtensionLineExtend - Property
        Fit - Property
        FractionFormat - Property
        HorizontalTextPosition - Property
        LinearScaleFactor - Property
        UnitsFormat - Property
        ExtensionLineWeight - Property
        RoundDistance - Property
        DimLine1Suppress - Property
        DimLine2Suppress - Property
        ExtLine1Suppress - Property
        ExtLine2Suppress - Property
        DimLineInside - Property
        TextInsideAlign - Property
        TextInside - Property
        ForceLineInside - Property
        TextOutsideAlign - Property
        ExtensionLineOffset - Property
        AltSuppressLeadingZeros - Property
        AltSuppressTrailingZeros - Property
        AltSuppressZeroFeet - Property
        AltSuppressZeroInches - Property
        AltToleranceSuppressLeadingZeros - Property
        AltToleranceSuppressTrailingZeros - Property
        AltToleranceSuppressZeroFeet - Property
        AltToleranceSuppressZeroInches - Property
        SuppressZeroFeet - Property
        SuppressZeroInches - Property
        ToleranceSuppressZeroFeet - Property
        ToleranceSuppressZeroInches - Property
        DimensionLineWeight - Property
        ArrowheadSize - Property
        Arrowhead1Type - Property
        Arrowhead2Type - Property
        Measurement - Property
        Arrowhead1Block - Property
        Arrowhead2Block - Property
        ArcPoint - Property
        ExtLine1Point - Property
        ExtLine2Point - Property
        CenterPoint - Property
        Leader1Point - Property
        Leader2Point - Property
        IsPartial - Property
        ArcStartParam - Property
        ArcEndParam - Property
        HasLeader - Property
        SymbolPosition - Property
IAcadDimRadialLarge (New)
        AltUnits - Property
        AltUnitsPrecision - Property
        AltUnitsScale - Property
        AltRoundDistance - Property
        AltTolerancePrecision - Property
        AltUnitsFormat - Property
        AltTextPrefix - Property
        AltTextSuffix - Property
        CenterType - Property
        CenterMarkSize - Property
        DimensionLineColor - Property
        PrimaryUnitsPrecision - Property
        FractionFormat - Property
        Fit - Property
        LinearScaleFactor - Property
        UnitsFormat - Property
        RoundDistance - Property
        DimLineSuppress - Property
        TextInsideAlign - Property
        TextInside - Property
        ForceLineInside - Property
        TextOutsideAlign - Property
        AltSuppressLeadingZeros - Property
        AltSuppressTrailingZeros - Property
        AltSuppressZeroFeet - Property
        AltSuppressZeroInches - Property
        AltToleranceSuppressLeadingZeros - Property
        AltToleranceSuppressTrailingZeros - Property
        AltToleranceSuppressZeroFeet - Property
        AltToleranceSuppressZeroInches - Property
        SuppressZeroFeet - Property
        SuppressZeroInches - Property
        ToleranceSuppressZeroFeet - Property
        ToleranceSuppressZeroInches - Property
        DimensionLineWeight - Property
        ArrowheadSize - Property
        ArrowheadType - Property
        Measurement - Property
        ArrowheadBlock - Property
        OverrideCenter - Property
        JogLocation - Property
        JogAngle - Property
        Center - Property
        ChordPoint - Property
IAcadBlock3 (New)
        Comments - Property
        Units - Property
        Explodable - Property
        BlockScaling - Property
        IsDynamicBlock - Property
        AddDimArc - Method
        AddDimRadialLarge - Method
IAcadModelSpace3 (New)
        AddDimArc - Method
        AddDimRadialLarge - Method
IAcadPaperSpace3 (New)
        AddDimArc - Method
        AddDimRadialLarge - Method
IAcadUtility2 (New)
        SendModelessOperationStart - Property


AutoCAD 2007 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2007 and AutoCAD 2007-based products.

Enums

AcEntityName (Changed)
        acDwfUnderlay = 46 (New)
        acDgnUnderlay = 47 (New)
AcViewportScale (Changed)
        acVp1_1 = 2 (New)
        acVp1_2 = 3 (New)
        acVp1_4 = 4 (New)
        acVp1_8 = 5 (New)
        acVp1_10 = 6 (New)
        acVp1_16 = 7 (New)
        acVp1_20 = 8 (New)
        acVp1_30 = 9 (New)
        acVp1_40 = 10 (New)
        acVp1_50 = 11 (New)
        acVp1_100 = 12 (New)
        acVp2_1 = 13 (New)
        acVp4_1 = 14 (New)
        acVp8_1 = 15 (New)
        acVp10_1 = 16 (New)
        acVp100_1 = 17 (New)
        acVp1_128in_1ft = 18 (New)
        acVp1_64in_1ft = 19 (New)
        acVp1_32in_1ft = 20 (New)
        acVp1_16in_1ft = 21 (New)
        acVp3_32in_1ft = 22 (New)
        acVp1_8in_1ft = 23 (New)
        acVp3_16in_1ft = 24 (New)
        acVp1_4in_1ft = 25 (New)
        acVp3_8in_1ft = 26 (New)
        acVp1_2in_1ft = 27 (New)
        acVp3_4in_1ft = 28 (New)
        acVp1in_1ft = 29 (New)
        acVp1and1_2in_1ft = 30 (New)
        acVp3in_1ft = 31 (New)
        acVp6in_1ft = 32 (New)
        acVp1ft_1ft = 33 (New)
AcSaveAsType (Changed)
        ac2007_dwg = 36 (New)
        ac2007_dxf = 37 (New)
        ac2007_Template = 38 (New)
        acNative = 36 (Changed)
AcValueDataType (New)
        acUnknownDataType = 0
        acLong = 1
        acDouble = 2
        acString = 4
        acDate = 8
        acPoint2d = 16
        acPoint3d = 32
        acObjectId = 64
        acBuffer = 128
        acResbuf = 256
        acGeneral = 512
AcValueUnitType (New)
        acUnitless = 0
        acUnitDistance = 1
        acUnitAngle = 2
        acUnitArea = 4
        acUnitVolume = 8
AcParseOption (New)
        acParseOptionNone = 0
        acSetDefaultFormat = 1
        acPreserveMtextFormat = 2
AcFormatOption (New)
        kFormatOptionNone = 0
        acForEditing = 1
        acForExpression = 2
        acUseMaximumPrecision = 4
        acIgnoreMtextFormat = 8
AcTableStyleOverrides (Changed)
        acTitleRowDataType = 24 (New)
        acHeaderRowDataType = 25 (New)
        acDataRowDataType = 26 (New)
        acCellDataType = 148 (New)
AcSectionState (New)
        acSectionStatePlane = 1
        acSectionStateBoundary = 2
        acSectionStateVolume = 4
AcSectionSubItem (New)
        acSectionSubItemkNone = 0
        acSectionSubItemSectionLine = 1
        acSectionSubItemSectionLineTop = 2
        acSectionSubItemSectionLineBottom = 4
        acSectionSubItemBackLine = 8
        acSectionSubItemBackLineTop = 16
        acSectionSubItemBackLineBottom = 32
        acSectionSubItemVerticalLineTop = 64
        acSectionSubItemVerticalLineBottom = 128
AcSectionType (New)
        acSectionTypeLiveSection = 1
        acSectionType2dSection = 2
        acSectionType3dSection = 4
AcSectionGeneration (New)
        acSectionGenerationSourceAllObjects = 1
        acSectionGenerationSourceSelectedObjects = 2
        acSectionGenerationDestinationNewBlock = 16
        acSectionGenerationDestinationReplaceBlock = 32
        acSectionGenerationDestinationFile = 64
AcHelixConstrainType (New)
        acTurnHeight = 0
        acTurns = 1
        acHeight = 2
AcShadowDisplayType (New)
        acCastsAndReceivesShadows = 0
        acCastsShadows = 1
        acReceivesShadows = 2
        acIgnoreShadows = 3
AcLoftedSurfaceNormalType (New)
        acRuled = 0
        acSmooth = 1
        acFirstNormal = 2
        acLastNormal = 3
        acEndsNormal = 4
        acAllNormal = 5
        acUseDraftAngles = 6
AcHelixTwistType (New)
        acCCW = 0
        acCW = 1

Classes

IAcadDatabase (Changed)
        SectionManager - Property (New)
        Materials - Property (New)
IAcadBlock (Changed)
        AddTable - Method (Moved from IAcadBlock2)
        Path - Property (Moved from IAcadBlock2)
        Comments - Property (Moved from IAcadBlock3)
        Units - Property (Moved from IAcadBlock3)
        Explodable - Property (Moved from IAcadBlock3)
        BlockScaling - Property (Moved from IAcadBlock3)
        IsDynamicBlock - Property (Moved from IAcadBlock3)
        AddDimArc - Method (Moved from IAcadBlock3)
        AddDimRadialLarge - Method (Moved from IAcadBlock3)
        AddSection - Method (New)
IAcadEntity (Changed)
        Material - Property (New)
IAcadAttribute (Changed)
        LockPosition - Property (Moved from IAcadAttribute2)
IAcadAttributeReference (Changed)
        LockPosition - Property (Moved from IAcadAttributeReference2)
IAcad3DSolid (Changed)
        SolidType - Property (New)
        Position - Property (New)
        History - Property (New)
        ShowHistory - Property (New)
IAcadDimAligned (Changed)
        DimensionLinetype - Property (New)
        ExtLine1Linetype - Property (New)
        ExtLine2Linetype - Property (New)
        ExtLineFixedLenSuppress - Property (New)
        ExtLineFixedLen - Property (New)
IAcadDimension (Changed)
        TextFill - Property (New)
        TextFillColor - Property (New)
IAcadDimAngular (Changed)
        DimensionLinetype - Property (New)
        ExtLine1Linetype - Property (New)
        ExtLine2Linetype - Property (New)
        ExtLineFixedLenSuppress - Property (New)
        ExtLineFixedLen - Property (New)
IAcadDimDiametric (Changed)
        DimensionLinetype - Property (New)
IAcadDimRotated (Changed)
        DimensionLinetype - Property (New)
        ExtLine1Linetype - Property (New)
        ExtLine2Linetype - Property (New)
        ExtLineFixedLenSuppress - Property (New)
        ExtLineFixedLen - Property (New)
IAcadDimOrdinate (Changed)
        ExtLineFixedLenSuppress - Property (New)
        ExtLineFixedLen - Property (New)
IAcadDimRadial (Changed)
        DimensionLinetype - Property (New)
IAcadMText (Changed)
        BackgroundFill - Property (Moved from IAcadMText2)
        FieldCode - Method (Moved from IAcadMText2)
IAcadText (Changed)
        FieldCode - Method (Moved from IAcadText2)
IAcadBlockReference (Changed)
        EffectiveName - Property (Moved from IAcadBlockReference2)
        IsDynamicBlock - Property (Moved from IAcadBlockReference2)
        GetDynamicBlockProperties - Method (Moved from IAcadBlockReference2)
        ResetBlock - Method (Moved from IAcadBlockReference2)
        ConvertToAnonymousBlock - Method (Moved from IAcadBlockReference2)
        ConvertToStaticBlock - Method (Moved from IAcadBlockReference2)
        XEffectiveScaleFactor - Property (Moved from IAcadBlockReference2)
        YEffectiveScaleFactor - Property (Moved from IAcadBlockReference2)
        ZEffectiveScaleFactor - Property (Moved from IAcadBlockReference2)
        InsUnits - Property (Moved from IAcadBlockReference2)
        InsUnitsFactor - Property (Moved from IAcadBlockReference2)
IAcadHatch (Changed)
        Area - Property (Moved from IAcadHatch2)
        Origin - Property (Moved from IAcadHatch2)
IAcadMLine (Changed)
        Justification - Property (Moved from IAcadMLine2)
        MLineScale - Property (Moved from IAcadMLine2)
IAcadDim3PointAngular (Changed)
        DimensionLinetype - Property (New)
        ExtLine1Linetype - Property (New)
        ExtLine2Linetype - Property (New)
        ExtLineFixedLenSuppress - Property (New)
        ExtLineFixedLen - Property (New)
IAcadExternalReference (Changed)
        XEffectiveScaleFactor - Property (Moved from IAcadExternalReference2)
        YEffectiveScaleFactor - Property (Moved from IAcadExternalReference2)
        ZEffectiveScaleFactor - Property (Moved from IAcadExternalReference2)
        InsUnits - Property (Moved from IAcadExternalReference2)
        InsUnitsFactor - Property (Moved from IAcadExternalReference2)
IAcadTable (Changed)
        RegenerateTableSuppressed - Property (Moved from IAcadTable2)
        GetDataType - Method (New)
        SetDataType - Method (New)
        GetFormat - Method (New)
        SetFormat - Method (New)
        FormatValue - Method (New)
        GetCellDataType - Method (New)
        SetCellDataType - Method (New)
        GetCellFormat - Method (New)
        SetCellFormat - Method (New)
        GetCellValue - Method (New)
        SetCellValue - Method (New)
        SetCellValueFromText - Method (New)
        ResetCellValue - Method (New)
IAcadDimArcLength (Changed)
        SymbolPosition - Property (New)
        DimensionLinetype - Property (New)
        ExtLine1Linetype - Property (New)
        ExtLine2Linetype - Property (New)
        ExtLineFixedLenSuppress - Property (New)
        ExtLineFixedLen - Property (New)
IAcadDimRadialLarge (Changed)
        DimensionLinetype - Property (New)
IAcadSection (New)
        Name - Property
        State - Property
        ViewingDirection - Property
        VerticalDirection - Property
        Normal - Property
        LiveSectionEnabled - Property
        IndicatorTransparency - Property
        IndicatorFillColor - Property
        Elevation - Property
        TopHeight - Property
        BottomHeight - Property
        NumVertices - Property
        Vertices - Property
        Coordinate - Property
        AddVertex - Method
        RemoveVertex - Method
        HitTest - Method
        CreateJog - Method
        Settings - Property
        GenerateSectionGeometry - Method
IAcadSectionSettings (New)
        CurrentSectionType - Property
        GetSectionTypeSettings - Method
IAcadSectionTypeSettings (New)
        GenerationOptions - Property
        SourceObjects - Property
        DestinationBlock - Property
        DestinationFile - Property
        IntersectionBoundaryColor - Property
        IntersectionBoundaryLayer - Property
        IntersectionBoundaryLinetype - Property
        IntersectionBoundaryLinetypeScale - Property
        IntersectionBoundaryPlotStyleName - Property
        IntersectionBoundaryLineweight - Property
        IntersectionBoundaryDivisionLines - Property
        IntersectionFillVisible - Property
        IntersectionFillHatchPatternType - Property
        IntersectionFillHatchPatternName - Property
        IntersectionFillHatchAngle - Property
        IntersectionFillHatchScale - Property
        IntersectionFillHatchSpacing - Property
        IntersectionFillColor - Property
        IntersectionFillLayer - Property
        IntersectionFillLinetype - Property
        IntersectionFillLinetypeScale - Property
        IntersectionFillPlotStyleName - Property
        IntersectionFillLineweight - Property
        IntersectionFillFaceTransparency - Property
        BackgroundLinesVisible - Property
        BackgroundLinesHiddenLine - Property
        BackgroundLinesColor - Property
        BackgroundLinesLayer - Property
        BackgroundLinesLinetype - Property
        BackgroundLinesLinetypeScale - Property
        BackgroundLinesPlotStyleName - Property
        BackgroundLinesLineweight - Property
        ForegroundLinesVisible - Property
        ForegroundLinesHiddenLine - Property
        ForegroundLinesColor - Property
        ForegroundLinesLayer - Property
        ForegroundLinesLinetype - Property
        ForegroundLinesLinetypeScale - Property
        ForegroundLinesPlotStyleName - Property
        ForegroundLinesLineweight - Property
        ForegroundLinesFaceTransparency - Property
        ForegroundLinesEdgeTransparency - Property
        CurveTangencyLinesVisible - Property
        CurveTangencyLinesColor - Property
        CurveTangencyLinesLayer - Property
        CurveTangencyLinesLinetype - Property
        CurveTangencyLinesLinetypeScale - Property
        CurveTangencyLinesPlotStyleName - Property
        CurveTangencyLinesLineweight - Property
IAcadPViewport (Changed)
        VisualStyle - Property (New)
        ModelView - Property (Moved from IAcadPViewport2)
        SheetView - Property (Moved from IAcadPViewport2)
        LabelBlockId - Property (Moved from IAcadPViewport2)
        HasSheetView - Property (Moved from IAcadPViewport2)
        SyncModelView - Method (Moved from IAcadPViewport2)
IAcadView (Changed)
        CategoryName - Property (Moved from IAcadView2)
        LayoutId - Property (Moved from IAcadView2)
        LayerState - Property (Moved from IAcadView2)
        HasVpAssociation - Property (Moved from IAcadView2)
IAcadGroup (Changed)
        Material - Property (New)
IAcadLayers (Changed)
        GenerateUsageData - Method (Moved from IAcadLayers2)
IAcadLayer (Changed)
        Description - Property (Moved from IAcadLayer2)
        Used - Property (Moved from IAcadLayer2)
        Material - Property (New)
IAcadSectionManager (New)
        Item - Method
        Count - Property
        GetLiveSection - Method
        GetUniqueSectionName - Method
IAcadMaterials (New)
        Item - Method
        Count - Property
        Add - Method
IAcadMaterial (New)
        Description - Property
        Name - Property
IAcadTableStyle (Changed)
        GetDataType - Method (New)
        SetDataType - Method (New)
        GetFormat - Method (New)
        SetFormat - Method (New)
IAcadShadowDisplay (New)
        ShadowDisplay - Property
        EnableShadowDisplay - Property
IAcadMInsertBlock (Changed)
        EffectiveName - Property (Moved from IAcadMInsertBlock2)
        IsDynamicBlock - Property (Moved from IAcadMInsertBlock2)
        GetDynamicBlockProperties - Method (Moved from IAcadMInsertBlock2)
        ResetBlock - Method (Moved from IAcadMInsertBlock2)
        ConvertToAnonymousBlock - Method (Moved from IAcadMInsertBlock2)
        ConvertToStaticBlock - Method (Moved from IAcadMInsertBlock2)
        XEffectiveScaleFactor - Property (Moved from IAcadMInsertBlock2)
        YEffectiveScaleFactor - Property (Moved from IAcadMInsertBlock2)
        ZEffectiveScaleFactor - Property (Moved from IAcadMInsertBlock2)
        InsUnits - Property (Moved from IAcadMInsertBlock2)
        InsUnitsFactor - Property (Moved from IAcadMInsertBlock2)
IAcadHelix (New)
        Position - Property
        Constrain - Property
        Height - Property
        Turns - Property
        TurnHeight - Property
        BaseRadius - Property
        TopRadius - Property
        Twist - Property
        TurnSlope - Property
        TotalLength - Property
IAcadSurface (New)
        SurfaceType - Property
        UIsolineDensity - Property
        VIsolineDensity - Property
IAcadPlaneSurface (New)
IAcadExtrudedSurface (New)
        Height - Property
        TaperAngle - Property
        Direction - Property
IAcadRevolvedSurface (New)
        RevolutionAngle - Property
        AxisPosition - Property
        AxisDirection - Property
IAcadSweptSurface (New)
        ProfileRotation - Property
        Bank - Property
        Twist - Property
        scale - Property
        Length - Property
IAcadLoftedSurface (New)
        NumCrossSections - Property
        NumGuidePaths - Property
        SurfaceNormals - Property
        StartDraftAngle - Property
        StartDraftMagnitude - Property
        EndDraftAngle - Property
        EndDraftMagnitude - Property
        Closed - Property
IAcadUnderlay (New)
        Contrast - Property
        Fade - Property
        Position - Property
        Rotation - Property
        Width - Property
        Height - Property
        UnderlayName - Property
        ItemName - Property
        Monochrome - Property
        AdjustForBackground - Property
        ClipBoundary - Method
        ScaleFactor - Property
        File - Property
        UnderlayVisibility - Property
        ClippingEnabled - Property
IAcadSubEntity (New)
        OnModified - Event
        ObjectName - Property
        color - Property
        Layer - Property
        Linetype - Property
        LinetypeScale - Property
        PlotStyleName - Property
        Lineweight - Property
        Hyperlinks - Property
IAcadSubEntSolidFace (New)
        Material - Property
IAcadSubEntSolidEdge (New)
IAcadSubEntSolidVertex (New)
IAcadSubEntSolidNode (New)
IAcadModelSpace (Changed)
        AddTable - Method (Moved from IAcadModelSpace2)
        AddDimArc - Method (Moved from IAcadModelSpace3)
        AddDimRadialLarge - Method (Moved from IAcadModelSpace3)
IAcadPaperSpace (Changed)
        AddTable - Method (Moved from IAcadPaperSpace2)
        AddDimArc - Method (Moved from IAcadPaperSpace3)
        AddDimRadialLarge - Method (Moved from IAcadPaperSpace3)
IAcadDocument (Changed)
        ActiveMaterial - Property (New)
IAcadPreferencesFiles (Changed)
        EnterpriseMenuFile - Property (New)
        CustomIconPath - Property (New)
        QNewTemplateFile - Property (Moved from IAcadPreferencesFiles2)
        PlotLogFilePath - Property (Moved from IAcadPreferencesFiles2)
        PageSetupOverridesTemplateFile - Property (Moved from IAcadPreferencesFiles2)
IAcadPreferencesOutput (Changed)
        ContinuousPlotLog - Property (Moved from IAcadPreferencesOutput2)
        AutomaticPlotLog - Property (Moved from IAcadPreferencesOutput2)
        DefaultPlotToFilePath - Property (Moved from IAcadPreferencesOutput2)
IAcadUtility (Changed)
        SendModelessOperationStart - Property (Moved from IAcadUtility2)

The following classes were removed/merged with their parent classes:

IAcadLayer2 (Removed - Moved to IAcadLayer)
IAcadView2 (Removed - Moved to IAcadView)
IAcadLayers2 (Removed - Moved to IAcadLayers)
IAcadAttribute2 (Removed - Moved to IAcadAttribute)
IAcadAttributeReference2 (Removed - Moved to IAcadAttributeReference)
IAcadBlockReference2 (Removed - Moved to IAcadBlockReference)
IAcadHatch2 (Removed - Moved to IAcadHatch)
IAcadMText2 (Removed - Moved to IAcadMText)
IAcadText2 (Removed - Moved to IAcadText)
IAcadPViewport2 (Removed - Moved to IAcadPViewport)
IAcadMInsertBlock2 (Removed - Moved to IAcadMInsertBlock)
IAcadMLine2 (Removed - Moved to IAcadMLine)
IAcadExternalReference2 (Removed - Moved to IAcadExternalReference)
IAcadTable2 (Removed - Moved to IAcadTable)
IAcadBlock2 (Removed - Moved to IAcadBlock)
IAcadBlock3 (Removed - Moved to IAcadBlock)
IAcadModelSpace2 (Removed - Moved to IAcadModelSpace)
IAcadModelSpace3 (Removed - Moved to IAcadModelSpace)
IAcadPaperSpace2 (Removed - Moved to IAcadPaperSpace)
IAcadPaperSpace3 (Removed - Moved to IAcadPaperSpace)
IAcadPreferencesFiles2 (Removed - Moved to IAcadPreferencesFiles)
IAcadPreferencesOutput2 (Removed - Moved to IAcadPreferencesOutput)
IAcadUtility2 (Removed - Moved to IAcadUtility)


AutoCAD 2008 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2008 and AutoCAD 2008-based products.

Enums

AcEntityName (Changed)
        acMLeader = 48 (New)
AcAttributeMode (Changed)
        acAttributeModeLockPosition = 16 (New)
        acAttributeModeMultipleLine = 32 (New)
AcMergeCellStyleOption (New)
        acMergeCellStyleNone = 0
        acMergeCellStyleCopyDuplicates = 1
        acMergeCellStyleOverwriteDuplicates = 2
        acMergeCellStyleConvertDuplicatesToOverrides = 4
        acMergeCellStyleIgnoreNewStyles = 8
AcUnderlayLayerOverrideType (New)
        acNoOverrides = 0
        acApplied = 1
AcTableFlowDirection (New)
        acTableFlowRight = 1
        acTableFlowDownOrUp = 2
        acTableFlowLeft = 4
AcCellMargin (New)
        acCellMarginTop = 1
        acCellMarginLeft = 2
        acCellMarginBottom = 4
        acCellMarginRight = 8
        acCellMarginHorzSpacing = 16
        acCellMarginVertSpacing = 32
AcCellContentLayout (New)
        acCellContentLayoutFlow = 1
        acCellContentLayoutStackedHorizontal = 2
        acCellContentLayoutStackedVertical = 4
AcCellProperty (New)
        acInvalidCellProperty = 0
        acLock = 1
        acDataType = 2
        acDataFormat = 4
        acRotation = 8
        acScale = 16
        acAlignmentProperty = 32
        acContentColor = 64
        acBackgroundColor = 128
        acTextStyle = 256
        acTextHeight = 512
        acMarginLeft = 1024
        acMarginTop = 2048
        acMarginRight = 4096
        acMarginBottom = 8192
        acEnableBackgroundColor = 16384
        acAutoScale = 32768
        acMergeAll = 0x00010000
        acFlowDirBtoT = 0x00020000
        acContentLayout = 0x00040000
        acDataTypeAndFormat = 6
        acContentProperties = 33662
        acBitProperties = 0x0003c000
        acAllCellProperties = 0x0007ffff
AcGridLineStyle (New)
        acGridLineStyleSingle = 1
        acGridLineStyleDouble = 2
AcDataLinkUpdateDirection (New)
        acUpdateDataFromSource = 1
        acUpdateSourceFromData = 2
AcDataLinkUpdateOption (New)
        acUpdateOptionNone = 0
        acUpdateOptionOverwriteContentModifiedAfterUpdate = 0x00020000
        acUpdateOptionOverwriteFormatModifiedAfterUpdate = 0x00040000
        acUpdateOptionUpdateFullSourceRange = 0x00080000
        acUpdateOptionIncludeXrefs = 0x00100000
AcCellContentType (New)
        acCellContentTypeUnknown = 0
        acCellContentTypeValue = 1
        acCellContentTypeField = 2
        acCellContentTypeBlock = 4
AcCellState (New)
        acCellStateNone = 0
        acCellStateContentLocked = 1
        acCellStateContentReadOnly = 2
        acCellStateFormatLocked = 4
        acCellStateFormatReadOnly = 8
        acCellStateLinked = 16
        acCellStateContentModified = 32
        acCellStateFormatModified = 64
AcCellOption (New)
        kCellOptionNone = 0
        kInheritCellFormat = 1
AcTextAttachmentType (New)
        acAttachmentTopOfTop = 0
        acAttachmentMiddleOfTop = 1
        acAttachmentBottomOfTop = 2
        acAttachmentBottomOfTopLine = 3
        acAttachmentMiddle = 4
        acAttachmentMiddleOfBottom = 5
        acAttachmentBottomOfBottom = 6
        acAttachmentBottomLine = 7
        acAttachmentAllLine = 8
AcMLeaderType (New)
        acStraightLeader = 1
        acSplineLeader = 2
        acInVisibleLeader = 0
AcMLeaderContentType (New)
        acNoneContent = 0
        acBlockContent = 1
        acMTextContent = 2
AcTextAlignmentType (New)
        acLeftAlignment = 0
        acCenterAlignment = 1
        acRightAlignment = 2
AcTextAngleType (New)
        acInsertAngle = 0
        acHorizontalAngle = 1
        acAlwaysRightReadingAngle = 2
AcBlockConnectionType (New)
        acConnectExtents = 0
        acConnectBase = 1
AcPredefBlockType (New)
        acBlockImperial = 0
        acBlockSlot = 1
        acBlockCircle = 2
        acBlockBox = 3
        acBlockHexagon = 4
        acBlockTriangle = 5
        acBlockUserDefined = 6
AcDrawLeaderOrderType (New)
        acDrawLeaderHeadFirst = 0
        acDrawLeaderTailFirst = 1
AcDrawMLeaderOrderType (New)
        acDrawContentFirst = 0
        acDrawLeaderFirst = 1
AcSegmentAngleType (New)
        acDegreesAny = 0
        acDegrees15 = 1
        acDegrees30 = 2
        acDegrees45 = 3
        acDegrees60 = 4
        acDegrees90 = 6
        acDegreesHorz = 12

Classes

IAcadObject (Changed)
        ObjectID - Property (Changed to support 64-bit)
        OwnerID - Property (Changed to support 64-bit)
        ObjectID32 - Property (New)
        OwnerID32 - Property (New)
IAcadDatabase (Changed)
        ObjectIdToObject - Method (Changed to support 64-bit)
        ObjectIdToObject32 - Method (Changed)
IAcadTable (Changed)
        GetBlockTableRecordId - Method (Changed to support 64-bit)
        SetBlockTableRecordId - Method (Changed to support 64-bit)
        GetBlockAttributeValue - Method (Changed to support 64-bit)
        SetBlockAttributeValue - Method (Changed to support 64-bit)
        GetFieldId - Method (Changed to support 64-bit)
        SetFieldId - Method (Changed to support 64-bit)
        GetBlockTableRecordId32 - Method (New)
        SetBlockTableRecordId32 - Method (New)
        GetBlockAttributeValue32 - Method (New)
        SetBlockAttributeValue32 - Method (New)
        GetFieldId32 - Method (New)
        SetFieldId32 - Method (New)
IAcadPViewport (Changed)
        LabelBlockId - Property (Changed to support 64-bit)
        LabelBlockId32 - Property (New)
IAcadView (Changed)
        LayoutId - Property (Changed to support 64-bit)
        LayoutId32 - Property (New)
IAcadSectionTypeSettings2 (New)
        IntersectionBoundaryVisible - Property (New)
IAcadIdPair (Changed)
        key - Property (Changed to support 64-bit)
        Value - Property (Changed to support 64-bit)
        Key32 - Property (New)
        Value32 - Property (New)
IAcadTableStyle2 (New)
        CreateCellStyle - Method
        CreateCellStyleFromStyle - Method
        RenameCellStyle - Method
        DeleteCellStyle - Method
        GetUniqueCellStyleName - Method
        GetIsCellStyleInUse - Method
        NumCellStyles - Property
        GetCellStyles - Method
        GetTextStyleId - Method
        SetTextStyleId - Method
        GetTextHeight2 - Method
        SetTextHeight2 - Method
        GetAlignment2 - Method
        SetAlignment2 - Method
        GetColor2 - Method
        SetColor2 - Method
        GetBackgroundColor2 - Method
        SetBackgroundColor2 - Method
        GetDataType2 - Method
        SetDataType2 - Method
        GetFormat2 - Method
        SetFormat2 - Method
        GetCellClass - Method
        SetCellClass - Method
        GetRotation - Method
        SetRotation - Method
        GetIsMergeAllEnabled - Method
        EnableMergeAll - Method
        GetGridLineWeight2 - Method
        SetGridLineWeight2 - Method
        GetGridColor2 - Method
        SetGridColor2 - Method
        GetGridVisibility2 - Method
        SetGridVisibility2 - Method
        TemplateId - Property
        SetTemplateId - Method
        GetTextStyleId32 - Method
        SetTextStyleId32 - Method
        TemplateId32 - Property
        SetTemplateId32 - Method
IAcadMLeaderStyle (New)
        Name - Property
        Description - Property
        BitFlags - Property
        ContentType - Property
        DrawMLeaderOrderType - Property
        DrawLeaderOrderType - Property
        MaxLeaderSegmentsPoints - Property
        FirstSegmentAngleConstraint - Property
        SecondSegmentAngleConstraint - Property
        LeaderLineType - Property
        LeaderLineColor - Property
        LeaderLineTypeId - Property
        LeaderLineWeight - Property
        EnableLanding - Property
        LandingGap - Property
        EnableDogleg - Property
        DoglegLength - Property
        ArrowSymbol - Property
        ArrowSize - Property
        TextStyle - Property
        TextLeftAttachmentType - Property
        TextRightAttachmentType - Property
        TextColor - Property
        TextHeight - Property
        EnableFrameText - Property
        AlignSpace - Property
        Block - Property
        BlockColor - Property
        EnableBlockScale - Property
        BlockScale - Property
        EnableBlockRotation - Property
        BlockRotation - Property
        BlockConnectionType - Property
        ScaleFactor - Property
        OverwritePropChanged - Property
        Annotative - Property
        BreakSize - Property
        TextString - Property
        TextAngleType - Property
        TextAlignmentType - Property
IAcadAttribute2 (New)
        MTextAttribute - Property
        MTextAttributeContent - Property
        UpdateMTextAttribute - Method
        MTextBoundaryWidth - Property
        MTextDrawingDirection - Property
IAcadAttributeReference2 (New)
        MTextAttribute - Property
        MTextAttributeContent - Property
        UpdateMTextAttribute - Method
        MTextBoundaryWidth - Property
        MTextDrawingDirection - Property
IAcadMLeader (New)
        ScaleFactor - Property
        LeaderType - Property
        LeaderLineColor - Property
        LeaderLineType - Property
        LeaderLineWeight - Property
        ArrowheadType - Property
        ArrowheadSize - Property
        DogLegged - Property
        DoglegLength - Property
        ContentBlockName - Property
        BlockConnectionType - Property
        TextString - Property
        TextStyleName - Property
        TextJustify - Property
        TextDirection - Property
        TextWidth - Property
        TextHeight - Property
        TextRotation - Property
        TextLineSpacingFactor - Property
        TextLineSpacingDistance - Property
        TextLineSpacingStyle - Property
        TextBackgroundFill - Property
        TextLeftAttachmentType - Property
        TextRightAttachmentType - Property
        LandingGap - Property
        ArrowheadBlock - Property
        ContentBlockType - Property
        LeaderCount - Property
        AddLeader - Method
        RemoveLeader - Method
        AddLeaderLine - Method
        AddLeaderLineEx - Method
        RemoveLeaderLine - Method
        SetLeaderLineVertices - Method
        GetLeaderLineVertices - Method
        ContentType - Property
        GetLeaderIndex - Method
        GetLeaderLineIndexes - Method
        GetVertexCount - Method
        TextFrameDisplay - Property
        StyleName - Property
        GetDoglegDirection - Method
        SetDoglegDirection - Method
        GetBlockAttributeValue - Method
        SetBlockAttributeValue - Method
        GetBlockAttributeValue32 - Method
        SetBlockAttributeValue32 - Method
IAcadPViewport2 (New)
        LayerPropertyOverrides - Property
IAcadTable2 (New)
        IsEmpty - Method
        CreateContent - Method
        MoveContent - Method
        DeleteContent - Method
        GetValue - Method
        SetValue - Method
        SetValueFromText - Method
        GetDataFormat - Method
        SetDataFormat - Method
        GetTextString - Method
        SetTextString - Method
        GetFieldId2 - Method
        SetFieldId2 - Method
        GetBlockTableRecordId2 - Method
        SetBlockTableRecordId2 - Method
        GetBlockAttributeValue2 - Method
        SetBlockAttributeValue2 - Method
        GetCustomData - Method
        SetCustomData - Method
        GetCellStyle - Method
        SetCellStyle - Method
        GetContentColor2 - Method
        SetContentColor2 - Method
        GetDataType2 - Method
        SetDataType2 - Method
        GetTextStyle2 - Method
        SetTextStyle2 - Method
        GetTextHeight2 - Method
        SetTextHeight2 - Method
        GetRotation - Method
        SetRotation - Method
        GetAutoScale2 - Method
        SetAutoScale2 - Method
        GetScale - Method
        SetScale - Method
        RemoveAllOverrides - Method
        GetGridLineWeight2 - Method
        SetGridLineWeight2 - Method
        GetGridLinetype - Method
        SetGridLinetype - Method
        GetGridColor2 - Method
        SetGridColor2 - Method
        GetGridVisibility2 - Method
        SetGridVisibility2 - Method
        GetGridDoubleLineSpacing - Method
        SetGridDoubleLineSpacing - Method
        EnableBreak - Property
        GetBreakHeight - Method
        SetBreakHeight - Method
        GetContentType - Method
        GetMargin - Method
        SetMargin - Method
        GetContentLayout - Method
        SetContentLayout - Method
        GetOverride - Method
        SetOverride - Method
        GetGridLineStyle - Method
        SetGridLineStyle - Method
        InsertRowsAndInherit - Method
        InsertColumnsAndInherit - Method
        GetHasFormula - Method
        GetFormula - Method
        SetFormula - Method
        IsContentEditable - Method
        IsFormatEditable - Method
        GetCellState - Method
        SetCellState - Method
        EnableMergeAll - Method
        IsMergeAllEnabled - Method
        BreaksEnabled - Property
        RepeatTopLabels - Property
        RepeatBottomLabels - Property
        TableBreakFlowDirection - Property
        AllowManualPositions - Property
        AllowManualHeights - Property
        TableBreakHeight - Property
        BreakSpacing - Property
        GetColumnName - Method
        SetColumnName - Method
        SetToolTip - Method
        GetFieldId232 - Method
        SetFieldId232 - Method
        GetBlockTableRecordId232 - Method
        SetBlockTableRecordId232 - Method
        GetBlockAttributeValue232 - Method
        SetBlockAttributeValue232 - Method
        GetGridLinetype32 - Method
        SetGridLinetype32 - Method
IAcadUnderlay2 (New)
        UnderlayLayerOverrideApplied - Property
IAcadBlock2 (New)
        AddMLeader - Method
IAcadModelSpace2 (New)
        AddMLeader - Method
IAcadPaperSpace2 (New)
        AddMLeader - Method
IAcadDocument (Changed)
        HWND - Property (Changed to support 64-bit)
        HWND32 - Property (New)
IAcadApplication (Changed)
        HWND - Property (Changed to support 64-bit)
        HWND32 - Property (New)


AutoCAD 2009 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2009 and AutoCAD 2009-based products.

Enums

No changes

Classes

IAcadUnderlay3 (New)
        DWFFormat - Property
IAcadWipeout (New)
IAcadUtility2 (New)
        GetSubEntity32 - Method
        ObjectId32ToObjectIdString - Method
        GetObjectIdString - Method
IAcadToolbarItem2 (New)
        CommandDisplayName - Property


AutoCAD 2010 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2010 and AutoCAD 2010-based products.

Enums

AcEntityName (Changed)
        acSubDMesh = 49 (New)
        acPdfUnderlay = 50 (New)
AcPlotScale (Changed)
        ac1_8 = 19 (Removed)
        ac1_10 = 20 (Removed)
        ac1_16 = 21 (Removed)
        ac1_20 = 22 (Removed)
        ac1_30 = 23 (Removed)
        ac1_40 = 24 (Removed)
        ac1_50 = 25 (Removed)
        ac1_100 = 26 (Removed)
        ac2_1 = 27 (Removed)
        ac4_1 = 28 (Removed)
        ac8_1 = 29 (Removed)
        ac10_1 = 30 (Removed)
        ac100_1 = 31 (Removed)
        ac1_5 = 19 (New)
        ac1_8 = 20 (New)
        ac1_10 = 21 (New)
        ac1_16 = 22 (New)
        ac1_20 = 23 (New)
        ac1_30 = 24 (New)
        ac1_40 = 25 (New)
        ac1_50 = 26 (New)
        ac1_100 = 27 (New)
        ac2_1 = 28 (New)
        ac4_1 = 29 (New)
        ac8_1 = 30 (New)
        ac10_1 = 31 (New)
        ac100_1 = 32 (New)
AcDimVerticalJustification (Changed)
        acUnder = 4 (New)
AcViewportScale (Changed)
        acVp1 = 2 (Removed)
        acVp2 = 3 (Removed)
        acVp3 = 4 (Removed)
        acVp4 = 5 (Removed)
        acVp5 = 6 (Removed)
        acVp6 = 7 (Removed)
        acVp7 = 8 (Removed)
        acVp8 = 9 (Removed)
        acVp9 = 10 (Removed)
        acVp10 = 11 (Removed)
        acVp11 = 12 (Removed)
        acVp12 = 13 (Removed)
        acVp13 = 14 (Removed)
        acVp14 = 15 (Removed)
        acVp15 = 16 (Removed)
        acVp16 = 17 (Removed)
        acVp17 = 18 (Removed)
        acVp18 = 19 (Removed)
        acVp19 = 20 (Removed)
        acVp20 = 21 (Removed)
        acVp21 = 22 (Removed)
        acVp22 = 23 (Removed)
        acVp23 = 24 (Removed)
        acVp24 = 25 (Removed)
        acVp25 = 26 (Removed)
        acVp26 = 27 (Removed)
        acVp27 = 28 (Removed)
        acVp28 = 29 (Removed)
        acVp29 = 30 (Removed)
        acVp30 = 31 (Removed)
        acVp31 = 32 (Removed)
        acVp32 = 33 (Removed)
        acVp33 = 34 (Removed)
        acVp34 = 35 (Removed)
        acVp35 = 36 (Removed)
        acVp36 = 37 (Removed)
        acVp37 = 38 (Removed)
        acVp38 = 39 (Removed)
        acVp39 = 40 (Removed)
        acVp40 = 41 (Removed)
        acVp41 = 42 (Removed)
        acVp42 = 43 (Removed)
        acVp43 = 44 (Removed)
        acVp44 = 45 (Removed)
        acVp45 = 46 (Removed)
        acVp46 = 47 (Removed)
        acVp47 = 48 (Removed)
        acVp48 = 49 (Removed)
        acVp49 = 50 (Removed)
        acVp50 = 51 (Removed)
        acVp51 = 52 (Removed)
        acVp52 = 53 (Removed)
        acVp53 = 54 (Removed)
        acVp54 = 55 (Removed)
        acVp55 = 56 (Removed)
        acVp56 = 57 (Removed)
        acVp57 = 58 (Removed)
        acVp58 = 59 (Removed)
        acVp59 = 60 (Removed)
        acVp60 = 61 (Removed)
        acVp61 = 62 (Removed)
        acVp62 = 63 (Removed)
        acVp63 = 64 (Removed)
        acVp64 = 65 (Removed)
        acVp65 = 66 (Removed)
        acVp66 = 67 (Removed)
        acVp67 = 68 (Removed)
        acVp68 = 69 (Removed)
        acVp69 = 70 (Removed)
        acVp70 = 71 (Removed)
        acVp71 = 72 (Removed)
        acVp72 = 73 (Removed)
        acVp73 = 74 (Removed)
        acVp74 = 75 (Removed)
        acVp75 = 76 (Removed)
        acVp76 = 77 (Removed)
        acVp77 = 78 (Removed)
        acVp78 = 79 (Removed)
        acVp79 = 80 (Removed)
        acVp80 = 81 (Removed)
        acVp81 = 82 (Removed)
        acVp82 = 83 (Removed)
        acVp83 = 84 (Removed)
        acVp84 = 85 (Removed)
        acVp85 = 86 (Removed)
        acVp86 = 87 (Removed)
        acVp87 = 88 (Removed)
        acVp88 = 89 (Removed)
        acVp89 = 90 (Removed)
        acVp90 = 91 (Removed)
        acVp91 = 92 (Removed)
        acVp92 = 93 (Removed)
        acVp93 = 94 (Removed)
        acVp94 = 95 (Removed)
        acVp95 = 96 (Removed)
        acVp96 = 97 (Removed)
        acVp97 = 98 (Removed)
        acVp98 = 99 (Removed)
        acVp99 = 100 (Removed)
        acVp100 = 101 (Removed)
        acVp1_8 = 5 (Removed)
        acVp1_10 = 6 (Removed)
        acVp1_16 = 7 (Removed)
        acVp1_20 = 8 (Removed)
        acVp1_30 = 9 (Removed)
        acVp1_40 = 10 (Removed)
        acVp1_50 = 11 (Removed)
        acVp1_100 = 12 (Removed)
        acVp2_1 = 13 (Removed)
        acVp4_1 = 14 (Removed)
        acVp8_1 = 15 (Removed)
        acVp10_1 = 16 (Removed)
        acVp100_1 = 17 (Removed)
        acVp1_128in_1ft = 18 (Removed)
        acVp1_64in_1ft = 19 (Removed)
        acVp1_32in_1ft = 20 (Removed)
        acVp1_16in_1ft = 21 (Removed)
        acVp3_32in_1ft = 22 (Removed)
        acVp1_8in_1ft = 23 (Removed)
        acVp3_16in_1ft = 24 (Removed)
        acVp1_4in_1ft = 25 (Removed)
        acVp3_8in_1ft = 26 (Removed)
        acVp1_2in_1ft = 27 (Removed)
        acVp3_4in_1ft = 28 (Removed)
        acVp1in_1ft = 29 (Removed)
        acVp1and1_2in_1ft = 30 (Removed)
        acVp3in_1ft = 31 (Removed)
        acVp6in_1ft = 32 (Removed)
        acVp1ft_1ft = 33 (Removed)
        acVp1_5 = 5 (New)
        acVp1_8 = 6 (New)
        acVp1_10 = 7 (New)
        acVp1_16 = 8 (New)
        acVp1_20 = 9 (New)
        acVp1_30 = 10 (New)
        acVp1_40 = 11 (New)
        acVp1_50 = 12 (New)
        acVp1_100 = 13 (New)
        acVp2_1 = 14 (New)
        acVp4_1 = 15 (New)
        acVp8_1 = 16 (New)
        acVp10_1 = 17 (New)
        acVp100_1 = 18 (New)
        acVp1_128in_1ft = 19 (New)
        acVp1_64in_1ft = 20 (New)
        acVp1_32in_1ft = 21 (New)
        acVp1_16in_1ft = 22 (New)
        acVp3_32in_1ft = 23 (New)
        acVp1_8in_1ft = 24 (New)
        acVp3_16in_1ft = 25 (New)
        acVp1_4in_1ft = 26 (New)
        acVp3_8in_1ft = 27 (New)
        acVp1_2in_1ft = 28 (New)
        acVp3_4in_1ft = 29 (New)
        acVp1in_1ft = 30 (New)
        acVp1and1_2in_1ft = 31 (New)
        acVp3in_1ft = 32 (New)
        acVp6in_1ft = 33 (New)
        acVp1ft_1ft = 34 (New)
AcTextAttachmentDirection (New)
        acAttachmentHorizontal = 0
        acAttachmentVertical = 1
AcVerticalTextAttachmentType (New)
        acAttachmentCenter = 0
        acAttachmentLinedCenter = 1
AcMeshCreaseType (New)
        acNoneCrease = 0
        acAlwaysCrease = 1
        acCreaseByLevel = 2

Classes

IAcadBlock (Changed)
        AddMLeader - Method (Moved from IAcadBlock2)
IAcadAttribute (Changed)
        MTextAttribute - Property (Moved from IAcadAttribute2)
        MTextAttributeContent - Property (Moved from IAcadAttribute2)
        UpdateMTextAttribute - Method (Moved from IAcadAttribute2)
        MTextBoundaryWidth - Property (Moved from IAcadAttribute2)
        MTextDrawingDirection - Property (Moved from IAcadAttribute2)
IAcadDimAligned (Changed)
        DimConstrForm - Property (New)
        DimConstrReference - Property (New)
        DimConstrName - Property (New)
        DimConstrExpression - Property (New)
        DimConstrValue - Property (New)
        DimConstrDesc - Property (New)
        SubUnitsSuffix - Property (New)
        SubUnitsFactor - Property (New)
        AltSubUnitsSuffix - Property (New)
        AltSubUnitsFactor - Property (New)
IAcadDimension (Changed)
        DimTxtDirection - Property (New)
IAcadDimAngular (Changed)
        DimConstrForm - Property (New)
        DimConstrReference - Property (New)
        DimConstrName - Property (New)
        DimConstrExpression - Property (New)
        DimConstrValue - Property (New)
        DimConstrDesc - Property (New)
IAcadDimDiametric (Changed)
        DimConstrForm - Property (New)
        DimConstrReference - Property (New)
        DimConstrName - Property (New)
        DimConstrExpression - Property (New)
        DimConstrValue - Property (New)
        DimConstrDesc - Property (New)
IAcadDimRotated (Changed)
        DimConstrForm - Property (New)
        DimConstrReference - Property (New)
        DimConstrName - Property (New)
        DimConstrExpression - Property (New)
        DimConstrValue - Property (New)
        DimConstrDesc - Property (New)
        SubUnitsSuffix - Property (New)
        SubUnitsFactor - Property (New)
        AltSubUnitsSuffix - Property (New)
        AltSubUnitsFactor - Property (New)
IAcadDimOrdinate (Changed)
        SubUnitsSuffix - Property (New)
        SubUnitsFactor - Property (New)
        AltSubUnitsSuffix - Property (New)
        AltSubUnitsFactor - Property (New)
IAcadDimRadial (Changed)
        DimConstrForm - Property (New)
        DimConstrReference - Property (New)
        DimConstrName - Property (New)
        DimConstrExpression - Property (New)
        DimConstrValue - Property (New)
        DimConstrDesc - Property (New)
IAcadDim3PointAngular (Changed)
        DimConstrForm - Property (New)
        DimConstrReference - Property (New)
        DimConstrName - Property (New)
        DimConstrExpression - Property (New)
        DimConstrValue - Property (New)
        DimConstrDesc - Property (New)
IAcadTable (Changed)
        IsEmpty - Method (Moved from IAcadTable2)
        CreateContent - Method (Moved from IAcadTable2)
        MoveContent - Method (Moved from IAcadTable2)
        DeleteContent - Method (Moved from IAcadTable2)
        GetValue - Method (Moved from IAcadTable2)
        SetValue - Method (Moved from IAcadTable2)
        SetValueFromText - Method (Moved from IAcadTable2)
        GetDataFormat - Method (Moved from IAcadTable2)
        SetDataFormat - Method (Moved from IAcadTable2)
        GetTextString - Method (Moved from IAcadTable2)
        SetTextString - Method (Moved from IAcadTable2)
        GetFieldId2 - Method (Moved from IAcadTable2)
        SetFieldId2 - Method (Moved from IAcadTable2)
        GetBlockTableRecordId2 - Method (Moved from IAcadTable2)
        SetBlockTableRecordId2 - Method (Moved from IAcadTable2)
        GetBlockAttributeValue2 - Method (Moved from IAcadTable2)
        SetBlockAttributeValue2 - Method (Moved from IAcadTable2)
        GetCustomData - Method (Moved from IAcadTable2)
        SetCustomData - Method (Moved from IAcadTable2)
        GetCellStyle - Method (Moved from IAcadTable2)
        SetCellStyle - Method (Moved from IAcadTable2)
        GetContentColor2 - Method (Moved from IAcadTable2)
        SetContentColor2 - Method (Moved from IAcadTable2)
        GetDataType2 - Method (Moved from IAcadTable2)
        SetDataType2 - Method (Moved from IAcadTable2)
        GetTextStyle2 - Method (Moved from IAcadTable2)
        SetTextStyle2 - Method (Moved from IAcadTable2)
        GetTextHeight2 - Method (Moved from IAcadTable2)
        SetTextHeight2 - Method (Moved from IAcadTable2)
        GetRotation - Method (Moved from IAcadTable2)
        SetRotation - Method (Moved from IAcadTable2)
        GetAutoScale2 - Method (Moved from IAcadTable2)
        SetAutoScale2 - Method (Moved from IAcadTable2)
        GetScale - Method (Moved from IAcadTable2)
        SetScale - Method (Moved from IAcadTable2)
        RemoveAllOverrides - Method (Moved from IAcadTable2)
        GetGridLineWeight2 - Method (Moved from IAcadTable2)
        SetGridLineWeight2 - Method (Moved from IAcadTable2)
        GetGridLinetype - Method (Moved from IAcadTable2)
        SetGridLinetype - Method (Moved from IAcadTable2)
        GetGridColor2 - Method (Moved from IAcadTable2)
        SetGridColor2 - Method (Moved from IAcadTable2)
        GetGridVisibility2 - Method (Moved from IAcadTable2)
        SetGridVisibility2 - Method (Moved from IAcadTable2)
        GetGridDoubleLineSpacing - Method (Moved from IAcadTable2)
        SetGridDoubleLineSpacing - Method (Moved from IAcadTable2)
        EnableBreak - Property (Moved from IAcadTable2)
        GetBreakHeight - Method (Moved from IAcadTable2)
        SetBreakHeight - Method (Moved from IAcadTable2)
        GetContentType - Method (Moved from IAcadTable2)
        GetMargin - Method (Moved from IAcadTable2)
        SetMargin - Method (Moved from IAcadTable2)
        GetContentLayout - Method (Moved from IAcadTable2)
        SetContentLayout - Method (Moved from IAcadTable2)
        GetOverride - Method (Moved from IAcadTable2)
        SetOverride - Method (Moved from IAcadTable2)
        GetGridLineStyle - Method (Moved from IAcadTable2)
        SetGridLineStyle - Method (Moved from IAcadTable2)
        InsertRowsAndInherit - Method (Moved from IAcadTable2)
        InsertColumnsAndInherit - Method (Moved from IAcadTable2)
        GetHasFormula - Method (Moved from IAcadTable2)
        GetFormula - Method (Moved from IAcadTable2)
        SetFormula - Method (Moved from IAcadTable2)
        IsContentEditable - Method (Moved from IAcadTable2)
        IsFormatEditable - Method (Moved from IAcadTable2)
        GetCellState - Method (Moved from IAcadTable2)
        SetCellState - Method (Moved from IAcadTable2)
        EnableMergeAll - Method (Moved from IAcadTable2)
        IsMergeAllEnabled - Method (Moved from IAcadTable2)
        BreaksEnabled - Property (Moved from IAcadTable2)
        RepeatTopLabels - Property (Moved from IAcadTable2)
        RepeatBottomLabels - Property (Moved from IAcadTable2)
        TableBreakFlowDirection - Property (Moved from IAcadTable2)
        AllowManualPositions - Property (Moved from IAcadTable2)
        AllowManualHeights - Property (Moved from IAcadTable2)
        TableBreakHeight - Property (Moved from IAcadTable2)
        BreakSpacing - Property (Moved from IAcadTable2)
        GetColumnName - Method (Moved from IAcadTable2)
        SetColumnName - Method (Moved from IAcadTable2)
        SetToolTip - Method (Moved from IAcadTable2)
        GetFieldId232 - Method (Moved from IAcadTable2)
        SetFieldId232 - Method (Moved from IAcadTable2)
        GetBlockTableRecordId232 - Method (Moved from IAcadTable2)
        SetBlockTableRecordId232 - Method (Moved from IAcadTable2)
        GetBlockAttributeValue232 - Method (Moved from IAcadTable2)
        SetBlockAttributeValue232 - Method (Moved from IAcadTable2)
        GetGridLinetype32 - Method (Moved from IAcadTable2)
        SetGridLinetype32 - Method (Moved from IAcadTable2)
IAcadDimArcLength (Changed)
        SubUnitsSuffix - Property (New)
        SubUnitsFactor - Property (New)
        AltSubUnitsSuffix - Property (New)
        AltSubUnitsFactor - Property (New)
IAcadMLeader (Changed)
        LeaderLinetype - Property (Renamed, previously LeaderLineType)
        BlockScale - Property (New)
        TextAttachmentDirection - Property (New)
        TextTopAttachmentType - Property (New)
        TextBottomAttachmentType - Property (New)
IAcadPViewport (Changed)
        StandardScale2 - Property (New)
        LayerPropertyOverrides - Property (Moved from IAcadPViewport2)
IAcadTableStyle (Changed)
        CreateCellStyle - Method (Moved from IAcadTableStyle2)
        CreateCellStyleFromStyle - Method (Moved from IAcadTableStyle2)
        RenameCellStyle - Method (Moved from IAcadTableStyle2)
        DeleteCellStyle - Method (Moved from IAcadTableStyle2)
        GetUniqueCellStyleName - Method (Moved from IAcadTableStyle2)
        GetIsCellStyleInUse - Method (Moved from IAcadTableStyle2)
        NumCellStyles - Property (Moved from IAcadTableStyle2)
        GetCellStyles - Method (Moved from IAcadTableStyle2)
        GetTextStyleId - Method (Moved from IAcadTableStyle2)
        SetTextStyleId - Method (Moved from IAcadTableStyle2)
        GetTextHeight2 - Method (Moved from IAcadTableStyle2)
        SetTextHeight2 - Method (Moved from IAcadTableStyle2)
        GetAlignment2 - Method (Moved from IAcadTableStyle2)
        SetAlignment2 - Method (Moved from IAcadTableStyle2)
        GetColor2 - Method (Moved from IAcadTableStyle2)
        SetColor2 - Method (Moved from IAcadTableStyle2)
        GetBackgroundColor2 - Method (Moved from IAcadTableStyle2)
        SetBackgroundColor2 - Method (Moved from IAcadTableStyle2)
        GetDataType2 - Method (Moved from IAcadTableStyle2)
        SetDataType2 - Method (Moved from IAcadTableStyle2)
        GetFormat2 - Method (Moved from IAcadTableStyle2)
        SetFormat2 - Method (Moved from IAcadTableStyle2)
        GetCellClass - Method (Moved from IAcadTableStyle2)
        SetCellClass - Method (Moved from IAcadTableStyle2)
        GetRotation - Method (Moved from IAcadTableStyle2)
        SetRotation - Method (Moved from IAcadTableStyle2)
        GetIsMergeAllEnabled - Method (Moved from IAcadTableStyle2)
        EnableMergeAll - Method (Moved from IAcadTableStyle2)
        GetGridLineWeight2 - Method (Moved from IAcadTableStyle2)
        SetGridLineWeight2 - Method (Moved from IAcadTableStyle2)
        GetGridColor2 - Method (Moved from IAcadTableStyle2)
        SetGridColor2 - Method (Moved from IAcadTableStyle2)
        GetGridVisibility2 - Method (Moved from IAcadTableStyle2)
        SetGridVisibility2 - Method (Moved from IAcadTableStyle2)
        TemplateId - Property (Moved from IAcadTableStyle2)
        SetTemplateId - Method (Moved from IAcadTableStyle2)
        GetTextStyleId32 - Method (Moved from IAcadTableStyle2)
        SetTextStyleId32 - Method (Moved from IAcadTableStyle2)
        TemplateId32 - Property (Moved from IAcadTableStyle2)
        SetTemplateId32 - Method (Moved from IAcadTableStyle2)
IAcadMLeaderStyle (Changed)
        LeaderLinetype - Property (Renamed, previously LeaderLineType)
        TextAttachmentDirection - Property (New)
        TextTopAttachmentType - Property (New)
        TextBottomAttachmentType - Property (New)
IAcadAttributeReference (Changed)
        MTextAttribute - Property (Moved from IAcadAttributeReference2)
        MTextAttributeContent - Property (Moved from IAcadAttributeReference2)
        UpdateMTextAttribute - Method (Moved from IAcadAttributeReference2)
        MTextBoundaryWidth - Property (Moved from IAcadAttributeReference2)
        MTextDrawingDirection - Property (Moved from IAcadAttributeReference2)
IAcadMLeaderLeader (New)
        LeaderType - Property
        LeaderLineColor - Property
        LeaderLinetype - Property
        LeaderLineWeight - Property
        ArrowheadType - Property
        ArrowheadSize - Property
        ArrowheadBlock - Property
IAcadUnderlay (Changed)
        UnderlayLayerOverrideApplied - Property (Moved from IAcadUnderlay2)
IAcadDwfUnderlay (New)
        DWFFormat - Property (Moved from IAcadUnderlay3)
IAcadSubDMesh (New)
        Smoothness - Property
        Coordinates - Property
        Coordinate - Property
        VertexCount - Property
        FaceCount - Property
IAcadSubDMeshFace (New)
        Material - Property
        CreaseType - Property
        CreaseLevel - Property
IAcadSubDMeshEdge (New)
        CreaseType - Property
        CreaseLevel - Property
IAcadSubDMeshVertex (New)
        Coordinates - Property
        CreaseType - Property
        CreaseLevel - Property
IAcadModelSpace (Changed)
        AddMLeader - Method (Moved from IAcadModelSpace2)
IAcadPaperSpace (Changed)
        AddMLeader - Method (Moved from IAcadPaperSpace2)
IAcadPreferencesUser (Changed)
        HyperlinkDisplayTooltip - Property (Removed)
IAcadToolbarItem (Changed)
        CommandDisplayName - Property (Moved from IAcadToolbarItem2)
IAcadUtility (Changed)
        GetSubEntity32 - Method (Moved from IAcadUtility2)
        ObjectId32ToObjectIdString - Method (Moved from IAcadUtility2)
        GetObjectIdString - Method (Moved from IAcadUtility2)

The following classes were removed/merged with their parent classes:

IAcadTableStyle2 (Removed - Moved to IAcadTableStyle)
IAcadAttribute2 (Removed - Moved to IAcadAttribute)
IAcadAttributeReference2 (Removed - Moved to IAcadAttributeReference)
IAcadPViewport2 (Removed - Moved to IAcadPViewport)
IAcadTable2 (Removed - Moved to IAcadTable)
IAcadUnderlay2 (Removed - Moved to IAcadUnderlay)
IAcadUnderlay3 (Removed - Moved to IAcadUnderlay)
IAcadBlock2 (Removed - Moved to IAcadBlock)
IAcadModelSpace2 (Removed - Moved to IAcadModelSpace)
IAcadPaperSpace2 (Removed - Moved to IAcadPaperSpace)
IAcadUtility2 (Removed - Moved to IAcadUtility)
IAcadToolbarItem2 (Removed - Moved to IAcadToolbarItem)


AutoCAD 2011 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2011 and AutoCAD 2011-based products.

Enums

AcEntityName (Changed)
        acNurbSurface = 51 (New)
AcSaveAsType (Changed)
        ac2010_dwg = 48 (New)
        ac2010_dxf = 49 (New)
        ac2010_Template = 50 (New)
        acNative = 48 (Changed)
AcWireframeType (New)
        acIsolines = 0
        acIsoparms = 1
AcSplineKnotParameterizationType (New)
        acChord = 0
        acSqrtChord = 1
        acUniformParam = 2
        acCustomParameterization = 15
AcSplineFrameType (New)
        acShow = 0
        acHide = 1
AcSplineMethodType (New)
        acFit = 0
        acControlVertices = 1
AcPointCloudColorType (New)
        acByColor = 0
        acPreset = 1

Classes

IAcadEntity2 (New)
        EntityTransparency - Property
IAcadRasterImage2 (New)
        EntityTransparency - Property
IAcad3DFace2 (New)
        EntityTransparency - Property
IAcad3DPolyline2 (New)
        EntityTransparency - Property
IAcadRegion2 (New)
        EntityTransparency - Property
IAcad3DSolid2 (New)
        EntityTransparency - Property
IAcadArc2 (New)
        EntityTransparency - Property
IAcadAttribute2 (New)
        EntityTransparency - Property
IAcadBlockReference2 (New)
        EntityTransparency - Property
IAcadCircle2 (New)
        EntityTransparency - Property
IAcadEllipse2 (New)
        EntityTransparency - Property
IAcadHatch2 (New)
        BackgroundColor - Property
        EntityTransparency - Property
IAcadLeader2 (New)
        EntityTransparency - Property
IAcadMLeader2 (New)
        EntityTransparency - Property
IAcadLWPolyline2 (New)
        EntityTransparency - Property
IAcadLine2 (New)
        EntityTransparency - Property
IAcadMText2 (New)
        EntityTransparency - Property
IAcadPoint2 (New)
        EntityTransparency - Property
IAcadPolyline2 (New)
        EntityTransparency - Property
IAcadPolygonMesh2 (New)
        EntityTransparency - Property
IAcadRay2 (New)
        EntityTransparency - Property
IAcadShape2 (New)
        EntityTransparency - Property
IAcadSolid2 (New)
        EntityTransparency - Property
IAcadSpline2 (New)
        KnotParameterization - Property
        SplineFrame - Property
        SplineMethod - Property
        Degree2 - Property
        Closed2 - Property
        EntityTransparency - Property
IAcadText2 (New)
        EntityTransparency - Property
IAcadTolerance2 (New)
        EntityTransparency - Property
IAcadTrace2 (New)
        EntityTransparency - Property
IAcadXline2 (New)
        EntityTransparency - Property
IAcadPViewport2 (New)
        EntityTransparency - Property
IAcadPolyfaceMesh2 (New)
        EntityTransparency - Property
IAcadMLine2 (New)
        EntityTransparency - Property
IAcadExternalReference2 (New)
        EntityTransparency - Property
IAcadTable2 (New)
        EntityTransparency - Property
IAcadOle2 (New)
        EntityTransparency - Property
IAcadHelix2 (New)
        EntityTransparency - Property
IAcadSurface2 (New)
        WireframeType - Property
        MaintainAssociativity - Property
        ShowAssociativity - Property
        EdgeExtensionDistances - Property
        EntityTransparency - Property
IAcadPlaneSurface2 (New)
        WireframeType - Property
        MaintainAssociativity - Property
        ShowAssociativity - Property
        EdgeExtensionDistances - Property
        EntityTransparency - Property
IAcadExtrudedSurface2 (New)
        WireframeType - Property
        MaintainAssociativity - Property
        ShowAssociativity - Property
        EdgeExtensionDistances - Property
        EntityTransparency - Property
IAcadRevolvedSurface2 (New)
        WireframeType - Property
        MaintainAssociativity - Property
        ShowAssociativity - Property
        EdgeExtensionDistances - Property
        EntityTransparency - Property
IAcadSweptSurface2 (New)
        WireframeType - Property
        MaintainAssociativity - Property
        ShowAssociativity - Property
        EdgeExtensionDistances - Property
        EntityTransparency - Property
IAcadLoftedSurface2 (New)
        StartSmoothMagnitude - Property
        EndSmoothMagnitude - Property
        StartSmoothContinuity - Property
        EndSmoothContinuity - Property
        Periodic - Property
        WireframeType - Property
        MaintainAssociativity - Property
        ShowAssociativity - Property
        EdgeExtensionDistances - Property
        EntityTransparency - Property
IAcadWipeout2 (New)
        EntityTransparency - Property
IAcadSubDMesh2 (New)
        EntityTransparency - Property
IAcadNurbSurface (New)
        CvHullDisplay - Property
        WireframeType - Property
        MaintainAssociativity - Property
        ShowAssociativity - Property
        EdgeExtensionDistances - Property
        EntityTransparency - Property
IAcadDimAligned2 (New)
        EntityTransparency - Property
IAcadDimAngular2 (New)
        EntityTransparency - Property
IAcadDimDiametric2 (New)
        EntityTransparency - Property
IAcadDimOrdinate2 (New)
        EntityTransparency - Property
IAcadDimRadial2 (New)
        EntityTransparency - Property
IAcadDimRotated2 (New)
        EntityTransparency - Property
IAcadDim3PointAngular2 (New)
        EntityTransparency - Property
IAcadDimArcLength2 (New)
        EntityTransparency - Property
IAcadDimRadialLarge2 (New)
        EntityTransparency - Property
IAcadPointCloud (New)
        InsertionPoint - Property
        scale - Property
        Rotation - Property
        UseEntityColor - Property
        Locked - Property


AutoCAD 2012 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2012 and AutoCAD 2012-based products.

Enums

No changes

Classes

IAcadSurface3 (New)
        SurfTrimAssociativity - Property
IAcadPlaneSurface3 (New)
        SurfTrimAssociativity - Property
IAcadExtrudedSurface3 (New)
        SurfTrimAssociativity - Property
IAcadRevolvedSurface3 (New)
        SurfTrimAssociativity - Property
IAcadSweptSurface3 (New)
        SurfTrimAssociativity - Property
IAcadLoftedSurface3 (New)
        SurfTrimAssociativity - Property
IAcadNurbSurface2 (New)
        SurfTrimAssociativity - Property


AutoCAD 2013 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2013 and AutoCAD 2013-based products.

Enums

AcSaveAsType (Changed)
        ac2013_dwg = 60 (New)
        ac2013_dxf = 61 (New)
        ac2013_Template = 62 (New)
        acNative = 60 (Changed)
AcPointCloudColorType (Changed)
        acTrueColor = 0 (New)
        acByColor = 1 (New)
AcPointCloudIntensityStyle (New)
        acIntensityGrayscale = 0
        acIntensityRainbow = 1
        acIntensityRed = 2
        acIntensityGreen = 3
        acIntensityBlue = 4
        acIntensityEditableFlag = 5

Classes

IAcadEntity (Changed)
        EntityTransparency - Property (Moved from IAcadEntity2)
IAcad3DSolid (Changed)
        CheckInterference - Method (Added solid interfere parameter)
IAcadSpline (Changed)
        KnotParameterization - Property (Moved from IAcadSpline2)
        SplineFrame - Property (Moved from IAcadSpline2)
        SplineMethod - Property (Moved from IAcadSpline2)
        Degree2 - Property (Moved from IAcadSpline2)
        Closed2 - Property (Moved from IAcadSpline2)
IAcadHatch (Changed)
        BackgroundColor - Property (Moved from IAcadHatch2)
IAcadRasterImage (Changed)
        transparency - Property (Renamed, previously Transparency)
IAcadDynamicBlockReferenceProperty (Changed)
        show - Property (Renamed, previously Show)
IAcadSurface (Changed)
        WireframeType - Property (Moved from IAcadSurface2)
        MaintainAssociativity - Property (Moved from IAcadSurface2)
        ShowAssociativity - Property (Moved from IAcadSurface2)
        EdgeExtensionDistances - Property (Moved from IAcadSurface2)
        SurfTrimAssociativity - Property (Moved from IAcadSurface3)
IAcadLoftedSurface (Changed)
        StartSmoothMagnitude - Property (Moved from IAcadLoftedSurface2)
        EndSmoothMagnitude - Property (Moved from IAcadLoftedSurface2)
        StartSmoothContinuity - Property (Moved from IAcadLoftedSurface2)
        EndSmoothContinuity - Property (Moved from IAcadLoftedSurface2)
        Periodic - Property (Moved from IAcadLoftedSurface2)
IAcadPointCloud (Changed)
        ShowIntensity - Property (New)
        IntensityColorScheme - Property (New)
        Width - Property (New)
        Length - Property (New)
        Height - Property (New)
        Name - Property (New)
        Path - Property (New)
        ShowClipped - Property (New)
IAcadPreferencesFiles (Changed)
        ActiveInvProject - Property (New)

The following classes were removed/merged with their parent classes:

IAcadEntity2 - Removed (Moved to IAcadEntity)
IAcadRasterImage2 - Removed (Moved to IAcadRasterImage)
IAcad3DFace2 - Removed (Moved to IAcad3DFace)
IAcad3DPolyline2 - Removed (Moved to IAcad3DPolyline)
IAcadRegion2 - Removed (Moved to IAcadRegion)
IAcad3DSolid2 - Removed (Moved to IAcad3DSolid)
IAcadArc2 - Removed (Moved to IAcadArc)
IAcadAttribute2 - Removed (Moved to IAcadAttribute)
IAcadBlockReference2 - Removed (Moved to IAcadBlockReference)
IAcadCircle2 - Removed (Moved to IAcadCircle)
IAcadEllipse2 - Removed (Moved to IAcadEllipse)
IAcadHatch2 - Removed (Moved to IAcadHatch)
IAcadLeader2 - Removed (Moved to IAcadLeader)
IAcadMLeader2 - Removed (Moved to IAcadMLeader)
IAcadLWPolyline2 - Removed (Moved to IAcadLWPolyline)
IAcadLine2 - Removed (Moved to IAcadLine)
IAcadMText2 - Removed (Moved to IAcadMText)
IAcadPoint2 - Removed (Moved to IAcadPoint)
IAcadPolyline2 - Removed (Moved to IAcadPolyline)
IAcadPolygonMesh2 - Removed (Moved to IAcadPolygonMesh)
IAcadRay2 - Removed (Moved to IAcadRay)
IAcadShape2 - Removed (Moved to IAcadShape)
IAcadSolid2 - Removed (Moved to IAcadSolid)
IAcadSpline2 - Removed (Moved to IAcadSpline)
IAcadText2 - Removed (Moved to IAcadText)
IAcadTolerance2 - Removed (Moved to IAcadTolerance)
IAcadTrace2 - Removed (Moved to IAcadTrace)
IAcadXline2 - Removed (Moved to IAcadXline)
IAcadPViewport2 - Removed (Moved to IAcadPViewport)
IAcadPolyfaceMesh2 - Removed (Moved to IAcadPolyfaceMesh)
IAcadMLine2 - Removed (Moved to IAcadMLine)
IAcadExternalReference2 - Removed (Moved to IAcadExternalReference)
IAcadTable2 - Removed (Moved to IAcadTable)
IAcadOle2 - Removed (Moved to IAcadOle)
IAcadHelix2 - Removed (Moved to IAcadHelix)
IAcadSurface2 - Removed (Moved to IAcadSurface)
IAcadSurface3 - Removed (Moved to IAcadSurface)
IAcadPlaneSurface2 - Removed (Moved to IAcadPlaneSurface)
IAcadPlaneSurface3 - Removed (Moved to IAcadPlaneSurface)
IAcadExtrudedSurface2 - Removed (Moved to IAcadExtrudedSurface)
IAcadExtrudedSurface3 - Removed (Moved to IAcadExtrudedSurface)
IAcadRevolvedSurface2 - Removed (Moved to IAcadRevolvedSurface)
IAcadRevolvedSurface3 - Removed (Moved to IAcadRevolvedSurface)
IAcadSweptSurface2 - Removed (Moved to IAcadSweptSurface)
IAcadSweptSurface3 - Removed (Moved to IAcadSweptSurface)
IAcadLoftedSurface2 - Removed (Moved to IAcadLoftedSurface)
IAcadLoftedSurface3 - Removed (Moved to IAcadLoftedSurface)
IAcadWipeout2 - Removed (Moved to IAcadWipeout)
IAcadSubDMesh2 - Removed (Moved to IAcadSubDMesh)
IAcadNurbSurface2 - Removed (Moved to IAcadNurbSurface)
IAcadDimAligned2 - Removed (Moved to IAcadDimAligned)
IAcadDimAngular2 - Removed (Moved to IAcadDimAngular)
IAcadDimDiametric2 - Removed (Moved to IAcadDimDiametric)
IAcadDimOrdinate2 - Removed (Moved to IAcadDimOrdinate)
IAcadDimRadial2 - Removed (Moved to IAcadDimRadial)
IAcadDimRotated2 - Removed (Moved to IAcadDimRotated)
IAcadDim3PointAngular2 - Removed (Moved to IAcadDim3PointAngular)
IAcadDimArcLength2 - Removed (Moved to IAcadDimArcLength)
IAcadDimRadialLarge2 - Removed (Moved to IAcadDimRadialLarge)


AutoCAD 2014 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2014 and AutoCAD 2014-based products.

Enums

AcPointCloudStylizationType (New)
        acIntensity = 3
        acNormal = 2
        acObjectColor = 1
        acScanColor = 0

Classes

IAcadApplication
        HWND32 - Property (Obsolete; use HWND)
IAcadDatabase
        ObjectIDToObject32 - Method (Obsolete; use ObjectIDToObject)
IAcadDocument
        ObjectIDToObject32 - Method (Obsolete; use ObjectIDToObject)
        HWND32 - Property (Obsolete; use HWND)
IAcadGeoPositionMarker (New)
        Altitude - Property
        BackgroundFill - Property
        DrawingDirection - Property
        Height - Property
        LandingGap - Property
        Latitude - Property
        LineSpacingDistance - Property
        LineSpacingFactor - Property
        LineSpacingStyle - Property
        Longitude - Property
        Notes - Property
        Position - Property
        Radius - Property
        Rotation - Property
        TextFrameDisplay - Property
        TextJustify - Property
        TextString - Property
        TextStyleName - Property
        TextWidth - Property
IAcadIDPair
        Key32 - Property (Obsolete; use Key)
        Value32 - Property (Obsolete; use Value)
IAcadMLeader
        GetBlockAttributeValue32 - Method (Obsolete; use GetBlockAttributeValue)
        SetBlockAttributeValue32 - Method (Obsolete; use SetBlockAttributeValue)
IAcadObject
        ObjectID32 - Property (Obsolete; use ObjectID)
        OwnerID32 - Property (Obsolete; use OwnerID)
IAcadPointCloud2 (New)
        Stylization - Property
        Unit - Property
        UnitFactor - Property
IAcadPViewport
        LabelBlockId32 - Property (Obsolete; use LabelBlockId)
IAcadTable
        GetBlockAttributeValue232 - Method (Obsolete; use GetBlockAttributeValue2)
        GetBlockAttributeValue32 - Method (Obsolete; use GetBlockAttributeValue)
        GetBlockTableRecordId232 - Method (Obsolete; use GetBlockTableRecordId2)
        GetBlockTableRecordId32 - Method (Obsolete; use GetBlockTableRecordId)
        GetFieldId232 - Method (Obsolete; use GetFieldId2)
        GetFieldId32 - Method (Obsolete; use GetFieldId)
        GetGridLinetype32 - Method (Obsolete; use GetGridLinetype)
        SetBlockAttributeValue232 - Method (Obsolete; use SetBlockAttributeValue2)
        SetBlockAttributeValue32 - Method (Obsolete; use SetBlockAttributeValue)
        SetBlockTableRecordId232 - Method (Obsolete; use SetBlockTableRecordId2)
        SetBlockTableRecordId32 - Method (Obsolete; use SetBlockTableRecordId)
        SetFieldId232 - Method (Obsolete; use SetFieldId2)
        SetFieldId32 - Method (Obsolete; use SetFieldId)
        SetGridLinetype32 - Method (Obsolete; use SetGridLinetype)
IAcadTableStyle
        GetTextStyleId32 - Method (Obsolete; use GetTextStyleId)
        SetTemplateId32 - Method (Obsolete; use SetTemplateId)
        SetTextStyleId32 - Method (Obsolete; use SetTextStyleId)
        TemplateId32 - Property (Obsolete; use TemplateId)
IAcadUtility
        GetSubEntity32 - Method (Obsolete; use GetSubEntity)
        ObjectId32ToObjectIdString - Method (Obsolete; use ObjectIdToObjectIdString)
IAcadView
        LayoutID32 - Property (Obsolete; use LayoutID)


AutoCAD 2015 API History Reference (ActiveX)

Additions and changes made to the ActiveX API in AutoCAD 2015 and AutoCAD 2015-based products.

Enums

AcPointCloudExStylizationType (New)
        acRGB = 0
        acObject = 1
        acNormals = 2
        acIntensities = 3
        acElevation = 4
        acClassification = 5

Classes

IAcadApplication
        HWND32 - Property (Removed; use HWND)
IAcadDatabase
        ObjectIDToObject32 - Method (Removed; use ObjectIDToObject)
IAcadDocument
        ObjectIDToObject32 - Method (Removed; use ObjectIDToObject)
        HWND32 - Property (Removed; use HWND)
IAcadGeomapImage (New)
        GeoImageBrightness - Property
        GeoImageContrast - Property
        GeoImageFade - Property
        GeoImagePosition - Property
        GeoImageWidth - Property
        GeoImageHeight - Property
IAcadIDPair
        Key32 - Property (Removed; use Key)
        Value32 - Property (Removed; use Value)
IAcadMLeader
        GetBlockAttributeValue32 - Method (Removed; use GetBlockAttributeValue)
        SetBlockAttributeValue32 - Method (Removed; use SetBlockAttributeValue)
IAcadObject
        ObjectID32 - Property (Removed; use ObjectID)
        OwnerID32 - Property (Removed; use OwnerID)
IAcadPointCloud (Changed)
        Stylization - Property (Moved from IAcadPointCloud2)
        Unit - Property (Moved from IAcadPointCloud2)
        UnitFactor - Property (Moved from IAcadPointCloud2)
IAcadPointCloudEx (New)
        ColorScheme - Property
        Geolocate - Property
        InsertionPoint - Property
        Locked - Property
        Name - Property
        Path - Property
        Rotation - Property
        scale - Property
        ShowCropped - Property
        Stylization - Property
        Unit - Property
        UnitFactor - Property
IAcadPViewport
        LabelBlockId32 - Property (Removed; use LabelBlockId)
IAcadTable
        GetBlockAttributeValue232 - Method (Removed; use GetBlockAttributeValue2)
        GetBlockAttributeValue32 - Method (Removed; use GetBlockAttributeValue)
        GetBlockTableRecordId232 - Method (Removed; use GetBlockTableRecordId2)
        GetBlockTableRecordId32 - Method (Removed; use GetBlockTableRecordId)
        GetFieldId232 - Method (Removed; use GetFieldId2)
        GetFieldId32 - Method (Removed; use GetFieldId)
        GetGridLinetype32 - Method (Removed; use GetGridLinetype)
        SetBlockAttributeValue232 - Method (Removed; use SetBlockAttributeValue2)
        SetBlockAttributeValue32 - Method (Removed; use SetBlockAttributeValue)
        SetBlockTableRecordId232 - Method (Removed; use SetBlockTableRecordId2)
        SetBlockTableRecordId32 - Method (Removed; use SetBlockTableRecordId)
        SetFieldId232 - Method (Removed; use SetFieldId2)
        SetFieldId32 - Method (Removed; use SetFieldId)
        SetGridLinetype32 - Method (Removed; use SetGridLinetype)
IAcadTableStyle
        GetTextStyleId32 - Method (Removed; use GetTextStyleId)
        SetTemplateId32 - Method (Removed; use SetTemplateId)
        SetTextStyleId32 - Method (Removed; use SetTextStyleId)
        TemplateId32 - Property (Removed; use TemplateId)
IAcadUtility
        GetSubEntity32 - Method (Removed; use GetSubEntity)
        ObjectId32ToObjectIdString - Method (Removed; use ObjectIdToObjectIdString)
IAcadView
        LayoutID32 - Property (Removed; use LayoutID)
_DAcadDocumentEvents (Changed)
        ObjectErased - Event (ObjectID must now be a Long)
        WindowMovedOrResized - Event (HWNDFrame must now be a Long)

The following classes were removed/merged with their parent classes:

IAcadPointCloud2 - Removed (Moved to IAcadPointCloud)


Getting Started with VBA

Topics in this section

  • About Embedded and Global VBA Projects

    An AutoCAD VBA project is a collection of code modules, class modules, and forms that work together to perform a given function. Projects can be stored within an AutoCAD drawing, or as a separate file.

  • About Organizing Your Projects with the VBA Manager

    You can view all the VBA projects loaded in the current AutoCAD session by using the VBA Manager. It is an AutoCAD tool that allows you to load, unload, save, create, embed, and extract VBA projects.

  • About Handling Your Macros

    A macro is a public (executable) subroutine. Each project usually contains at least one macro.

  • About Editing Your Projects with the VBA IDE

    Once a project has been loaded into AutoCAD, you can edit the code, forms, and references for that project using the VBA interactive development environment.

  • Exercise: An Introduction to VBA

    In this exercise you will create a new AutoCAD drawing, add a line of text to that drawing, then save the drawing, all from VBA.

  • About More Information on the VBA IDE

    More information on the VBA IDE and the VBA programming language is available in the Help files provided by Microsoft.

  • AutoCAD VBA Project Terms Reference

    Terms related to VBA projects and the VBA IDE.

  • AutoCAD VBA Commands Reference

    Commands related to VBA projects and the VBA IDE.

  • AutoCAD VBA AutoLISP Functions Reference

    AutoLISP functions related working with VBA projects.

  • To add a new component to your project

    New modules and user forms can be added to a VBA project file.


About Embedded and Global VBA Projects (VBA/ActiveX)

An AutoCAD® VBA project is a collection of code modules, class modules, and forms that work together to perform a given function. Projects can be stored within an AutoCAD drawing, or as a separate file.

Embedded projects are stored within an AutoCAD drawing. These projects are automatically loaded whenever the drawing in which they are contained is opened in AutoCAD, making the distribution of projects very convenient. Embedded projects are limited and not able to open or close AutoCAD drawings because they function only within the document where they reside. Users of embedded projects are no longer required to find and load project files before they run a program. A time log that is triggered when the drawing is opened is an example of a project embedded in a drawing. With this macro users can log in and record the length of time they worked on the drawing. The user does not have to remember to load the project before opening the drawing; it simply is done automatically.

Global projects are stored in separate files and are more versatile because they can work in, open, and close any AutoCAD drawing, but are not automatically loaded when a drawing is opened. Users must know which project file contains the macro they need and then load that project file before they can run the macro. However, global projects are easier to share with other users, and they make excellent libraries for common macros. An example of a project you may store in a project file is a macro that collects a bill of materials from many drawings. This macro can be run by an administrator at the end of a work cycle and can collect information from many drawings.

At any given time, users can have both embedded and global projects loaded into their AutoCAD session.

AutoCAD VBA projects are not binary compatible with standalone Visual Basic 6 or .NET projects. However, the forms, modules, and classes can be exchanged between projects using the Import and Export tools in the VBA IDE. The use of Visual Studio .NET to drive and customize AutoCAD through COM Automation is supported.


About Organizing Your Projects with the VBA Manager (ActiveX)

You can view all the VBA projects loaded in the current AutoCAD session by using the VBA Manager. It is an AutoCAD tool that allows you to load, unload, save, create, embed, and extract VBA projects.

Topics in this section

  • About Loading an Existing Project

    When you load a project into AutoCAD, all the public subroutines, also called macros, become available for use. Projects embedded in a drawing are loaded whenever the drawing is opened. Projects stored in DVB files must be loaded explicitly.

  • About Unloading a Project (VBA/ActiveX)

    Unloading a project frees up memory and keeps the list of loaded projects at a length that is easy to manage.

  • About Embedding a Project into a Drawing (VBA/ActiveX)

    When you embed a project you place a copy of the project in the drawing database. The project is then loaded or unloaded whenever the drawing containing it is opened or closed.

  • About Extracting a Project from a Drawing (VBA/ActiveX)

    When you extract a project you remove the project from the drawing database and are given the opportunity to save the project in an external project file. If you do not save the file in an external project file, the project data will be deleted.

  • About Creating a New Project (VBA/ActiveX)

    New projects are created as unsaved global projects. Once a project has been created, you can then embed the project in a drawing, or save the project out to a project file.

  • Saving Your Project (VBA/ActiveX)

    Embedded projects are saved whenever the drawing is saved. Global projects must be saved using the VBA Manager or the VBA IDE.

  • To open the VBA Manager (VBA/ActiveX)

    The VBA Manager allows you to edit, step through, and execute a macro in a VBA project.


About Loading an Existing Project

When you load a project into AutoCAD, all the public subroutines, also called macros, become available for use. Projects embedded in a drawing are loaded whenever the drawing is opened. Projects stored in DVB files must be loaded explicitly.

Anytime a project is loaded, any other projects that are referenced by the first project will be loaded automatically. Additionally, AutoCAD will automatically load at startup any project file with the name acad.dvb.

Topics in this section

  • About Virus Alerts (VBA/ActiveX)

    Each time you load a project you are given the option of enabling or disabling the code within that project as a protection against viruses.

  • To load an existing VBA project file (VBA/ActiveX)

    A VBA project must be loaded before it can be used in AutoCAD.


About Virus Alerts (VBA/ActiveX)

Each time you load a project you are given the option of enabling or disabling the code within that project as a protection against viruses.

If you enable the code, viruses in the code can begin executing. If you disable the code, the project will still be loaded, but all code within that project is prevented from running. The virus alert is not displayed when you load a project by dragging a DVB file from Windows Explorer or File Explorer, and dropping it into an open drawing in the AutoCAD window.


To load an existing VBA project file (VBA/ActiveX)

A VBA project must be loaded before it can be used in AutoCAD.

  1. On the ribbon, click Manage tab [image] Applications panel (expanded) [image] Load Project.
  2. In the Open VBA Project dialog box, select the project file to load.

    The VBA Project dialog box will allow you to open only valid DVB files. If you attempt to open a different type of file, you will receive an error message.

  3. Click Open.

You can also load a project file using one of the following methods:

  • On the ribbon, click Manage tab [image] Applications panel (expanded) [image] VBA Manager. In the VBA Manager, click Load to display the Open VBA Project dialog box.
  • At the AutoCAD Command prompt, enter vbaload and press Enter. The Open VBA Project dialog box is displayed.
  • Drag a DVB file from Windows Explorer or File Explorer, and drop it into an open drawing in the AutoCAD window.
  • Use the vl-vbaload AutoLISP function.


About Unloading a Project (VBA/ActiveX)

Unloading a project frees up memory and keeps the list of loaded projects at a length that is easy to manage.

You cannot unload embedded projects or projects that are referenced by other loaded projects.

Topics in this section

  • To unload a VBA project (VBA/ActiveX)

    VBA project files can be unloaded when they are no longer needed.


About Unloading a Project (VBA/ActiveX)
About Unloading a Project (VBA/ActiveX)
About Embedding a Project into a Drawing (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Organizing Your Projects with the VBA Manager (ActiveX) > About Unloading a Project (VBA/ActiveX) >

To unload a VBA project (VBA/ActiveX)

VBA project files can be unloaded when they are no longer needed.

  1. On the ribbon, click Manage tab [image] Applications panel (expanded) [image] VBA Manager.
  2. In the VBA Manager, select the VBA project you want to unload.
  3. Click Unload.

You can also unload a project file using the VBAUNLOAD command.


About Embedding a Project into a Drawing (VBA/ActiveX)

When you embed a project you place a copy of the project in the drawing database. The project is then loaded or unloaded whenever the drawing containing it is opened or closed.

A drawing can contain only one embedded project at a time. If a drawing already contains an embedded project you must extract it before a different project can be embedded into the drawing.

Topics in this section

  • To embed a project in an AutoCAD drawing (VBA/ActiveX)

    Embedding a VBA project file into a drawing allows you to ensure a set of macros are available when the drawing is opened each time.


About Embedding a Project into a Drawing (VBA/ActiveX)
About Embedding a Project into a Drawing (VBA/ActiveX)
About Extracting a Project from a Drawing (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Organizing Your Projects with the VBA Manager (ActiveX) > About Embedding a Project into a Drawing (VBA/ActiveX) >

To embed a project in an AutoCAD drawing (VBA/ActiveX)

Embedding a VBA project file into a drawing allows you to ensure a set of macros are available when the drawing is opened each time.

  1. On the ribbon, click Manage tab [image] Applications panel (expanded) [image] VBA Manager.
  2. In the VBA Manager, select the project you want to embed.
  3. Click Embed.


To embed a project in an AutoCAD drawing (VBA/ActiveX)
About Organizing Your Projects with the VBA Manager (ActiveX)
To extract a project from an AutoCAD drawing (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Organizing Your Projects with the VBA Manager (ActiveX) >

About Extracting a Project from a Drawing (VBA/ActiveX)

When you extract a project you remove the project from the drawing database and are given the opportunity to save the project in an external project file. If you do not save the file in an external project file, the project data will be deleted.

Topics in this section

  • To extract a project from an AutoCAD drawing (VBA/ActiveX)

    An embedded VBA project can be removed and saved to a DVB file that can be loaded into other drawings.


About Extracting a Project from a Drawing (VBA/ActiveX)
About Extracting a Project from a Drawing (VBA/ActiveX)
About Creating a New Project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Organizing Your Projects with the VBA Manager (ActiveX) > About Extracting a Project from a Drawing (VBA/ActiveX) >

To extract a project from an AutoCAD drawing (VBA/ActiveX)

An embedded VBA project can be removed and saved to a DVB file that can be loaded into other drawings.

  1. On the ribbon, click Manage tab [image] Applications panel (expanded) [image] VBA Manager.
  2. In the VBA Manager, click Extract.

    The Extract button is only enabled when a drawing contains an embedded VBA project file.

  3. In the AutoCAD message box, click Yes to export the VBA project to a DVB file and remove the embedded project file. Click No to just remove the embedded project file.
  4. If you clicked Yes, specify a name and location for the DVB file. Click Save.


To extract a project from an AutoCAD drawing (VBA/ActiveX)
About Organizing Your Projects with the VBA Manager (ActiveX)
To create a new VBA project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Organizing Your Projects with the VBA Manager (ActiveX) >

About Creating a New Project (VBA/ActiveX)

New projects are created as unsaved global projects. Once a project has been created, you can then embed the project in a drawing, or save the project out to a project file.

Topics in this section

  • To create a new VBA project (VBA/ActiveX)

    New VBA projects allow you to store and organize custom macros.


About Creating a New Project (VBA/ActiveX)
About Creating a New Project (VBA/ActiveX)
Saving Your Project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Organizing Your Projects with the VBA Manager (ActiveX) > About Creating a New Project (VBA/ActiveX) >

To create a new VBA project (VBA/ActiveX)

New VBA projects allow you to store and organize custom macros.

  1. On the ribbon, click Manage tab [image] Applications panel (expanded) [image] VBA Manager.
  2. In the VBA Manager, click New.

    A new project will be created with the default name of ACADProject. To change the project's name you must go into the VBA IDE.

You can also create a project file using the VBANEW command.


Saving Your Project (VBA/ActiveX)

Embedded projects are saved whenever the drawing is saved. Global projects must be saved using the VBA Manager or the VBA IDE.

There is no explicit SAVE command in AutoCAD for VBA projects. Instead, the SAVE command resides in the File menu of the VBA IDE and in the VBA Manager. Any changes to a VBA project will access a standard Save VBA Project dialog box when one of these events occurs:

  • You select the SAVE command from the VBA IDE.
  • You choose the Save As option in the VBA Manager.
  • Your AutoCAD session is about to end or quit and the VBA project is not saved.
NoteBefore you save a project, it is assigned the default file name project.dvb. It is important that you assign a new name to your project file when you save the project. If you save a project with the default file name project.dvb, you will no longer be able to create new empty projects. Each time you create a new project, you will actually be loading the saved project called project.dvb.

Topics in this section

  • To save your project using the VBA Manager (VBA/ActiveX)

    Changes made to a VBA project must be saved before it can be unloaded.


To save your project using the VBA Manager (VBA/ActiveX)

Changes made to a VBA project must be saved before it can be unloaded.

  1. On the ribbon, click Manage tab [image] Applications panel (expanded) [image] VBA Manager.
  2. In the VBA Manager, select a project to save.
  3. Click Save As.
  4. In the Save As dialog box, enter a name and specify a location for the VBA project file. Click Save.


To open the VBA Manager (VBA/ActiveX)

The VBA Manager allows you to edit, step through, and execute a macro in a VBA project.

Do one of the following:

  • On the ribbon, click Manage tab [image] Applications panel (expanded) [image] VBA Manager.
  • At the AutoCAD Command prompt, enter vbaman and press Enter.


About Handling Your Macros (VBA/ActiveX)

A macro is a public (executable) subroutine. Each project usually contains at least one macro.

Topics in this section

  • About Using the Macros Dialog Box (VBA/ActiveX)

    The Macros dialog box allows you to run, edit, delete, and create macros as well as set the VBA project options.

  • About Running a Macro (VBA/Active)

    Running a macro executes the macro code within the context of the current AutoCAD session.

  • About Editing a Macro (VBA/ActiveX)

    Editing a macro will open the VBA IDE with the chosen macro open in the Code window.

  • About Stepping into a Macro (VBA/ActiveX)

    Stepping into a macro begins execution of the macro and then halts the execution on the first line of code. The VBA IDE is opened with the chosen macro open in the Code window at the line of execution.

  • About Setting Project Options (VBA/ActiveX)

    There are several options that affect if a VBA project can be loaded or used during the current session.


About Using the Macros Dialog Box (VBA/ActiveX)

The Macros dialog box allows you to run, edit, delete, and create macros as well as set the VBA project options.

Open the Macros dialog box from the ribbon in AutoCAD by clicking Manage tab [image] Applications panel [image] Run VBA Macro, or issue VBARUN at the AutoCAD Command prompt.

The names of all macros in the valid range are displayed in this dialog box. You can change the valid range by using the Macros In drop-down list. This list specifies the projects or drawings whose macros are displayed. You can choose to display the macros in

  • All drawings and projects
  • All drawings
  • All projects
  • Any individual drawing currently open in AutoCAD
  • Any individual project currently loaded in AutoCAD

By limiting the valid range you can control how many macro names appear in the list. This will help you in the cases when many macros are available in the loaded drawings and projects.

Topics in this section

  • To create a new macro (VBA/ActiveX)

    After a VBA project is loaded, you can add a new macro to the project.

  • To delete a macro (VBA/ActiveX)

    After a VBA project is loaded, you can delete a macro in the project.


To create a new macro (VBA/ActiveX)

After a VBA project is loaded, you can add a new macro to the project.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Run VBA Macro.
  2. In the Macros dialog box, Macros In drop-down list, select the project file you want to work with.
  3. In the Macro Name text box, enter a name for the new macro and click Create.

    If a macro with the specified name already exists, you will be prompted to replace the existing macro. Click Yes to replace the macro or No to enter a different name.


To delete a macro (VBA/ActiveX)

After a VBA project is loaded, you can delete a macro in the project.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Run VBA Macro.
  2. In the Macros dialog box, Macros In drop-down list, select the project file you want to work with.
  3. In the Macros list, select a macro and click Delete. Click Yes to delete the macro or No to keep the macro.

You can also work with macros in a loaded project file using the VBARUN command.


About Running a Macro (VBA/Active)

Running a macro executes the macro code within the context of the current AutoCAD session.

The current active drawing is considered to be the open drawing that has the focus when macro execution begins. All VBA references to the ThisDrawing object will refer to the current active drawing for macros in global projects. For macros in embedded projects, the ThisDrawing object always refers to the drawing in which the macro is embedded.

Topics in this section

  • To run a macro from the Macros dialog box (VBA/ActiveX)

    Macros can be executed from a loaded VBA project file.

  • To run a macro from the VBA IDE (VBA/ActiveX)

    Macros can be executed from a loaded VBA project file.


To run a macro from the Macros dialog box (VBA/ActiveX)

Macros can be executed from a loaded VBA project file.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Run VBA Macro.
  2. In the Macros dialog box, Macros In drop-down list, select the project file you want to work with.
  3. In the Macros list, select a macro and click Run.

You can also work with macros in a loaded project file using the VBARUN command.


To run a macro from the VBA IDE (VBA/ActiveX)

Macros can be executed from a loaded VBA project file.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Visual Basic Editor.
  2. In the VBA IDE, in a code window, position the cursor over the function or subroutine you want to execute.
  3. From the Run menu, click Run Macro.

    If the cursor is not positioned inside a function or subroutine, or a form is not current, the Macros dialog box is displayed. Select the macro to execute and click Run.


About Editing a Macro (VBA/ActiveX)

Editing a macro will open the VBA IDE with the chosen macro open in the Code window.

Topics in this section

  • To edit a macro (VBA/ActiveX)

    Macros in a loaded VBA project file can be edited in the VBA IDE.


To edit a macro (VBA/ActiveX)

Macros in a loaded VBA project file can be edited in the VBA IDE.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Run VBA Macro.
  2. In the Macros dialog box, Macros In drop-down list, select the project file you want to work with.
  3. In the Macros list, select a macro and click Edit.


About Stepping into a Macro (VBA/ActiveX)

Stepping into a macro begins execution of the macro and then halts the execution on the first line of code. The VBA IDE is opened with the chosen macro open in the Code window at the line of execution.

Topics in this section

  • To step into a macro (VBA/ActiveX)

    As a macro is being executed, you have the option to evaluate each line of code one at a time.


To step into a macro (VBA/ActiveX)

As a macro is being executed, you have the option to evaluate each line of code one at a time.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Run VBA Macro.
  2. In the Macros dialog box, Macros In drop-down list, select the project file you want to work with.
  3. In the Macros list, select a macro and click Step Into.

    On the Debug toolbar or Debug menu, click Step Into to continue the execution of the macro one line at a time. Click Continue to resume normal execution of the macro.


About Setting Project Options (VBA/ActiveX)

There are several options that affect if a VBA project can be loaded or used during the current session.

There are three options that can be set for AutoCAD VBA projects:

  • Enable Auto Embedding
  • Allow Break on Errors
  • Enable Macro Virus Protection

Enable Auto Embedding

The auto embed feature automatically creates an embedded VBA project for all drawings when the drawing is opened.

Allow Break on Errors

This option allows VBA to enter Break mode when an error is encountered. Break mode is a temporary suspension of program execution in the interactive development environment. In Break mode, you can examine, debug, reset, step through, or continue program execution.

When this option is enabled, unhandled errors found during the execution of a VBA macro will suspend the execution of the macro and display the VBA IDE at the point of the error in the macro.

When this option is disabled, untrapped errors found during the execution of a VBA macro will display a message box alerting you to the error, and then end execution of the macro.

Enable Macro Virus Protection

The virus protection mechanism displays a built-in warning message whenever you open a drawing that may contain macro viruses.

Topics in this section

  • To set the AutoCAD VBA project options (VBA/ActiveX)

    Some of the AutoCAD VBA settings restrict the loading of project files and execution of macros.


About Setting Project Options (VBA/ActiveX)
About Setting Project Options (VBA/ActiveX)
About Editing Your Projects with the VBA IDE (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Handling Your Macros (VBA/ActiveX) > About Setting Project Options (VBA/ActiveX) >

To set the AutoCAD VBA project options (VBA/ActiveX)

Some of the AutoCAD VBA settings restrict the loading of project files and execution of macros.

  1. On the ribbon, click Manage tab [image] Applications panel [image] Run VBA Macro.
  2. In the Macros dialog box, click Options.
  3. In the Options dialog box, enable or clear the options in the dialog box based on your preferences and the security you want to provide. Click OK.


About Editing Your Projects with the VBA IDE (VBA/ActiveX)

Once a project has been loaded into AutoCAD, you can edit the code, forms, and references for that project using the VBA interactive development environment.

You can also debug and run projects from the VBA IDE. Once open, the VBA IDE provides access to all loaded projects.

Topics in this section

  • About Viewing Project Information (VBA/ActiveX)

    The VBA IDE contains a window called the Project window, which displays a list of all loaded VBA projects.

  • About Defining the Components in a Project (VBA/ActiveX)

    Each project can contain many different components.

  • About Importing Existing Components (VBA/ActiveX)

    Importing allows you to add an existing component to your project.

  • About Editing Components (VBA/ActiveX)

    You can edit standard modules, class modules, and forms in the VBA IDE. Standard and class modules are edited in a Code window. Forms are edited in the UserForm window using a special toolbox.

  • About Naming Your Project (VBA/ActiveX)

    The project name and the name of the .dvb file where the project is stored are two different values.

  • About Referencing Other VBA Projects (VBA/ActiveX)

    Referencing one VBA project from another allows developers to share code more easily.

  • About Setting the VBA IDE Options (VBA/ActiveX)

    You can change the characteristics of the VBA IDE using the Options dialog box.

  • To open the VBA IDE on demand (VBA/ActiveX)

    The VBA IDE can be opened when a project file is first loaded, or when you want to create or edit a project file that has already been loaded.


About Editing Your Projects with the VBA IDE (VBA/ActiveX)
About Editing Your Projects with the VBA IDE (VBA/ActiveX)
About Defining the Components in a Project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) >

About Viewing Project Information (VBA/ActiveX)

The VBA IDE contains a window called the Project window, which displays a list of all loaded VBA projects.

It also displays the code, class, and form modules included in the project, the document associated with the project, all other VBA projects referenced from the project, and the physical location (path) of the project.

The Project window has its own toolbar, which can be used to open various project components for editing. Use the View Code button to open the code for a selected module. Use the View Object button to display selected objects such as forms.

The Project window is visible by default. If it is not visible, select Project window from the View menu, or press Ctrl+R.


About Defining the Components in a Project (VBA/ActiveX)

Each project can contain many different components.

The different components a project can contain are

  • objects
  • forms
  • standard modules
  • class modules
  • references

Adding new components creates a blank component in your project. You can add new modules, forms, and class modules to your project. You are responsible for updating all the properties of the component (such as the name of the component) and for filling in the appropriate code. When naming new components, remember that other developers may want to use your components in future applications. Follow the appropriate naming conventions for your development team.

Objects

The object component represents the type of object, or document, that the VBA code will access. For AutoCAD VBA projects, this object represents the current AutoCAD drawing.

Forms

The form component contains the custom dialog boxes you constructed for use with your project.

Standard Modules

The code module component contains your generic procedures and functions. A standard module is also referred to as a code module, or as simply a module.

Class Modules

The class module component contains all your own objects, which are defined as classes.

References

The reference component contains all your references to other projects or libraries.


About Defining the Components in a Project (VBA/ActiveX)
About Editing Your Projects with the VBA IDE (VBA/ActiveX)
To import an existing component to your project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) >

About Importing Existing Components (VBA/ActiveX)

Importing allows you to add an existing component to your project.

You can import forms, modules, or class modules. Forms are imported as FRM files, modules are imported as BAS files, and class modules are imported as CLS files.

When you import a component file, a copy of the file you are importing is added to the project. The original file is left intact. Changes you make to the imported component do not alter the original component file.

If you import a component with the same name as an existing one, the file is added to your project with a number appended to it.

The imported component will be added to your project and will appear in the Project Explorer window. To edit the properties of the component, select that component in the Project Explorer window. The properties for the selected component will be listed and can be edited in the Properties window.

Topics in this section

  • To import an existing component to your project (VBA/ActiveX)

    Modules and user forms can be exported from one project and imported into another.


About Importing Existing Components (VBA/ActiveX)
About Importing Existing Components (VBA/ActiveX)
About Editing Components (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Importing Existing Components (VBA/ActiveX) >

To import an existing component to your project (VBA/ActiveX)

Modules and user forms can be exported from one project and imported into another.

  1. In the VBA IDE, Project Explorer window, select the project to which you will be adding the component.
  2. From the File menu, click Import File to open the Import File dialog box.
  3. From the Import File dialog box, select the file to import and click Open.


About Editing Components (VBA/ActiveX)

You can edit standard modules, class modules, and forms in the VBA IDE. Standard and class modules are edited in a Code window. Forms are edited in the UserForm window using a special toolbox.

You can open as many Code windows as you have modules, so you can easily view the code in different forms or modules, and copy and paste between them.

Topics in this section

  • About Using the Code Window (VBA/ActiveX)

    The Code window contains two drop-down lists, a split bar, a margin indicator bar, and the Full View and Procedure View icons.

  • About Using the UserForm Window (VBA/ActiveX)

    The UserForm window allows you to create custom dialog boxes in your project.

  • To edit a component in your project (VBA/ActiveX)

    Modules and user forms can be edited in a project file using the VBA IDE.

  • To access the code associated with a form (VBA/ActiveX)

    User forms have a visual component and an associated code module that can be edited using the VBA IDE.


About Editing Components (VBA/ActiveX)
About Editing Components (VBA/ActiveX)
About Using the UserForm Window (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Editing Components (VBA/ActiveX) >

About Using the Code Window (VBA/ActiveX)

The Code window contains two drop-down lists, a split bar, a margin indicator bar, and the Full View and Procedure View icons.

The two drop-down lists at the top of the Code window display the current object and procedure. You can move about your project by changing the object or procedure in these drop-down lists.

The split bar on the right side of the Code window allows you to split the window horizontally. Simply drag this bar down to create another window pane. This feature allows you to view two parts of code simultaneously in the same module. To close the pane, drag the split bar back to its original location.

The margin indicator bar is located down the left side of the Code window. It is used to display margin indicators that are used during code editing and debugging.

The Full View and Procedure View icons are located at the bottom-left corner of the Code window and toggle the display from only one procedure at a time to viewing the entire module at one time.


About Using the Code Window (VBA/ActiveX)
About Editing Components (VBA/ActiveX)
To edit a component in your project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Editing Components (VBA/ActiveX) >

About Using the UserForm Window (VBA/ActiveX)

The UserForm window allows you to create custom dialog boxes in your project.

Controls can be added by dragging the desired control from the Toolbox and placing it on the form. You can set your controls to align with the grid of your form from the General tab of the Options dialog box. You can view the form grid and determine the size of the gridlines from the General tab of the Options dialog box.

Each form you design will automatically have a Maximize, Minimize, and Close button. These buttons have already been implemented for you.


About Using the UserForm Window (VBA/ActiveX)
About Editing Components (VBA/ActiveX)
To access the code associated with a form (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Editing Components (VBA/ActiveX) >

To edit a component in your project (VBA/ActiveX)

Modules and user forms can be edited in a project file using the VBA IDE.

  1. In the VBA IDE, Project Explorer window, select the component you want to edit.
  2. Do one of the following:
    • On the Project Explorer, click the View Code button to open a Code window.
    • On the Project Explorer, click the View Object button to open a UserForm window and associated toolbox.


To edit a component in your project (VBA/ActiveX)
About Editing Components (VBA/ActiveX)
About Naming Your Project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Editing Components (VBA/ActiveX) >

To access the code associated with a form (VBA/ActiveX)

User forms have a visual component and an associated code module that can be edited using the VBA IDE.

  • Double-click any control in the UserForm window to open the Code window.

    The code window is scrolled to show the code associated with the control you double-clicked. If no code is associated with the control, a function for the default event of the control is added.


About Naming Your Project (VBA/ActiveX)

The project name and the name of the .dvb file where the project is stored are two different values.

You establish the name of the .dvb file the project is stored in when you save the project. The project name is set in the Properties window of the VBA IDE.

If you do not set the project name and file name, AutoCAD automatically assigns the following default names:

Project name: ACADProject

File name: Project.dvb

Topics in this section

  • To change the name of a project (VBA/ActiveX)

    You can rename a project from the VBA IDE.

  • To change the file name for a project (VBA/ActiveX)

    You can rename a project file from the VBA IDE.


About Naming Your Project (VBA/ActiveX)
About Naming Your Project (VBA/ActiveX)
To change the file name for a project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Naming Your Project (VBA/ActiveX) >

To change the name of a project (VBA/ActiveX)

You can rename a project from the VBA IDE.

  1. In the VBA IDE, Project Explorer window, select the project to change.
  2. Right-click the project and click <project_name> Properties.
  3. In the <project_name> - Project Properties dialog box, in the Project Name text box, edit the project's name. Click OK.


To change the name of a project (VBA/ActiveX)
About Naming Your Project (VBA/ActiveX)
About Referencing Other VBA Projects (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Naming Your Project (VBA/ActiveX) >

To change the file name for a project (VBA/ActiveX)

You can rename a project file from the VBA IDE.

  1. In the VBA IDE, click File menu [image] Save.
  2. In the Save As dialog box, enter the new name and location for the project file. Click Save.


About Referencing Other VBA Projects (VBA/ActiveX)

Referencing one VBA project from another allows developers to share code more easily.

Developers can create libraries of commonly used macros and then reference the library when needed. This keeps the shared code centrally located and supported, while allowing a large number of developers to utilize the code.

Once another project has been successfully referenced, you will notice a new folder in the Projects window of the VBA IDE. This new folder is titled References and contains the name of the project referenced.

Once you have referenced a project, you can use any public code or form component in that project.

When a project that references another project is loaded into AutoCAD, the referenced project is automatically loaded into AutoCAD as well. The referenced project cannot be closed until all projects that reference it are closed first.

You cannot make circular references. That is, you cannot reference a project that contains a reference back to the first project. If you accidentally create a circular reference, you will be notified by VBA.

Project referencing is a standard feature of Microsoft VBA. There is no additional work in AutoCAD to extend this functionality. You can find more information on referencing projects in the Microsoft VBA Help. You can open the Microsoft VBA Help from the Help menu in the VBA IDE.

NoteYou cannot reference embedded projects or VBA projects from other applications.

Topics in this section

  • To reference another VBA project (VBA/ActiveX)

    References to third-party libraries and other project files can be added to a VBA project.


About Referencing Other VBA Projects (VBA/ActiveX)
About Referencing Other VBA Projects (VBA/ActiveX)
About Setting the VBA IDE Options (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Getting Started with VBA > About Editing Your Projects with the VBA IDE (VBA/ActiveX) > About Referencing Other VBA Projects (VBA/ActiveX) >

To reference another VBA project (VBA/ActiveX)

References to third-party libraries and other project files can be added to a VBA project.

  1. In the VBA IDE, Project Explorer window, select the project to which you will be adding the reference.
  2. From the Tools menu, click References.
  3. In the References dialog box, click Browse.
  4. In the Add Reference dialog box, select the project file you want to reference and then click Open.
  5. Click OK button to complete the reference addition.


About Setting the VBA IDE Options (VBA/ActiveX)

You can change the characteristics of the VBA IDE using the Options dialog box.

To open the Options dialog box, click Tools menu [image] Options.

The Options dialog box contains four tabs:

  • Editor
  • Editor Format
  • General
  • Docking

Editor Tab

The Editor tab specifies the Code window and Project window settings.

Code settings include
  • Auto Syntax Check
  • Require Variable Declaration
  • Auto List Member
  • Auto Quick Info
  • Auto Data Tips
  • Auto Indent
  • Tab Width
Window settings include
  • Drag and Drop Text Editing
  • Default to Full Module View
  • Procedure Separator Display

Editor Format Tab

The Editor Format tab specifies the appearance of your code.

You can

  • Change color of the code
  • Change text list items
  • Change foreground
  • Change background
  • Change margin indicators
  • Change text font and size
  • Display or hide the margin indicator
  • Display or hide sample text for your settings

General Tab

The General tab specifies the settings, error handling, and compile settings for your current VBA project.

You can

  • Change the grid settings for the form grid
  • Display or hide tooltips
  • Set the automatic collapse of windows
  • Choose to receive state loss notifications
  • Determine how errors are handled
  • Set the project to compile on demand or perform background compilations

Docking Tab

The Docking tab allows you to choose which windows you want to be dockable.


To open the VBA IDE on demand (VBA/ActiveX)

The VBA IDE can be opened when a project file is first loaded, or when you want to create or edit a project file that has already been loaded.

Do one of the following:

  • On the ribbon, click Manage tab [image] Applications panel [image] Visual Basic Editor.
  • At the AutoCAD Command prompt, enter vbaide and press Enter.


Exercise: An Introduction to VBA (VBA/ActiveX)

In this exercise you will create a new AutoCAD drawing, add a line of text to that drawing, then save the drawing, all from VBA.

  1. At the AutoCAD Command prompt, enter vbaide and press Enter.
  2. In the VBA IDE, Project Explorer window, select the ThisDrawing class module or a code module in the project.
  3. On the menu bar, click View menu [image] Code to open a code window for the ThisDrawing class module.
  4. On the menu bar, click Insert menu [image] Procedure to create a new procedure in the project.
  5. In the Add Procedure dialog box, Name text box, enter HelloWorld.
  6. Under the Type section, select Sub.
  7. Under the Scope section, select Public. Click OK.
  8. Enter the following code between the lines Public Sub HelloWorld() and End Sub lines.
    ' Create a new drawing
ThisDrawing.Application.Documents.Add

Dim insPoint(0 To 2) As Double  'Declare insertion point
Dim textHeight As Double        'Declare text height
Dim textStr As String           'Declare text string
Dim textObj As AcadText         'Declare text object

insPoint(0) = 2                 'Set insertion point X coordinate
insPoint(1) = 4                 'Set insertion point Y coordinate
insPoint(2) = 0                 'Set insertion point Z coordinate

textHeight = 1                  'Set text height to 1.0
textStr = "Hello World!"        'Set the text string

'Create the Text object
Set textObj = ThisDrawing.ModelSpace.AddText _
 (textStr, insPoint, textHeight)

ThisDrawing.SaveAs("Hello.dwg")
  9. On the menu bar, click Run menu [image] Run Sub/UserForm to execute the HelloWorld subroutine.

    When the subroutine finishes executing, switch to the AutoCAD application window. The text “Hello World!” should be visible in your drawing. The drawing name should be Hello.dwg.


About More Information on the VBA IDE (VBA/ActiveX)

More information on the VBA IDE and the VBA programming language is available in the Help files provided by Microsoft.

The Microsoft Visual Basic Help can be accessed from the Help menu in the VBA IDE.


AutoCAD VBA Project Terms Reference (VBA/ActiveX)

Terms related to VBA projects and the VBA IDE.

Global Project
A VBA project stored in a .dvb file.
Embedded Project
A VBA project stored in an AutoCAD drawing.
Regular Document
An AutoCAD drawing that does not contain VBA embedded projects.
Smart Document
An AutoCAD drawing that contains one or more VBA embedded projects.
Current Project
The project currently selected in the VBA IDE.
ThisDrawing
ThisDrawing is a VBA programming term used to represent the current drawing. For global projects, ThisDrawing always refers to the active document in AutoCAD. For embedded projects, ThisDrawing always refers to the document containing the project.
VBA IDE
The VBA interactive development environment. This application allows you to edit the code and forms in your project, or copy code and forms from other projects. It also allows you to set references to other application Object Models.
VBA Manager
The VBA Manager allows you to manage your projects. You can create, delete, embed, or extract projects. You can also view which projects, if any, are embedded in an open drawing.
Macros Dialog Box
The Macros dialog box allows you to run, delete, and create new macros, and provides access to the VBA project options.


AutoCAD VBA Commands Reference (VBA/ActiveX)

Commands related to VBA projects and the VBA IDE.

VBAIDE

Brings up the VBA IDE.

The VBA IDE allows you to edit, run, and debug programs interactively. Although the VBA IDE is invoked only when AutoCAD is running, it can be minimized, opened, and closed independent of the AutoCAD Application window.

VBALOAD
Loads a VBA project into the current AutoCAD session.
VBAMAN
Displays the VBA Manager allowing you to view, create, load, close, embed, and extract projects.
VBANEW
Creates a new project.
VBAPREF
Displays the Options dialog box and allows you to set VBA-specific options for the current session.
VBARUN
Runs a VBA macro from the Macros dialog box or from the AutoCAD command line.
VBASTMT
Executes a VBA statement from the AutoCAD command line.
VBAUNLOAD

Unloads a VBA project from the current AutoCAD session.

If the VBA project is modified but not saved, the user is asked to save it with the Save Project dialog box (or command line equivalent).


AutoCAD VBA AutoLISP Functions Reference (VBA/ActiveX)

AutoLISP functions related working with VBA projects.

vl-vbaload
Loads a VBA project.
vl-vbarun
Runs a VBA macro.


To add a new component to your project (VBA/ActiveX)

New modules and user forms can be added to a VBA project file.

  1. In the VBA IDE, Project Explorer window, select the project to which you want to add a new component.
  2. From the Insert menu, click UserForm, Module, or Class Module.

    The new component is add to the project and appears in the Project Explorer window.


ActiveX Automation Basics

Topics in this section

  • About the AutoCAD Object Model

    An object is the main building block of the AutoCAD ActiveX interface.

  • About Accessing the Object Hierarchy

    Accessing the object hierarchy is easy from within VBA. This is because VBA is running in-process with the current AutoCAD session so there is no additional step needed to connect it to the application.

  • Collection Objects Reference

    A Collection object is a predefined object that contains (is a parent object for) all instances of a similar object.

  • About Properties and Methods

    Each object has associated properties and methods.

  • About Parent Objects

    Each object has a parent object to which it is permanently linked.

  • About Locating the Type Library

    The objects, properties, and methods exposed by Automation objects are contained in a type library. A type library is a file or part of a file that describes the type of one or more objects.

  • About Using Variants in Methods and Properties

    ActiveX Automation uses variants to pass arrays of data.

  • About Using Other Programming Languages

    Most of the ActiveX related topics were written for use with the VBA programming language. To use the code in other programming environments, you must update it for the chosen environment.


About the AutoCAD Object Model (VBA/ActiveX)

An object is the main building block of the AutoCAD ActiveX interface.

Each exposed object represents a precise part of AutoCAD. There are many different types of objects in the AutoCAD ActiveX interface. For example:

  • Graphical objects such as lines, arcs, text, and dimensions are objects.
  • Style settings such as linetypes and dimension styles are objects.
  • Organizational structures such as layers, groups, and blocks are objects.
  • The drawing display such as view and viewport are objects.
  • Even the drawing and the AutoCAD application are considered objects.

The objects are structured in a hierarchical fashion, with the Application object at the root. The view of this hierarchical structure is referred to as the Object Model. The Object Model shows you which object provides access to the next level of objects.

Topics in this section

  • About the Application Object (VBA/ActiveX)

    The Application object is the Root object for the AutoCAD ActiveX Automation Object Model.

  • About the Document Object (VBA/ActiveX)

    The Document object, which is actually an AutoCAD drawing, is found in the Documents collection and provides access to all of the graphical and most of the nongraphical AutoCAD objects.

  • About Collection Objects (VBA/ActiveX)

    AutoCAD groups most objects in collections. Although these collections contain different types of data, they can be processed using similar techniques.

  • About Graphical and Nongraphical Objects (VBA/ActiveX)

    A Document object, drawing, contains graphical objects and nongraphical objects that can be accessed using AutoCAD ActiveX automation.

  • About the Preferences, Plot, and Utility Objects (VBA/ActiveX)

    The AutoCAD ActiveX Automation Object Model allows you to access application preferences, plot a drawing, or use specialized utilities.

  • About Using New AutoCAD Features (VBA/ActiveX)

    If your Automation project uses a feature that was not in a previous AutoCAD version, you must explicitly declare the AutoCAD interface you are using in the project.


About the Application Object (VBA/ActiveX)

The Application object is the Root object for the AutoCAD ActiveX Automation Object Model.

From the Application object, you can access any of the other objects, or the properties or methods assigned to any object.

For example, the Application object has a Preferences property that returns the Preferences object. This object provides access to the registry-stored settings in the Options dialog box. (Drawing-stored settings are contained in the DatabasePreferences object, which will be discussed later.) Other properties of the Application object give you access to application-specific data such as the application name and version, and the AutoCAD size, location, and visibility. The methods of the Application object perform application-specific actions such as listing, loading, and unloading ADS and ARX applications, and quitting AutoCAD.

The Application object also provides links to the AutoCAD drawings through the Documents collection, the AutoCAD menus and toolbars through the MenuBar and MenuGroups collections, and the VBA IDE through a property called VBE.

The Application object is also the Global object for the ActiveX interface. This means that all the methods and properties for the Application object are available in the global name space.


About the Document Object (VBA/ActiveX)

The Document object, which is actually an AutoCAD drawing, is found in the Documents collection and provides access to all of the graphical and most of the nongraphical AutoCAD objects.

Access to the graphical objects (lines, circles, arcs, and so forth) is provided through the ModelSpace and PaperSpace collections, and access to nongraphical objects (layers, linetypes, text styles, and so forth) is provided through like-named collections such as Layers, Linetypes, and TextStyles. The Document object also provides access to the Plot and Utility objects.

To access drawing properties, use the SummaryInfo property of the Document object.


About Collection Objects (VBA/ActiveX)

AutoCAD groups most objects in collections. Although these collections contain different types of data, they can be processed using similar techniques.

Each collection has a method for adding an object to the collection. Most collections use the Add method for this purpose. However, entity objects are usually added using a method titled Add<Entityname>. For example, to add a line you would use the AddLine method.

Collections also have some other methods and properties in common. The Count property can be used to obtain a zero-based count of the objects in a collection. The Item method can be used to obtain any object within a collection.


About Graphical and Nongraphical Objects (VBA/ActiveX)

A Document object, drawing, contains graphical objects and nongraphical objects that can be accessed using AutoCAD ActiveX automation.

Graphical objects, also known as entities, are the visible objects (lines, circles, raster images, and so forth) that make up a drawing. To create these objects, use the appropriate Add<Entityname> method. To modify or query these objects, use the methods or properties of the object itself. Each graphical object has methods that allow an application to perform most of the AutoCAD editing commands such as Copy, Delete, Move, Mirror, and so forth. These objects also have methods for setting and retrieving extended data (xdata), highlighting and updating, and retrieving the bounding box of the object. Graphical objects have typical properties such as Layer, Linetype, Color, and Handle. They also have specific properties, depending on their object type, such as Center, Radius, and Area.

Nongraphical objects are the invisible (informational) objects that are part of a drawing, such as Layers, Linetypes, DimStyles, SelectionSets, and so forth. To create these objects, use the Add method of the parent Collection object. To modify or query these objects, use the methods or properties of the object itself. Each nongraphical object has methods and properties specific to its purpose; all have methods for setting and retrieving extended data (xdata), and deleting themselves.


About the Preferences, Plot, and Utility Objects (VBA/ActiveX)

The AutoCAD ActiveX Automation Object Model allows you to access application preferences, plot a drawing, or use specialized utilities.

Under the Preferences object is a set of objects, each corresponding to a tab in the Options dialog box. Together, these objects provide access to all the registry-stored settings in the Options dialog box. Drawing-stored settings are contained in the DatabasePreferences object. You can also set and modify options (and system variables that are not part of the Options dialog box) with the SetVariable and GetVariable methods.

The Plot object provides access to settings in the Plot dialog box and gives an application the ability to plot the drawing using various methods.

The Utility object provides user input and conversion functions. The user input functions are methods that prompt the user on the AutoCAD command line for input of various types of data, such as strings, integers, reals, points, and so forth. The conversion functions are methods that operate on AutoCAD-specific data types such as points and angles, in addition to string and number handling.


About Using New AutoCAD Features (VBA/ActiveX)

If your Automation project uses a feature that was not in a previous AutoCAD version, you must explicitly declare the AutoCAD interface you are using in the project.

If an Automation project contains explicit declarations of interfaces that are new in a specific version of AutoCAD, do not use that project with earlier versions of AutoCAD.


About Accessing the Object Hierarchy (VBA/ActiveX)

Accessing the object hierarchy is easy from within VBA. This is because VBA is running in-process with the current AutoCAD session so there is no additional step needed to connect it to the application.

VBA provides a link to the active drawing in the current AutoCAD session through the ThisDrawing object. By using ThisDrawing you gain immediate access to the current Document object and all of its methods and properties, and all of the other objects in the hierarchy.

When used in global projects, ThisDrawing always refers to the active document in AutoCAD. When used in embedded projects, ThisDrawing always refers to the document containing the project. For example, the following line of code in a global project saves whatever drawing is currently active in AutoCAD:

ThisDrawing.Save

Topics in this section

  • About Referencing Objects in the Object Hierarchy (VBA/ActiveX)

    You can reference objects directly or through a user-defined variable. To reference the objects directly, include the object in the calling hierarchy.

  • About Accessing the Application Object (VBA/ActiveX)

    The Application property of the Document object provides access to the Application object. The Application object is above the Document object in the object hierarchy.


About Referencing Objects in the Object Hierarchy (VBA/ActiveX)

You can reference objects directly or through a user-defined variable. To reference the objects directly, include the object in the calling hierarchy.

For example, the following statement adds a line in model space. Notice that the hierarchy starts with ThisDrawing, goes to the ModelSpace object, and then calls the AddLine method:

Dim startPoint(0 To 2) As Double, endPoint(0 To 2) As Double
Dim LineObj as AcadLine
startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
endPoint(0) = 30: endPoint(1) = 20: endPoint(2) = 0
Set LineObj = ThisDrawing.ModelSpace.AddLine(startPoint,endPoint)

To reference the objects through a user-defined variable, define the variable as the desired type, then set the variable to the appropriate object. For example, the following code defines a variable (moSpace) of type AcadModelSpace and sets the variable equal to the current model space:

Dim moSpace As AcadModelSpace
Set moSpace = ThisDrawing.ModelSpace

The following statement then adds a line to the model space using the user-defined variable:

Dim startPoint(0 To 2) As Double, endPoint(0 To 2) As Double
Dim LineObj as AcadLine
startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
endPoint(0) = 30: endPoint(1) = 20: endPoint(2) = 0
Set LineObj = moSpace.AddLine(startPoint,endPoint)

Retrieving the first entity in model space

The following example returns the first entity object in model space. Similar code can do the same for paper space entities. Note that all drawing objects can be defined as AcadEntity objects:

Sub Ch2_FindFirstEntity()
    ' This example returns the first entity in model space
    On Error Resume Next

    Dim entity As AcadEntity
    If ThisDrawing.ModelSpace.count <> 0 Then
        Set entity = ThisDrawing.ModelSpace.Item(0)
        MsgBox entity.ObjectName + _
 " is the first entity in model space."
    Else
        MsgBox "There are no objects in model space."
    End If
End Sub


About Accessing the Application Object (VBA/ActiveX)

The Application property of the Document object provides access to the Application object. The Application object is above the Document object in the object hierarchy.

The ThisDrawing object provides access to the Document object. For example, the following line of code updates the application:

ThisDrawing.Application.Update


Collection Objects Reference (VBA/ActiveX)

A Collection object is a predefined object that contains (is a parent object for) all instances of a similar object.

The following is a list of collection objects:

Collection
Contains all documents open in the current AutoCAD session.
ModelSpace Collection
Contains all graphical objects (entities) in model space.
PaperSpace Collection
Contains all graphical objects (entities) in the active paper space layout.
Block Object
Contains all entities within a specific block definition.
Blocks Collection
Contains all blocks in the drawing.
Dictionaries Collection
Contains all dictionaries in the drawing.
DimStyles Collection
Contains all dimension styles in the drawing.
FileDependencies Collection
Contains all items in the File Dependency List.
Groups Collection
Contains all groups in the drawing.
Hyperlinks Collection
Contains all hyperlinks for a given entity.
Layers Collection
Contains all layers in the drawing.
Layouts Collection
Contains all layouts in the drawing.
Linetypes Collection
Contains all linetypes in the drawing.
MenuBar Collection
Contains all menus currently displayed in AutoCAD.
MenuGroups Collection
Contains all menus and toolbars currently loaded in AutoCAD.
PlotConfigurations Collection
Contains named plot settings in the drawing.
RegisteredApplications Collection
Contains all registered applications in the drawing.
SelectionSets Collection
Contains all selection sets in the drawing.
TextStyles Collection
Contains all text styles in the drawing.
UCSs Collection
Contains all user coordinate systems (UCSs) in the drawing.
Views Collection
Contains all views in the drawing.
Viewports Collection
Contains all viewports in the drawing.

Topics in this section

  • About Accessing a Collection (VBA/ActiveX)

    Most collection objects are accessed through the Document object. The Document object contains a property for each of the Collection objects.

  • About Adding a New Member to a Collection Object (VBA/ActiveX)

    To add a new member to the collection, use the Add method.

  • About Iterating through a Collection Object (VBA/ActiveX)

    To select a specific member of a Collection object, use the Item method.

  • About Deleting a Member of a Collection Object (VBA/ActiveX)

    To delete a specific dimension style, use the Delete method found on the member object.


About Accessing a Collection (VBA/ActiveX)

Most collection objects are accessed through the Document object. The Document object contains a property for each of the Collection objects.

For example, the following code defines a variable and sets it to the Layers collection of the current drawing:

Dim layerCollection as AcadLayers
Set layerCollection = ThisDrawing.Layers

The Documents collection, MenuBar collection, and MenuGroups collection are accessed through the Application object. The Application object contains a property for each of these collections. For example, the following code defines a variable and sets it to the MenuGroups collection for the application:

Dim MenuGroupsCollection as AcadMenuGroups
Set MenuGroupsCollection = ThisDrawing.Application.MenuGroups


About Adding a New Member to a Collection Object (VBA/ActiveX)

To add a new member to the collection, use the Add method.

For example, the following code creates a new layer and adds it to the Layers collection:

Dim newLayer as AcadLayer
Set newLayer = ThisDrawing.Layers.Add("MyNewLayer")


About Iterating through a Collection Object (VBA/ActiveX)

To select a specific member of a Collection object, use the Item method.

The Item method requires an identifier as either an index number specifying the location of the item within the collection or a string representing the name of the item.

The Item method is the default method for a collection. If you do not specify a method name when referring to a collection, Item is assumed. The following statements are equivalent:

ThisDrawing.Layers.Item("ABC")
ThisDrawing.Layers("ABC")
NoteDo not use the entity edit methods (Copy, Array, Mirror, and so forth) on any object while simultaneously iterating through a collection using the For Each mechanism. Either finish your iteration before you attempt to edit an object in the collection or create a temporary array and set it equal to the collection. Then you can iterate through the copied array and perform your edits.

Iterate through the Layers collection

The following example iterates through a collection and displays the names of all layers in the collection:

Sub Ch2_IterateLayer()
    ' Iterate through the collection
    On Error Resume Next

    Dim I As Integer
    Dim msg As String
    msg = ""
    For I = 0 To ThisDrawing.Layers.count - 1
        msg = msg + ThisDrawing.Layers.Item(I).Name + vbCrLf
    Next
    MsgBox msg
End Sub

Find the layer named MyLayer

The following example refers to layer named MyLayer, and issues a message if the layer does not exist:

Sub Ch2_FindLayer()
    ' Use the Item method to find a layer named MyLayer
    On Error Resume Next

    Dim ABCLayer As AcadLayer
    Set ABCLayer = ThisDrawing.Layers("MyLayer")
    If Err <> 0 Then
        MsgBox "The layer 'MyLayer' does not exist."
    End If
End Sub


About Deleting a Member of a Collection Object (VBA/ActiveX)

To delete a specific dimension style, use the Delete method found on the member object.

For example, the following code deletes the layer ABC:

Dim ABCLayer as AcadLayer
Set ABCLayer = ThisDrawing.Layers.Item("ABC")
ABCLayer.Delete

Once an object has been deleted, you must never attempt to access the object again later in the program.


About Properties and Methods (VBA/ActiveX)

Each object has associated properties and methods.

Properties describe aspects of the individual object, while methods are actions that can be performed on the individual object. Once an object is created, you can query and edit the object through its properties and methods.

For example, a Circle object has the Center property. This property represents the 3D world coordinate system coordinate at the center of that circle. To change the center of the circle, simply set this property to the new coordinate. The Circle object also has a method called Offset. This method creates a new object at a specified offset distance from the existing circle.


About Parent Objects (VBA/ActiveX)

Each object has a parent object to which it is permanently linked.

All objects originate from a single parent object called the Root object. You can access all the objects in the interface by following the links from the root to the child objects. Additionally, objects have a property called Application that links directly back to the Root object.

The Root object for the AutoCAD interface is the AutoCAD application.


About Locating the Type Library (VBA/ActiveX)

The objects, properties, and methods exposed by Automation objects are contained in a type library. A type library is a file or part of a file that describes the type of one or more objects.

Type libraries do not store objects; they store information. By accessing a type library, applications and browsers can determine the characteristics of an object, such as the interfaces supported by the object and the names and addresses of the members of each interface.

Before you can use the Automation object exposed by an application, you must reference its type library. The Automation objects related to AutoCAD are

  • AutoCAD 2015 Type Library file, acax20enu.tlb, which is located at %ProgramFiles%\Common Files\Autodesk Shared
    NoteReference is automatically set in the VBA IDE, but needs to be set in other interactive development environments.
  • AutoCAD/ObjectDBX Common 20.0 type library file, axdb20enu.tlb, which is located at %ProgramFiles%\Common Files\Autodesk Shared
  • AcSmComponents20 1.0 type library file (Sheet Set Object library), AcSmComponents20.tlb, which is located at %ProgramFiles%\Common Files\Autodesk Shared
  • CAO 1.0 type library file (Connectivity Automation Object library), cao20enu.tlb, which is located at %ProgramFiles%\Common Files\Autodesk Shared
  • Transmittal 18.0 type library file (eTransmittal Object library), AcETransmit18.tlb, which is located at %ProgramFiles%\Common Files\Autodesk Shared
  • Autodesk Standards Manager Type Library file (CAD Standards Plug-in library), AcStMgr.tlb, which is located at %ProgramFiles%\Common Files\Autodesk Shared
    NoteUse with VB6, Managed .NET, or C++ to create stand-alone DLLs that can be used with the CAD Standards feature in AutoCAD or the Batch Standards Checker.

You can use an application's objects without referencing the application's type library. However, it is preferable to add the type library reference for the following reasons:

  • Globally accessible functions may be accessed directly without qualification.
  • Invocation of functions, properties, and methods can be checked at compile time for correctness, and therefore will execute more quickly at runtime.
  • It is possible to declare variables of the types defined in the library, which increases runtime reliability and readability.


About Using Variants in Methods and Properties (VBA/ActiveX)

ActiveX Automation uses variants to pass arrays of data.

Although this may seem confusing to a novice user, it is not difficult once you learn the basics. In addition, AutoCAD ActiveX Automation provides utilities to help you convert your data types.

Topics in this section

  • About Variants (VBA/ActiveX)

    A variant is a special data type that can contain any kind of data except fixed-length string data and user-defined types.

  • About Using Variants for Array Data (VBA/ActiveX)

    Variants are used to pass array data in and out of AutoCAD ActiveX Automation.

  • About Converting Arrays to Variants (VBA/ActiveX)

    AutoCAD ActiveX Automation provides a utility method to convert an array of data into a variant.

  • About Interpreting Variant Arrays (VBA/ActiveX)

    Array information passed back from AutoCAD ActiveX Automation is passed back as a variant.


About Using Variants in Methods and Properties (VBA/ActiveX)
About Using Variants in Methods and Properties (VBA/ActiveX)
About Using Variants for Array Data (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX Automation Basics > About Using Variants in Methods and Properties (VBA/ActiveX) >

About Variants (VBA/ActiveX)

A variant is a special data type that can contain any kind of data except fixed-length string data and user-defined types.

A variant can also contain the special values Empty, Error, Nothing, and NULL. You can determine how the data in a variant is treated using the VarType or TypeName VBA function.

You can use the Variant data type in place of most any data type to work with data in a more flexible way.


About Using Variants for Array Data (VBA/ActiveX)

Variants are used to pass array data in and out of AutoCAD ActiveX Automation.

This means that your array must be a variant to be accepted by AutoCAD ActiveX Automation methods and properties. In addition, array data output from AutoCAD ActiveX Automation must be handled as a variant.

NoteIn AutoCAD, VBA input arrays are automatically converted to variants. This means that you don't have to provide a variant array as input to the ActiveX Automation methods and properties when using them from VBA. However, all the output arrays will be in the form of variants, so remember to handle them appropriately.


About Converting Arrays to Variants (VBA/ActiveX)

AutoCAD ActiveX Automation provides a utility method to convert an array of data into a variant.

This method is the CreateTypedArray method, which creates a variant that contains an array of integers, floating numbers, doubles, and so forth. You can pass the resulting variant into any AutoCAD method or property that accepts an array of numbers as a variant.

The CreateTypedArray method takes as input the type of values that are in the array, and the array of data to be converted. It returns the array of values as a variant.

Create a spline with the CreateTypedArray method

The following code converts three arrays using CreateTypedArray: the coordinates for a spline's fit points, and the start and end tangent of the spline. It then passes the variant into the AddSpline method to create the spline.

Sub Ch2_CreateSplineUsingTypedArray()
    ' This example creates a spline object in model space
    ' using the CreateTypedArray method.
    Dim splineObj As AcadSpline
    Dim startTan As Variant
    Dim endTan As Variant
    Dim fitPoints As Variant

    Dim utilObj As Object   ' late bind the Utility object
    Set utilObj = ThisDrawing.Utility

    ' Define the Spline Object
    utilObj.CreateTypedArray _
 startTan, vbDouble, 0.5, 0.5, 0
    utilObj.CreateTypedArray _
 endTan, vbDouble, 0.5, 0.5, 0
    utilObj.CreateTypedArray _
 fitPoints, vbDouble, 0, 0, 0, 5, 5, 0, 10, 0, 0

    Set splineObj = ThisDrawing.ModelSpace.AddSpline _
 (fitPoints, startTan, endTan)

    ' Zoom in on the newly created spline
    ZoomAll

End Sub


About Converting Arrays to Variants (VBA/ActiveX)
About Using Variants in Methods and Properties (VBA/ActiveX)
About Using Other Programming Languages (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX Automation Basics > About Using Variants in Methods and Properties (VBA/ActiveX) >

About Interpreting Variant Arrays (VBA/ActiveX)

Array information passed back from AutoCAD ActiveX Automation is passed back as a variant.

If you know the data type of the array, you can simply access the variant as an array. If you do not know the data type contained in the variant, use the VBA functions VarType or Typename. These functions return the type of data in the variant. If you need to iterate through the array, you can use the VBA For Each statement.

Calculate the distance between two points

The following code demonstrates calculating the distance between two points input by the user. In this example, the data type is known because all coordinates are doubles. 3D coordinates are a three-element array of doubles and 2D coordinates are a two-element array of doubles.

Sub Ch2_CalculateDistance()
    Dim point1 As Variant
    Dim point2 As Variant

    ' Get the points from the user
    point1 = ThisDrawing.Utility.GetPoint _
 (, vbCrLf & "First point: ")
    point2 = ThisDrawing.Utility.GetPoint _
 (point1, vbCrLf & "Second point: ")

    ' Calculate the distance between point1 and point2
    Dim x As Double, y As Double, z As Double
    Dim dist As Double
    x = point1(0) - point2(0)
    y = point1(1) - point2(1)
    z = point1(2) - point2(2)
    dist = Sqr((Sqr((x ^ 2) + (y ^ 2)) ^ 2) + (z ^ 2))

    'Display the resulting distance
    MsgBox "The distance between the points is: " _
 & dist, , "Calculate Distance"
End Sub


About Using Other Programming Languages (VBA/ActiveX)

Most of the ActiveX related topics were written for use with the VBA programming language. To use the code in other programming environments, you must update it for the chosen environment.

Use the documentation for your development environment to help you convert the example code.

NoteThe registry key for COM application access for AutoCAD 2015 is AutoCAD.Application.20.

Topics in this section

  • About Converting the VBA Code to VB (VBA/ActiveX)

    To update a code example for use with VB, you must first reference the AutoCAD type library.


About Converting the VBA Code to VB (VBA/ActiveX)

To update a code example for use with VB, you must first reference the AutoCAD type library.

To do this in VB, select the References option from the Project menu to launch the References dialog box. From the References dialog box, choose the type library for AutoCAD, and then click OK.

Next, in the code example, replace all references to ThisDrawing with a user-specified variable referencing the active document. To do this, define a variable for the AutoCAD application (acadApp) and for the current document (acadDoc). Then, set the application variable to the current AutoCAD application.

If AutoCAD is running, the VB GetObject function retrieves the AutoCAD Application object when you specify the AutoCAD version number. If AutoCAD is not running, an error occurs that (in this example) is trapped, then cleared. The CreateObject function then attempts to create an AutoCAD Application object. If it succeeds, AutoCAD is started; if it fails, a message box displays a description of the error.

When running multiple sessions of AutoCAD, the GetObject function will return the first instance of AutoCAD in the Windows Running Object Table. See the Microsoft VBA documentation on the Running Object Table (ROT) and the GetObject function for more information on verifying the session returned by GetObject.

You must set the AutoCAD application's Visible property to TRUE in order to display the AutoCAD drawing window.

If GetObject creates a new instance of AutoCAD (that is, AutoCAD was not already running when you issued GetObject), failure to set Visible to TRUE results in an invisible AutoCAD application; AutoCAD will not even appear on the Windows taskbar.

NoteUse version-dependent ProgIDs. If a CreateObject or GetObject function uses a version-independent ProgID, change the function to use a version-dependent ProgID. For example, if you are using CreateObject, you change CreateObject("AutoCAD.Application") to CreateObject("AutoCAD.Application.20"). Additionally, if a GetInterfaceObject method uses a version-independent ProgID, the method must be changed to use a version-dependent ProgID.

Connect to AutoCAD from Visual Basic 6

The following code example uses the Clear and Description properties of Err. If your coding environment does not support these properties, you will need to modify the example appropriately:

Sub Ch2_ConnectToAcad()
    Dim acadApp As AcadApplication
    On Error Resume Next

    Set acadApp = GetObject(, "AutoCAD.Application.19")
    If Err Then
        Err.Clear
        Set acadApp = CreateObject("AutoCAD.Application.19")
        If Err Then
 MsgBox Err.Description
 Exit Sub
        End If
    End If
    MsgBox "Now running " + acadApp.Name + _
 " version " + acadApp.Version
End Sub

Next, set the document variable to the Document object in the AutoCAD application. The Document object is returned by the ActiveDocument property of the Application object.

Dim acadDoc as AcadDocument
Set acadDoc = acadApp.ActiveDocument

From this point on, use the acadDoc variable to reference the current AutoCAD drawing.

VBA versus VB Comparison Code Example

The following code example demonstrates creating a line in both VBA and VB.

Creating a line using VBA:

Sub Ch2_AddLineVBA()
    ' This example adds a line
    ' in model space
    Dim lineObj As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double

    ' Define the start and end
    ' points for the line
    startPoint(0) = 1
    startPoint(1) = 1
    startPoint(2) = 0
    endPoint(0) = 5
    endPoint(1) = 5
    endPoint(2) = 0

    ' Create the line in model space
    Set lineObj = ThisDrawing. _
        ModelSpace.AddLine _
        (startPoint, endPoint)

    ' Zoom in on the newly created line
    ZoomAll
End Sub

Creating a line using VB:

Sub Ch2_AddLineVB()
    On Error Resume Next

    ' Connect to the AutoCAD application
    Dim acadApp As AcadApplication
    Set acadApp = GetObject _
 (, "AutoCAD.Application.20")
    If Err Then
        Err.Clear
        Set acadApp = CreateObject _
 ("AutoCAD.Application.20")
        If Err Then
 MsgBox Err.Description
 Exit Sub
        End If
    End If

    ' Connect to the AutoCAD drawing
    Dim acadDoc As AcadDocument
    Set acadDoc = acadApp.ActiveDocument

    ' Establish the endpoints of the line
    Dim lineObj As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    startPoint(0) = 1
    startPoint(1) = 1
    startPoint(2) = 0
    endPoint(0) = 5
    endPoint(1) = 5
    endPoint(2) = 0
    ' Create a Line object in model space
    Set lineObj = acadDoc.ModelSpace.AddLine _
 (startPoint, endPoint)
    ZoomAll
    acadApp.visible = True
End Sub


Control the AutoCAD Environment

Topics in this section

  • About Opening, Saving, and Closing Drawings

    The Documents collection and Document object provide access to the AutoCAD file functions.

  • About Setting AutoCAD Preferences

    There are nine objects pertaining to options, each representing a tab in the Options dialog box.

  • About Controlling the Application Window

    The ability to control the Application window allows developers the flexibility to create effective and intelligent applications.

  • About Controlling the Drawing Windows

    You can minimize, maximize, reposition, resize, and check the state of any Document window.

  • About Resetting Active Objects

    Changes to most active objects, such as the active layer and active linetype, appear immediately.

  • About Setting and Returning System Variables

    The Document object provides the SetVariable and GetVariable methods for setting and retrieving AutoCAD system variables.

  • About Drawing with Precision

    With AutoCAD you can create your drawings with precise geometry without performing tedious calculations.

  • About Prompting for User Input

    The Utility object, which is a child of the Document object, defines the user input methods.

  • About Accessing the AutoCAD Command Line

    You can send commands directly to the AutoCAD command line by using the SendCommand method.

  • About Working with No Documents Open

    AutoCAD always starts up with a new or existing document open. It is possible, however, to close all documents during the current session.

  • About Importing Other File Formats

    You can use drawings or images from other applications by opening them in specific formats.

  • About Exporting to Other File Formats

    If you need to use an AutoCAD drawing in another application, you can convert it to a specific format by using the Export method.


About Opening, Saving, and Closing Drawings (VBA/ActiveX)

The Documents collection and Document object provide access to the AutoCAD file functions.

To create a new drawing, or open an existing drawing, use the methods on the Documents collection. The Add method creates a new drawing and adds that drawing to the Documents collection. The Open method opens an existing drawing. There is also a Close method on the Documents collection that closes all the drawings open in the AutoCAD session.

Use either the Save or SaveAs method to save a drawing. Occasionally you will want to check if the active drawing has any unsaved changes. It is a good idea to do this before you quit the AutoCAD session or start a new drawing. Use the Saved property to make sure that the current drawing does not contain any unsaved changes.

To import and export drawings, use the Import and Export methods on the Document object.

Open an existing drawing

This example uses the Open method to open an existing drawing. The VBA Dir function is used to check for the existence of the file before trying to open it. You should change the drawing file name or path to specify an existing AutoCAD drawing file on your system.

Sub Ch3_OpenDrawing()
  Dim dwgName As String
  dwgName = "c:\campus.dwg"
  If Dir(dwgName) <> "" Then
    ThisDrawing.Application.Documents.Open dwgName
  Else
    MsgBox "File " & dwgName & " does not exist."
  End If
End Sub

Create a new drawing

This example uses the Add method to create a new drawing based on the default template.

Sub Ch3_NewDrawing()
  Dim docObj As AcadDocument
  Set docObj = ThisDrawing.Application.Documents.Add
End Sub

Save the active drawing

This example saves the active drawing under its current name and again under a new name.

Sub Ch3_SaveActiveDrawing()
  ' Save the active drawing under the current name
  ThisDrawing.Save

  ' Save the active drawing under a new name
  ThisDrawing.SaveAs "MyDrawing.dwg"
End Sub

Test if a drawing has unsaved changes

This example checks to see if there are unsaved changes and verifies with the user that it is OK to save the drawing (if it is not OK, skip to the end). If OK, use the Save method to save the current drawing, as shown here:

Sub Ch3_TestIfSaved()
  If Not (ThisDrawing.Saved) Then
    If MsgBox("Do you wish to save this drawing?", _
      vbYesNo) = vbYes Then
      ThisDrawing.Save
    End If
  End If
End Sub


About Setting AutoCAD Preferences (VBA/ActiveX)

There are nine objects pertaining to options, each representing a tab in the Options dialog box.

These objects provide access to all of the registry-stored options in the Options dialog box. You can customize many of the AutoCAD settings by using properties found on these objects. These objects are

  • PreferencesDisplay
  • PreferencesDrafting
  • PreferencesFiles
  • PreferencesOpenSave
  • PreferencesOutput
  • PreferencesProfiles
  • PreferencesSelection
  • PreferencesSystem
  • PreferencesUser

These objects are accessible with the Preferences object. To gain access to the Preferences object, use the Preferences property of the Application object:

Dim acadPref as AcadPreferences
Set acadPref = ThisDrawing.Application.Preferences

You can then access any of the specific Preferences objects using the Display, Drafting, Files, OpenSave, Output, Profile, Selection, System, and User properties.

Set the crosshairs to full screen

Sub Ch2_PrefsSetCursor()
  ' This example sets the crosshairs of the AutoCAD drawing cursor
  ' to full screen.

  ' Access the Preferences object
  Dim acadPref As AcadPreferences
  Set acadPref = ThisDrawing.Application.Preferences

  ' Use the CursorSize property to set the size of the crosshairs
  acadPref.Display.CursorSize = 100
End Sub

Display the screen menu and scroll bars

Sub Ch2_PrefsSetDisplay()
  ' This example disables the scroll
  ' bars with the DisplayScrollBars
  ' properties.

  ' Access the Preferences object
  Dim acadPref As AcadPreferences
  Set acadPref = ThisDrawing.Application.Preferences

  ' Display the and disable scroll bars
  acadPref.Display.DisplayScrollBars = False
End Sub

Topics in this section

  • About Database Preferences (VBA/ActiveX)

    In addition to the nine Preferences objects, the DatabasePreferences object contains all the options stored in the drawing.


About Database Preferences (VBA/ActiveX)

In addition to the nine Preferences objects, the DatabasePreferences object contains all the options stored in the drawing.

This separate object was provided to make the drawing-stored options available to applications accessing AutoCAD drawings without first starting the AutoCAD application (ObjectDBX applications).

The DatabasePreferences object is found under the Document object.


About Controlling the Application Window (VBA/ActiveX)

The ability to control the Application window allows developers the flexibility to create effective and intelligent applications.

There will be times when it is appropriate for your application to minimize the AutoCAD window, perhaps while your code is performing work in another application such as Excel. Additionally, you will often want to verify the state of the AutoCAD window before performing such tasks as prompting for input from the user.

Using methods and properties found on the Application object, you can change the position, size, and visibility of the Application window. You can also use the WindowState property to minimize, maximize, and check the current state of the Application window.

Position and size the Application window

This example uses the WindowTop, WindowLeft, Width, and Height properties to position the AutoCAD Application window in the upper-left corner of the screen and size it to 400 pixels wide by 400 pixels high.

Sub Ch3_PositionApplicationWindow()
  ThisDrawing.Application.WindowTop = 0
  ThisDrawing.Application.WindowLeft = 0
  ThisDrawing.Application.width = 400
  ThisDrawing.Application.height = 400
End Sub

Maximize the Application window

Sub Ch3_MaximizeApplicationWindow()
  ThisDrawing.Application.WindowState = acMax
End Sub

Minimize the Application window

Sub Ch3_MinimizeApplicationWindow()
  ThisDrawing.Application.WindowState = acMin
End Sub

Find the current state of the Application window

This example queries the state of the Application window and displays the state in a message box to the user.

Sub Ch3_CurrentWindowState()
  Dim CurrWindowState As Integer
  Dim msg As String
  CurrWindowState = ThisDrawing.Application.WindowState
  msg = Choose(CurrWindowState, "normal", "minimized", "maximized")
  MsgBox "The application window is " + msg
End Sub

Make the Application window invisible

The following code uses the Visible property to make the AutoCAD application invisible to the end user.

Sub Ch3_HideWindowState()
  ThisDrawing.Application.Visible = False
End Sub


About Controlling the Drawing Windows (VBA/ActiveX)

You can minimize, maximize, reposition, resize, and check the state of any Document window.

The way a drawing is displayed within a window by using views, viewports, and zooming methods can also be manipulated with the Document object.

AutoCAD ActiveX provides many ways to display views of your drawing. You can control the drawing display to move quickly to different areas of your drawing while you track the overall effect of your changes. You can zoom to change magnification or pan to reposition the view in the graphics area, save a view and then restore it when you need to plot or refer to specific details, or display several views at one time by splitting the screen into several tiled viewports.

Topics in this section

  • About Positioning and Sizing the Document Window (VBA/ActiveX)

    Use the Document object to modify the position and size of any document window.

  • About Using Zoom (VBA/ActiveX)

    A view is a specific magnification, position, and orientation of a drawing.

  • About Using Named Views (VBA/ActiveX)

    You can name and save a view you want to reuse. When you no longer need the view, you can delete it.

  • About Using Tiled Viewports (VBA/ActiveX)

    Model space can contain one or more viewports.

  • About Updating the Geometry in the Document Window (VBA/ActiveX)

    Many of the actions you perform through AutoCAD ActiveX Automation modify what is displayed in the AutoCAD drawing.


About Positioning and Sizing the Document Window (VBA/ActiveX)

Use the Document object to modify the position and size of any document window.

The Document window can be minimized or maximized by using the WindowState property, and you can find the current state of the Document window by using the WindowState property.

Position a Document window

This example uses the Width and Height properties to set the active Document window to 400 pixels wide by 400 pixels high.

Sub Ch3_SizeDocumentWindow()
  ThisDrawing.Width = 400
  ThisDrawing.Height = 400
End Sub

Maximize the active Document window

Sub Ch3_MaximizeDocumentWindow()
  ThisDrawing.WindowState = acMax
End Sub

Minimize the active Document window

Sub Ch3_MinimizeDocumentWindow()
  ThisDrawing.WindowState = acMin
End Sub

Find the current state of the active Document window

Sub Ch3_CurrentWindowState()
  Dim CurrWindowState As Integer
  Dim msg As String
  CurrWindowState = ThisDrawing.WindowState
  msg = Choose(CurrWindowState, "normal", "minimized", "maximized")
  MsgBox "The document window is " + msg
End Sub


About Using Zoom (VBA/ActiveX)

A view is a specific magnification, position, and orientation of a drawing.

The most common way to change a view is to use one of the many AutoCAD Zoom options, which increases or decreases the size of the image displayed in the graphics area.

Topics in this section

  • About Defining a Zoom Window (VBA/ActiveX)

    You can quickly zoom in on an area by specifying the corners that define it.

  • About Scaling a View (VBA/ActiveX)

    You can increase or decrease the magnification of the image by a precise scale.

  • About Centering Objects (VBA/ActiveX)

    Zoom in on the active drawing to a specified center.

  • About Displaying Drawing Limits and Extents (VBA/ActiveX)

    You can display a view based on the drawing boundaries or the extents of the objects in the drawing with the ZoomAll, ZoomExtents, or ZoomPrevious method.


About Defining a Zoom Window (VBA/ActiveX)

You can quickly zoom in on an area by specifying the corners that define it.

To zoom in on an area by specifying its boundaries, use either the ZoomWindow or ZoomPickWindow method. The ZoomWindow method allows you to define two points representing the Zoom window programmatically. The ZoomPickWindow method requires the user to pick two points. These two picked points become the Zoom window.

Zoom the active drawing to a window defined by two points

Sub Ch3_ZoomWindow()
  ' ZoomWindow
  MsgBox "Perform a ZoomWindow with:" & vbCrLf & _
  "1.3, 7.8, 0" & vbCrLf & _
  "13.7, -2.6, 0", , "ZoomWindow"

  Dim point1(0 To 2) As Double
  Dim point2(0 To 2) As Double
  point1(0) = 1.3: point1(1) = 7.8: point1(2) = 0
  point2(0) = 13.7: point2(1) = -2.6: point2(2) = 0
  ThisDrawing.Application.ZoomWindow point1, point2
  ' ZoomPickWindow
  MsgBox "Perform a ZoomPickWindow", , "ZoomPickWindow"

  ThisDrawing.Application.ZoomPickWindow
End Sub


About Scaling a View (VBA/ActiveX)

You can increase or decrease the magnification of the image by a precise scale.

A zoom scale can be specified using one of these ways:

  • Relative to the drawing limits
  • Relative to the current view
  • Relative to paper space units

To scale a view, use the ZoomScaled method. This method takes two parameters as input: the scale and the type of scale. The scale is simply a number. How that number gets interpreted by AutoCAD depends on the type of scale you choose.

The type of scale determines if the scale value is created relative to the drawing limits, the current view, or the paper space units. To scale relative to the drawing limits, use the constant acZoomScaledAbsolute. To scale the view relative to the current view, use the constant acZoomScaledRelative. To scale relative to paper space units, use the constant acZoomScaledRelativePSpace.

Zoom in on the active drawing using a specified scale

Sub Ch3_ZoomScaled()
  MsgBox "Perform a ZoomScaled using:" & vbCrLf & _
  "Scale Type: acZoomScaledRelative" & vbCrLf & _
  "Scale Factor: 2", , "ZoomScaled"

  Dim scalefactor As Double
  Dim scaletype As Integer

  scalefactor = 2
  scaletype = acZoomScaledRelative

  ThisDrawing.Application.ZoomScaled scalefactor, scaletype
End Sub


About Centering Objects (VBA/ActiveX)

Zoom in on the active drawing to a specified center.

You can move a specific point in your drawing to the center of the graphics area. The ZoomCenter method is useful for resizing an object and bringing it to the center of the viewport. With ZoomCenter, you can specify a scale size by entering a magnification relative to the current view.

Zoom in on the active drawing to a specified center

The following example shows the effects of using ZoomCenter to display a view at the same size and at twice the size:

Sub Ch3_ZoomCenter()
  MsgBox "Perform a ZoomCenter using:" & vbCrLf & _
  "Center 3, 3, 0" & vbCrLf & _
  "Magnification: 10", , "ZoomCenter"

  Dim Center(0 To 2) As Double
  Dim magnification As Double

  Center(0) = 3: Center(1) = 3: Center(2) = 0
  magnification = 10

  ThisDrawing.Application.ZoomCenter Center, magnification
End Sub


About Displaying Drawing Limits and Extents (VBA/ActiveX)

You can display a view based on the drawing boundaries or the extents of the objects in the drawing with the ZoomAll, ZoomExtents, or ZoomPrevious method.

ZoomAll displays the entire drawing. If the objects extend beyond the limits, ZoomAll displays the extents of the objects. If the objects are drawn within the limits, ZoomAll displays the limits.

ZoomExtents calculates zooms based on the extents of the active viewport, not the current view. Usually the active viewport is entirely visible, so the results are obvious and intuitive. However, when using the Zoom methods in model space while working in a paper space viewport, if you are zoomed in beyond the paper space viewport's borders, some of the area zoomed may not be visible.

ZoomExtents changes the view to encompass the entity extents for the current drawing. In some cases (for both ZoomAll and ZoomExtents), this may cause a regeneration. Regeneration will not occur on layers that are frozen or turned off. If your drawing has no objects, ZoomExtents displays the drawing limits.

For 3D views, ZoomAll and ZoomExtents have the same effect. Infinite construction lines (xlines) and rays do not affect either option.

ZoomPrevious zooms the current viewport to its previous extents.

Zoom in on the active drawing to all contents and to the drawing extents

Sub Ch3_ZoomAll()
' ZoomAll
  MsgBox "Perform a ZoomAll", , "ZoomAll"
  ThisDrawing.Application.ZoomAll

' ZoomExtents
  MsgBox "Perform a ZoomExtents", , "ZoomExtents"
  ThisDrawing.Application.ZoomExtents
End Sub


About Using Named Views (VBA/ActiveX)

You can name and save a view you want to reuse. When you no longer need the view, you can delete it.

To create a new view, use the Add method to add a new view to the Views collection. When you save the drawing, the viewing position and scale of the view are saved.

You name the view when you create it. The name of the view can be up to 255 characters long and contain letters, digits, and the special characters dollar sign ($), hyphen (-), and underscore (_).

To delete a named view, simply use the Delete method. The Delete method for the View object lies on the View object, not its parent.

Add a View object

The following example adds a View object (viewObj).

Sub Ch3_AddView()
  ' Add a named view to the views collection
  Dim viewObj As AcadView
  Set viewObj = ThisDrawing.Views.Add("View1")
End Sub

Delete a View object

The following example deletes a View object (viewObj).

Sub Ch3_DeleteView()
  Dim viewObj As AcadView
  Set viewObj = ThisDrawing.Views("View1")
  ' Delete the view
  viewObj.Delete
End Sub

Delete a named view from the Views collection

This example deletes a named view from the Views collection.

Sub Ch3_DeleteViewFromCollection()
  ThisDrawing.Views("View1").Delete
End Sub


About Using Tiled Viewports (VBA/ActiveX)

Model space can contain one or more viewports.

AutoCAD usually begins a new drawing using a single viewport that fills the entire graphics area. You can split the drawing area to display several viewports simultaneously. For example, if you keep both the full and the detail views visible, you can see the effects of your detail changes on the entire drawing. In each tiled viewport, you can do the following:

  • Zoom, set the Snap, Grid, and UCS icon modes, and restore named views in individual viewports
  • Draw from one viewport to another when executing a command
  • Name a configuration of viewports so you can reuse it

You can display tiled viewports in various configurations. How you display the viewports depends on the number and size of the views you need to see.

Topics in this section

  • About Splitting the Active Viewport (VBA/ActiveX)

    The active viewport can be split into multiple viewports using the Split method.

  • About Making Another Tiled Viewport Current (VBA/ActiveX)

    You enter points and select objects in the current viewport. To make a viewport current, use the ActiveViewport property.


About Using Tiled Viewports (VBA/ActiveX)
About Using Tiled Viewports (VBA/ActiveX)
About Making Another Tiled Viewport Current (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Control the AutoCAD Environment > About Controlling the Drawing Windows (VBA/ActiveX) > About Using Tiled Viewports (VBA/ActiveX) >

About Splitting the Active Viewport (VBA/ActiveX)

The active viewport can be split into multiple viewports using the Split method.

This method takes one parameter, the type of configuration to split the viewport into. To specify the window configuration, use one of the following constants that correspond to the default configurations previously shown: acViewport2Horizontal, acViewport2Vertical, acViewport3Left, acViewport3Right, acViewport3Horizontal, acViewport3Vertical, acViewport3Above, acViewport3Below, or acViewport4.

Split a viewport into two horizontal windows

The following example creates a new viewport and then splits the viewport into two horizontal windows.

Sub Ch3_SplitAViewport()
  ' Create a new viewport
  Dim vportObj As AcadViewport
  Set vportObj = ThisDrawing.Viewports.Add("TEST_VIEWPORT")

  ' Split vportObj into 2 horizontal windows
  vportObj.Split acViewport2Horizontal

  ' Now set vportObj to be the active viewport
  ThisDrawing.ActiveViewport = vportObj
End Sub


About Splitting the Active Viewport (VBA/ActiveX)
About Using Tiled Viewports (VBA/ActiveX)
About Updating the Geometry in the Document Window (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Control the AutoCAD Environment > About Controlling the Drawing Windows (VBA/ActiveX) > About Using Tiled Viewports (VBA/ActiveX) >

About Making Another Tiled Viewport Current (VBA/ActiveX)

You enter points and select objects in the current viewport. To make a viewport current, use the ActiveViewport property.

You can iterate through existing viewports to find a particular viewport. To do this, first identify the name of the viewport configuration on which the desired viewport resides using the Name property. Additionally, if the viewport configuration has been split, each individual viewport on the configuration can be identified through the LowerLeftCorner and UpperRightCorner properties.

The LowerLeftCorner and UpperRightCorner properties represent the graphic placement of the viewport on the display. These properties are defined as follows (using a four-way split as an example):

In this example:

  • Viewport 1: LowerLeftCorner = (0, .5), UpperRightCorner = (.5, 1)
  • Viewport 2: LowerLeftCorner = (.5, .5), UpperRightCorner = (1, 1)
  • Viewport 3: LowerLeftCorner = (0, 0), UpperRightCorner = (.5, .5)
  • Viewport 4: LowerLeftCorner = (.5, 0), UpperRightCorner = (1, .5)

Split a viewport, then iterate through the windows

This example splits a viewport into four windows. It then iterates through all the viewports in the drawing and displays the viewport name and the lower-left and upper-right corner for each viewport.

Sub Ch3_IteratingViewportWindows()
  ' Create a new viewport and make it active
  Dim vportObj As AcadViewport
  Set vportObj = ThisDrawing.Viewports.Add("TEST_VIEWPORT")
  ThisDrawing.ActiveViewport = vportObj

  ' Split vport into 4 windows
  vportObj.Split acViewport4

  ' Iterate through the viewports,
  ' highlighting each viewport and displaying
  ' the upper right and lower left corners
  ' for each.
  Dim vport As AcadViewport
  Dim LLCorner As Variant
  Dim URCorner As Variant
  For Each vport In ThisDrawing.Viewports
    ThisDrawing.ActiveViewport = vport
    LLCorner = vport.LowerLeftCorner
    URCorner = vport.UpperRightCorner
    MsgBox "Viewport: " & vport.Name & " is now active." & _
    vbCrLf & "Lower left corner: " & _
    LLCorner(0) & ", " & LLCorner(1) & vbCrLf & _
    "Upper right corner: " & _
    URCorner(0) & ", " & URCorner(1)
  Next vport
End Sub


About Updating the Geometry in the Document Window (VBA/ActiveX)

Many of the actions you perform through AutoCAD ActiveX Automation modify what is displayed in the AutoCAD drawing.

Not all of these actions immediately update the display of the drawing. This is designed so you can make several changes to the drawing without waiting for the display to be updated after every single action. Instead, you can bundle your actions together and make a single call to update the display when you have finished.

The methods that will update the display are Update and Regen.

The Update method updates the display of a single object only. The Regen method regenerates the entire drawing and recomputes the screen coordinates and view resolution for all objects. It also reindexes the drawing database for optimum display and object selection performance.

Update the display of a single object

This example creates a circle. It then updates the circle using the Update method so the circle is visible in AutoCAD.

Sub Ch3_UpdateDisplay()
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 1: center(1) = 1: center(2) = 0
  radius = 1

  ' Create the circle
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Update the circle
  circleObj.Update
End Sub


About Resetting Active Objects (VBA/ActiveX)

Changes to most active objects, such as the active layer and active linetype, appear immediately.

However, there are several active objects that must be reset for changes to appear. These objects are the active text style, the active user coordinate system (UCS), and the active viewport. If changes are made to any of these objects, the object must be reset, and the Regen method must be called for the changes to appear.

To reset these objects, simply set the ActiveTextStyle, ActiveUCS, or ActiveViewport property, using the updated object.

Reset the active viewport

The following example changes the display of the grid in the active viewport and then resets the viewport as the active viewport to display the change.

Sub Ch3_ResetActiveViewport()
  ' Toggle the setting of the grid display
  ' for the active viewport
  ThisDrawing.ActiveViewport.GridOn = Not (ThisDrawing.ActiveViewport.GridOn)

  ' Reset the active viewport
  ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
End Sub


About Setting and Returning System Variables (VBA/ActiveX)

The Document object provides the SetVariable and GetVariable methods for setting and retrieving AutoCAD system variables.

For example, to assign an integer to the AutoCAD MAXSORT system variable, use the following code:

ThisDrawing.SetVariable "MAXSORT", 100


About Drawing with Precision (VBA/ActiveX)

With AutoCAD you can create your drawings with precise geometry without performing tedious calculations.

Often you can specify precise points without knowing the coordinates. Without leaving the drawing screen, you can perform calculations on your drawing and display various types of status information.

At this time, AutoCAD ActiveX Automation does not provide a method for the following AutoCAD capabilities:

  • Setting object snaps
  • Specifying measured intervals on objects or dividing objects into segments

Topics in this section

  • About Adjusting Snap and Grid Alignment (VBA/ActiveX)

    You can use the grid as a visual guideline and turn on Snap mode to restrict cursor movement.

  • About Using Ortho Mode (VBA/ActiveX)

    As you draw lines or move objects, you can use Ortho mode to restrict the cursor to the horizontal or vertical axis.

  • About Drawing Construction Lines (VBA/ActiveX)

    You can create construction lines that extend to infinity in one or both directions.

  • About Calculating Points and Values (VBA/ActiveX)

    By using the methods provided by the Utility object, you can quickly solve a mathematical problem or locate points on your drawing.

  • About Calculating Areas (VBA/ActiveX)

    Calculate the area defined by points entered from the user You can find the area of an arc, circle, ellipse, lightweight polyline, polyline, region, or planar-closed spline by using the Area property.


About Adjusting Snap and Grid Alignment (VBA/ActiveX)

You can use the grid as a visual guideline and turn on Snap mode to restrict cursor movement.

In addition to setting the spacing, you can adjust the snap and grid alignment. You can rotate the alignment, or you can set it for use with isometric drawings.

If you need to draw along a specific alignment or angle, you can rotate the snap angle. The center point of the snap angle rotation is the snap base point. If you need to align a hatch pattern, you can change this point, which is normally set to 0,0.

To rotate the snap angle, use the SnapRotationAngle property. To change the base point of the snap angle rotation, use the SnapBasePoint property.

NoteBoth properties require a call to the Update method to update the AutoCAD display.

Change the snap base point and rotation angle

This example changes the snap base point to (1,1) and the snap rotation angle to 30 degrees. The grid is turned on so that the changes are visible.

Sub Ch3_ChangeSnapBasePoint()
  ' Turn on the grid for the active viewport
  ThisDrawing.ActiveViewport.GridOn = True

  ' Change the snap base point to 1, 1
  Dim newBasePoint(0 To 1) As Double
  newBasePoint(0) = 1: newBasePoint(1) = 1
  ThisDrawing.ActiveViewport.SnapBasePoint = newBasePoint

  ' Change the snap rotation angle to 30 degrees (0.575 radians)
  Dim rotationAngle As Double
  rotationAngle = 0.575
  ThisDrawing.ActiveViewport.SnapRotationAngle = rotationAngle

  ' reset the viewport
  ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
End Sub


About Using Ortho Mode (VBA/ActiveX)

As you draw lines or move objects, you can use Ortho mode to restrict the cursor to the horizontal or vertical axis.

The orthogonal alignment depends on the current snap angle or the UCS. Ortho mode works with activities that require you to specify a second point. You can use Ortho not only to establish vertical or horizontal alignment but also to enforce parallelism or create regular offsets.

By allowing AutoCAD to impose orthogonal restraints, you can draw more quickly. For example, you can create a series of perpendicular lines by turning on Ortho mode before you start drawing. Because the lines are constrained to the horizontal and vertical axes, you can draw faster, knowing that the lines are perpendicular.

As you move the cursor, a rubber-band line that defines the displacement follows the horizontal or vertical axis, depending on which axis is nearest to the cursor. AutoCAD ignores Ortho mode in perspective views, or when you enter coordinates on the command line or specify an object snap.

To turn Ortho mode on or off, use the OrthoOn property. This property requires a Boolean for input. Set to TRUE to turn Ortho mode on, and to FALSE to turn Ortho mode off. For example, the following statement turns Ortho mode on for the active viewport:

ThisDrawing.ActiveViewport.OrthoOn = True


About Drawing Construction Lines (VBA/ActiveX)

You can create construction lines that extend to infinity in one or both directions.

Construction lines that extend in one direction are known as rays. Construction lines that extend in both directions are known as xlines. These construction lines can be used as a reference for creating other objects. For example, you can use construction lines to find the center of a triangle, prepare multiple views of the same item, or create temporary intersections that you can use for object snaps.

Topics in this section

  • About Creating Construction XLines (VBA/ActiveX)

    A construction xline can be placed anywhere in 3D space and extends to infinity in both directions.

  • About Querying Construction XLines (VBA/ActiveX)

    Once created, you can query a construction line (xline) to determine the points used to create the object.

  • About Creating Rays (VBA/ActiveX)

    A ray is a line in 3D space that starts at a point you specify and extends to infinity.

  • About Querying Rays (VBA/ActiveX)

    Once created, you can query a ray to determine the points used to create the object.


About Drawing Construction Lines (VBA/ActiveX)
About Drawing Construction Lines (VBA/ActiveX)
About Querying Construction XLines (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Control the AutoCAD Environment > About Drawing with Precision (VBA/ActiveX) > About Drawing Construction Lines (VBA/ActiveX) >

About Creating Construction XLines (VBA/ActiveX)

A construction xline can be placed anywhere in 3D space and extends to infinity in both directions.

To create an xline, use the AddXLine method. This method specifies the line by the two-point method; you enter or select two points to define the orientation. The first point, the root, is considered the midpoint of the construction line.

Add a construction line

The following example code creates an XLine object using the two points (5, 0, 0) and (1, 1, 0).

Sub Ch3_AddXLine()
  Dim xlineObj As AcadXline
  Dim basePoint(0 To 2) As Double
  Dim directionVec(0 To 2) As Double

  ' Define the xline
  basePoint(0) = 2#: basePoint(1) = 2#: basePoint(2) = 0#
  directionVec(0) = 1#: directionVec(1) = 1#: directionVec(2) = 0#

  ' Create the xline in model space
  Set xlineObj = ThisDrawing.ModelSpace.AddXLine(basePoint, directionVec)
  ThisDrawing.Application.ZoomAll
End Sub


About Creating Construction XLines (VBA/ActiveX)
About Drawing Construction Lines (VBA/ActiveX)
About Creating Rays (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Control the AutoCAD Environment > About Drawing with Precision (VBA/ActiveX) > About Drawing Construction Lines (VBA/ActiveX) >

About Querying Construction XLines (VBA/ActiveX)

Once created, you can query a construction line (xline) to determine the points used to create the object.

The BasePoint property can be used to obtain the first point of the xline. While the second point used to create the xline is not stored with the object, you can use the DirectionVector property to obtain the directional vector for the xline.

Query a construction line

Dim BPoint As Variant
Dim Vector As Variant

BPoint = xlineObj.BasePoint
Vector = xlineObj.DirectionVector


About Querying Construction XLines (VBA/ActiveX)
About Drawing Construction Lines (VBA/ActiveX)
About Querying Rays (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Control the AutoCAD Environment > About Drawing with Precision (VBA/ActiveX) > About Drawing Construction Lines (VBA/ActiveX) >

About Creating Rays (VBA/ActiveX)

A ray is a line in 3D space that starts at a point you specify and extends to infinity.

Unlike xline construction lines, which extend in two directions, rays extend in only one direction. As a result, rays help reduce the visual clutter caused by numerous construction lines.

Like construction lines, rays are ignored by commands that display the drawing extents.


About Creating Rays (VBA/ActiveX)
About Drawing Construction Lines (VBA/ActiveX)
About Calculating Points and Values (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Control the AutoCAD Environment > About Drawing with Precision (VBA/ActiveX) > About Drawing Construction Lines (VBA/ActiveX) >

About Querying Rays (VBA/ActiveX)

Once created, you can query a ray to determine the points used to create the object.

The BasePoint property can be used to obtain the first point of the ray. While the second point used to create the ray is not stored with the object, you can use the DirectionVector property to obtain the directional vector for the ray.

Add, query, and edit a Ray object

The following example code creates a Ray object using the two points (5, 0, 0) and (1, 1, 0). It then queries the current base point and direction vector and displays the results in a message box. The direction vector is then changed and the base point and new direction vector are queried and displayed.

Sub Ch3_EditRay()
  Dim rayObj As AcadRay
  Dim basePoint(0 To 2) As Double
  Dim secondPoint(0 To 2) As Double

  ' Define the ray
  basePoint(0) = 3#: basePoint(1) = 3#: basePoint(2) = 0#
  secondPoint(0) = 4#: secondPoint(1) = 4#: secondPoint(2) = 0#

  ' Creates a Ray object in model space
  Set rayObj = ThisDrawing.ModelSpace.AddRay(basePoint, secondPoint)
  ThisDrawing.Application.ZoomAll

  ' Find the current status of the Ray
  MsgBox "The base point of the ray is: " & _
  rayObj.basePoint(0) & ", " & _
  rayObj.basePoint(1) & ", " & _
  rayObj.basePoint(2) & vbCrLf & _
  "The directional vector for the ray is: " & _
  rayObj.DirectionVector(0) & ", " & _
  rayObj.DirectionVector(1) & ", " & _
  rayObj.DirectionVector(2), , "Edit Ray"

  ' Change the directional vector for the ray
  Dim newVector(0 To 2) As Double
  newVector(0) = -1
  newVector(1) = 1
  newVector(2) = 0
  rayObj.DirectionVector = newVector
  ThisDrawing.Regen False

  MsgBox "The base point of the ray is: " & _
  rayObj.basePoint(0) & ", " & _
  rayObj.basePoint(1) & ", " & _
  rayObj.basePoint(2) & vbCrLf & _
  "The directional vector for the ray is: " & _
  rayObj.DirectionVector(0) & ", " & _
  rayObj.DirectionVector(1) & ", " & _
  rayObj.DirectionVector(2), , "Edit Ray"
End Sub


About Calculating Points and Values (VBA/ActiveX)

By using the methods provided by the Utility object, you can quickly solve a mathematical problem or locate points on your drawing.

By using methods on the Utility object, you can do the following:

  • Find the angle of a line from the X axis with the AngleFromXAxis method
  • Convert an angle as a string to a real (double) value with the AngleToReal method
  • Convert an angle from a real (double) value to a string with the AngleToString method
  • Convert a distance from a string to a real (double) value with the DistanceToReal method
  • Create a variant that contains an array of integers, floating numbers, doubles, and so forth, with the CreateTypedArray method
  • Find the point at a specified angle and distance from a given point with the PolarPoint method
  • Translate a point from one coordinate system to another coordinate system with the TranslateCoordinates method
  • Find the distance between two points entered by the user with the GetDistance method

Find the distance between two points with the GetDistance method

This example uses the GetDistance method to obtain the point coordinates, and the MsgBox function to display the calculated distance.

Sub Ch3_GetDistanceBetweenTwoPoints()
  Dim returnDist As Double

  ' Return the value entered by user. A prompt is provided.
  returnDist = ThisDrawing.Utility.GetDistance(, "Pick two points.")
  MsgBox "The distance between the two points is: " & returnDist
End Sub


About Calculating Areas (VBA/ActiveX)

Calculate the area defined by points entered from the user You can find the area of an arc, circle, ellipse, lightweight polyline, polyline, region, or planar-closed spline by using the Area property.

If you need to calculate the combined area of more than one object, you can keep a running total as you add or use the Boolean method on a series of regions to obtain a single region representing the desired area. From this single region you can use the Area property to obtain its area.

The calculated area differs according to the type of object you query.

Topics in this section

  • About Calculating a Defined Area (VBA/ActiveX)

    The points specified by a user can be used to obtain the area of a closed region.


About Calculating a Defined Area (VBA/ActiveX)

The points specified by a user can be used to obtain the area of a closed region.

You can measure an arbitrary closed region defined by the 2D or 3D points specified by the user. The points must be coplanar.

To obtain the area specified by points from the user

  • Use the GetPoint method in a loop to obtain the points from the user.
  • Create a lightweight polyline from the points provided by the user. Use the AddLightweightPolyline method to create the polyline.
  • Use the Area property to obtain the area of the newly created polyline.
  • Erase the polyline using the Erase method.

Calculate the area defined by points entered from the user

This example prompts the user to enter five points. A polyline is then created out of the points entered. The polyline is closed, and the area of the polyline is displayed in a message box.

Sub Ch3_CalculateDefinedArea()
  Dim p1 As Variant
  Dim p2 As Variant
  Dim p3 As Variant
  Dim p4 As Variant
  Dim p5 As Variant

  ' Get the points from the user
  p1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "First point: ")
  p2 = ThisDrawing.Utility.GetPoint(p1, vbCrLf & "Second point: ")
  p3 = ThisDrawing.Utility.GetPoint(p2, vbCrLf & "Third point: ")
  p4 = ThisDrawing.Utility.GetPoint(p3, vbCrLf & "Fourth point: ")
  p5 = ThisDrawing.Utility.GetPoint(p4, vbCrLf & "Fifth point: ")

  ' Create the 2D polyline from the points
  Dim polyObj As AcadLWPolyline
  Dim vertices(0 To 9) As Double
  vertices(0) = p1(0): vertices(1) = p1(1)
  vertices(2) = p2(0): vertices(3) = p2(1)
  vertices(4) = p3(0): vertices(5) = p3(1)
  vertices(6) = p4(0): vertices(7) = p4(1)
  vertices(8) = p5(0): vertices(9) = p5(1)
  Set polyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(vertices)
  polyObj.Closed = True
  ThisDrawing.Application.ZoomAll

  ' Display the area for the polyline
  MsgBox "The area defined by the points is " & _
  polyObj.Area, , "Calculate Defined Area"
End Sub


About Prompting for User Input (VBA/ActiveX)

The Utility object, which is a child of the Document object, defines the user input methods.

The user input methods display a prompt on the AutoCAD command line and request input of various types. This type of user input is most useful for interactive input of screen coordinates, entity selection, and short-string or numeric values. If your application requires the input of numerous options or values, a dialog box may be more appropriate than individual prompts.

Each user input method displays a prompt on the AutoCAD command line and returns a value specific to the type of input requested. For example, GetString returns a string, GetPoint returns a variant (which contains a three-element array of doubles), and GetInteger returns an integer value. You can further control the input from the user with the InitializeUserInput method. This method lets you control things such as NULL input (pressing Enter), input of zero or negative numbers, and input of arbitrary text values.

To force the prompt to be displayed on a line by itself, use the carriage return/linefeed constant (vbCrLf) at the beginning of your prompt strings.

Topics in this section

  • About Requesting for a String (VBA/ActiveX)

    The GetString method prompts the user for input of a string at the AutoCAD Command prompt.

  • About Requesting a Point (VBA/ActiveX)

    The GetPoint method prompts the user for the specification of a point at the AutoCAD Command prompt.

  • About Requesting a Keyword (VBA/ActiveX)

    The GetKeyword method prompts the user for input of a keyword at the AutoCAD Command prompt.

  • About Controlling User Input (VBA/ActiveX)

    You can use the InitializeUserInput method to define keywords or restrict the type of input to the user input method.


About Requesting for a String (VBA/ActiveX)

The GetString method prompts the user for input of a string at the AutoCAD Command prompt.

This method accepts two parameters. The first parameter controls the input of spaces in the input string. If it is set to 0, spaces are not allowed (Spacebar terminates the input); if set to 1, the string can contain spaces (Enter must be used to terminate the input). The second parameter is the prompt string.

Get a string value from the user at the AutoCAD Command prompt

The following example displays the Enter Your Name prompt, and requires that the input from the user be terminated by pressing Enter (spaces are allowed in the input string). The string value is stored in the retVal variable and is displayed using a message box.

Sub Ch3_GetStringFromUser()
  Dim retVal As String
  retVal = ThisDrawing.Utility.GetString(1, vbCrLf & "Enter your name: ")
  MsgBox "The name entered was: " & retVal
End Sub

The GetString method does not honor a prior call to the InitializeUserInput method.


About Requesting a Point (VBA/ActiveX)

The GetPoint method prompts the user for the specification of a point at the AutoCAD Command prompt.

This method accepts two parameters, an optional from point and the prompt string. If the from point is provided, AutoCAD draws a rubber-band line from that point. To control the user input, this method can be preceded by a call to the InitializeUserInput method.

Get a point selected by the user

The following example prompts the user for two points, then draws a line using those points as the start point and endpoint.

Sub Ch3_GetPointsFromUser()
  Dim startPnt As Variant
  Dim endPnt As Variant
  Dim prompt1 As String
  Dim prompt2 As String

  prompt1 = vbCrLf & "Enter the start point of the line: "
  prompt2 = vbCrLf & "Enter the end point of the line: "

  ' Get the first point without entering a base point
  startPnt = ThisDrawing.Utility.GetPoint(, prompt1)

  ' Use the point entered above as the base point
  endPnt = ThisDrawing.Utility.GetPoint(startPnt, prompt2)

  ' Create a line using the two points entered
  ThisDrawing.ModelSpace.AddLine startPnt, endPnt
  ThisDrawing.Application.ZoomAll
End Sub


About Requesting a Keyword (VBA/ActiveX)

The GetKeyword method prompts the user for input of a keyword at the AutoCAD Command prompt.

This method accepts only one parameter, which is the prompt string. The keywords and input parameters are defined with a call to the InitializeUserInput method.

Get a keyword from the user at the AutoCAD Command prompt

The following example forces the user to enter a keyword by setting the first parameter of InitializeUserInput to 1, which disallows NULL input (pressing Enter). The second parameter establishes the list of valid keywords.

Sub Ch3_KeyWord()
  Dim keyWord As String
  ThisDrawing.Utility.InitializeUserInput 1, "Line Circle Arc"
  keyWord = ThisDrawing.Utility.GetKeyword(vbCrLf & "Enter an option (Line/Circle/Arc): ")
  MsgBox keyWord, , "GetKeyword Example"
End Sub

A more user-friendly keyword prompt is one that provides a default value if the user presses Enter (NULL input). Notice the minor modifications to the following example:

Sub Ch3_KeyWord2()
  Dim keyWord As String
  ThisDrawing.Utility.InitializeUserInput 0, "Line Circle Arc"
  keyWord = ThisDrawing.Utility.GetKeyword(vbCrLf & "Enter an option (Line/Circle/<Arc>): ")
  If keyWord = "" Then keyWord = "Arc"
  MsgBox keyWord, , "GetKeyword Example"
End Sub


About Controlling User Input (VBA/ActiveX)

You can use the InitializeUserInput method to define keywords or restrict the type of input to the user input method.

The use and parameter values are similar to the AutoLISP initget function. InitializeUserInput can be used with the following methods: GetAngle, GetCorner, GetDistance, GetInteger, GetKeyword, GetOrientation, GetPoint, and GetReal. InitializeUserInput cannot be used with the GetString method. Use the GetInput method to retrieve the string value (keyword or arbitrary input) when the user input method does not return a string value.

The InitializeUserInput method accepts two parameters. The first parameter is a bit-coded integer value that determines the input options for the user input method. The second parameter is a string that defines the valid keywords.

Get an integer value or a keyword from the user at the AutoCAD Command prompt

The following example prompts the user for a positive, non-negative integer value or a keyword:

Sub Ch3_UserInput()
  ' The first parameter of InitializeUserInput (6)
  ' restricts input to positive and non-negative
  ' values. The second parameter is the list of
  ' valid keywords.
  ThisDrawing.Utility.InitializeUserInput 6, "Big Small Regular"

  ' Set the prompt string variable
  Dim promptStr As String
  promptStr = vbCrLf & "Enter the size or (Big/Small/<Regular>):"

  ' At the GetInteger prompt, entering a keyword or pressing
  ' ENTER without entering a value results in an error. To allow
  ' your application to continue and check for the error
  ' description, you must set the error handler to resume on error.
  On Error Resume Next

  ' Get the value entered by the user
  Dim returnInteger As Integer
  returnInteger = ThisDrawing.Utility.GetInteger(promptStr)

  ' Check for an error. If the error number matches the
  ' one shown below, then use GetInput to get the returned
  ' string; otherwise, use the value of returnInteger.

  If Err.Number = -2145320928 Then
    Dim returnString As String
    Debug.Print Err.Description
    returnString = ThisDrawing.Utility.GetInput()
    If returnString = "" Then        'ENTER returns null string
      returnString = "Regular"     'Set to default
    End If
    Err.Clear
  Else                                 'Otherwise,
    returnString = returnInteger     'Use the value entered
  End If

  ' Display the result
  MsgBox returnString, , "InitializeUserInput Example"
End Sub


About Accessing the AutoCAD Command Line (VBA/ActiveX)

You can send commands directly to the AutoCAD command line by using the SendCommand method.

The SendCommand method sends a single string to the command line. The string must contain the arguments to the command listed in the order expected by the prompt sequence of the executed command. A blank space or the ASCII equivalent of a carriage return in the string is equivalent to pressing Enter on the keyboard. Unlike the AutoLISP environment, invoking the SendCommand method with no argument is invalid.

Send a command to the AutoCAD command line

The following example creates a circle with a center of (2, 2, 0) and a radius of 4. The drawing is then zoomed to all the geometry in the drawing. Notice that there is a space at the end of the string which represents the final Enter to begin execution of the command.

Sub Ch3_SendACommandToAutoCAD()
  ThisDrawing.SendCommand "_Circle 2,2,0 4 "
  ThisDrawing.SendCommand "_zoom a "
End Sub


About Working with No Documents Open (VBA/ActiveX)

AutoCAD always starts up with a new or existing document open. It is possible, however, to close all documents during the current session.

If you close all the documents in the AutoCAD user interface, you will notice a few changes to the application window. The available menus are reduced to simply the File, View, Window, and Help menus. These menus also have reduced available options on them. You will also notice that there is no command line.

Similarly, the ActiveX interface only allows the following actions when no documents are open:

  • You can open a document.
  • You can create a new document.
  • You can import a document.
  • You can exit out of AutoCAD.

These actions are all available from the Documents collection. The methods and properties of the Documents collection, in addition to a limited set of methods and properties of the Application object, are the only valid interface available when there are no documents open. If you perform any other action, such as attempting to access user options, your actions will result in an error.

Use the Count property on the Documents collection to determine if AutoCAD is in a zero document state. If Documents.Count = 0, then AutoCAD is in a zero document state. If Documents.Count > 0, then there is at least one drawing open.

It is also important to note that in VBA the ThisDrawing object is not defined when AutoCAD is in a zero document state. This makes sense since ThisDrawing normally refers to the active drawing and in the zero document state there are no drawings open. Attempting to execute a macro that uses ThisDrawing will result in a runtime error. To avoid the error, use the VBA GetObject function, and specify the AutoCAD version, to obtain a connection to AutoCAD when there are no documents open.


About Importing Other File Formats (VBA/ActiveX)

You can use drawings or images from other applications by opening them in specific formats.

AutoCAD handles some form of conversion for drawing interchange format (DXF)™, SAT, and WMF files. For all versions, you can import the file by using the Import method. This method takes three values as input: the name of the file to import, the insertion point in the drawing to place the file, and the scale factor to use when placing the imported drawing.


About Exporting to Other File Formats (VBA/ActiveX)

If you need to use an AutoCAD drawing in another application, you can convert it to a specific format by using the Export method.

The Export method exports a AutoCAD drawing to a WMF, SAT, EPS, DXF, or BMP format. The Export method takes three values as input: the name for the new file to be created, the extension for the new file, and the selection set of objects to export.

When exporting to WMF, SAT, or BMP format, you must provide a nonempty selection set. This selection set specifies the objects from the drawing to export. If no selection set is specified, nothing is exported and a trappable invalid argument error results.

When exporting to EPS and DXF formats, Export ignores the selection set argument, but it is still required. The entire drawing is automatically exported for these formats.

Export a drawing as a DXF file and import it again

This example creates a circle in the current drawing. It then exports the drawing to a file called DXFExprt.dxf, opens a new drawing, and imports the file. Note that an empty selection set is provided as an argument to Export. The Export method ignores selection set information when exporting a DXF file, but a syntax error results if the argument is omitted.

Sub Ch3_ImportingAndExporting()
  ' Create the circle for visual representation
  Dim circleObj As AcadCircle
  Dim centerPt(0 To 2) As Double
  Dim radius As Double
  centerPt(0) = 2: centerPt(1) = 2: centerPt(2) = 0
  radius = 1
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius)
  ThisDrawing.Application.ZoomAll

  ' Create an empty selection set
  Dim sset As AcadSelectionSet
  Set sset = ThisDrawing.SelectionSets.Add("NEWSSET")

  ' Export the current drawing to a DXF file in the
  ' AutoCAD temporary file directory
  Dim tempPath As String
  Dim exportFile As String
  Const dxfname As String = "DXFExprt"
  tempPath = ThisDrawing.Application.preferences.Files.TempFilePath
  exportFile = tempPath & dxfname
  ThisDrawing.Export exportFile, "DXF", sset

  ' Delete the empty selection set
  ThisDrawing.SelectionSets.Item("NEWSSET").Delete

  ' Open a new drawing
  ThisDrawing.Application.Documents.Add "acad.dwt"

  ' Define the import
  Dim importFile As String
  Dim insertPoint(0 To 2) As Double
  Dim scalefactor As Double
  importFile = tempPath & dxfname & ".dxf"
  insertPoint(0) = 0: insertPoint(1) = 0: insertPoint(2) = 0
  scalefactor = 2#

  ' Import the file
  ThisDrawing.Import importFile, insertPoint, scalefactor
  ThisDrawing.Application.ZoomAll
End Sub


Create and Edit AutoCAD Entities

Topics in this section

  • About Creating Objects

    While there are often several different ways to create the same graphical object in AutoCAD, ActiveX Automation offers only one creation method per object.

  • About Working with Selection Sets

    A selection set can consist of a single object, or it can be a more complex grouping: for example, the set of objects of a certain layer.

  • Modifying Objects

    To modify an existing object, use the methods and properties associated with that object. If you modify a visible property of a graphic object, use the Update method to redraw the object on screen.

  • About Adding Text to Drawings

    Text conveys important information in your drawing. Use text for title blocks, to label parts of the drawing, to give specifications, or to make annotations.

  • About Working with Layers

    You are always drawing on a layer. It may be the default layer or a layer you create and name yourself.

  • About Working with Colors

    You can assign true colors to individual objects in a drawing using the AcCmColor object.

  • About Working with Linetypes

    A linetype is a repeating pattern of dashes, dots, and blank spaces.

  • About Assigning Layers, Colors, and Linetypes to Objects

    Once you have defined layers, colors, and linetypes, you can assign them to objects in your drawing.

  • About Saving and Restoring Layer Settings


About Creating Objects (VBA/ActiveX)

While there are often several different ways to create the same graphical object in AutoCAD®, ActiveX Automation offers only one creation method per object.

For example, in AutoCAD there are four different ways you can create a circle: (1) by specifying the center and radius, (2) by two points defining the diameter, (3) by three points defining the circumference, or (4) by two tangents and a radius. However, in ActiveX Automation there is only one creation method provided to create a circle, and that method uses the center and radius.

NoteThe VB and VBA methods of creating objects using either CreateObject or Dim with the New keyword can only be used to create the AutoCAD Application object. All other AutoCAD objects must be created using the Add or Add<objectname> method provided in the AutoCAD interface.

Topics in this section

  • About Determining the Container Object (VBA/ActiveX)

    Graphical objects are created in either the ModelSpace collection, the PaperSpace collection, or a Block object.

  • About Creating Lines (VBA/ActiveX)

    The line is the most basic object in AutoCAD. You can create a variety of lines—single lines, and multiple line segments with and without arcs.

  • About Creating Curved Objects (VBA/ActiveX)

    You can create a variety of curved objects with AutoCAD, including spline curves, circles, arcs, and ellipses.

  • About Creating Point Objects (VBA/ActiveX)

    Point objects can be useful, for example, as node or reference points that you can snap to and offset objects from.

  • About Creating Solid-Filled Areas (VBA/ActiveX)

    You can create triangular and quadrilateral areas filled with a color.

  • About Working with Regions (VBA/ActiveX)

    Regions are two-dimensional enclosed areas you create from closed shapes called loops.

  • About Creating Hatches (VBA/ActiveX)

    Hatching fills a specified area in a drawing with a pattern.


About Determining the Container Object (VBA/ActiveX)

Graphical objects are created in either the ModelSpace collection, the PaperSpace collection, or a Block object.

The ModelSpace collection is returned by the ModelSpace property and the PaperSpace collection by the PaperSpace property.

You can reference these objects directly, or through a user-defined variable. To reference the objects directly, include the object in the calling hierarchy. For example, the following statement adds a line to the model space:

Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint,endPoint)

To reference the objects through a user-defined variable, define the variable as type AcadModelSpace or AcadPaperSpace, and then set the variable to the appropriate property of the active document. The following example defines two variables and sets them equal to the current model space and paper space, respectively:

Dim moSpace As AcadModelSpace
Dim paSpace As AcadPaperSpace
Set moSpace = ThisDrawing.ModelSpace
Set paSpace = ThisDrawing.PaperSpace

The following statement adds a line to the model space using the user-defined variable:

Set lineObj = moSpace.AddLine(startPoint,endPoint)


About Creating Lines (VBA/ActiveX)

The line is the most basic object in AutoCAD. You can create a variety of lines—single lines, and multiple line segments with and without arcs.

In general, you draw lines by specifying coordinate points. The default linetype is CONTINUOUS, an unbroken line, but various linetypes are available that use dots and dashes.

To create a line, use one of the following methods:

AddLine
Creates a line passing through two points.
AddLightweightPolyline
Creates a 2D lightweight polyline from a list of vertices.
AddMLine
Creates a multiline.
AddPolyline
Creates a 2D or 3D polyline.

Standard lines and multilines are created on the XY plane of the world coordinate system. Polylines and Lightweight Polylines are created in the object coordinate system (OCS).

Create a Polyline object

This example uses the AddLightweightPolyline method to create a simple two-segment polyline using the 2D coordinates (2,4), (4,2), and (6,4).

Sub Ch4_AddLightWeightPolyline()
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 5) As Double

  ' Define the 2D polyline points
  points(0) = 2: points(1) = 4
  points(2) = 4: points(3) = 2
  points(4) = 6: points(5) = 4

  ' Create a light weight Polyline object in model space
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
  ThisDrawing.Application.ZoomAll
End Sub


About Creating Curved Objects (VBA/ActiveX)

You can create a variety of curved objects with AutoCAD, including spline curves, circles, arcs, and ellipses.

All curves are created on the XY plane of the current WCS.

To create a curve, use one of the following methods:

AddArc
Creates an arc given the center, radius, start and end angles.
AddCircle
Creates a circle given the center point and radius.
AddEllipse
Creates an ellipse given the center point, a point on the major axis, and the radius ratio.
AddSpline
Creates a quadratic or cubic NURBS (nonuniform rational B-spline) curve.

Create a Spline object

This example creates a spline in model space using three points (0, 0, 0), (5, 5, 0), and (10, 0, 0). The spline has start and end tangents of (0.5, 0.5, 0.0).

Sub Ch4_CreateSpline()
  ' This example creates a spline object in model space.
  ' Declare the variables needed
  Dim splineObj As AcadSpline
  Dim startTan(0 To 2) As Double
  Dim endTan(0 To 2) As Double
  Dim fitPoints(0 To 8) As Double

  ' Define the variables
  startTan(0) = 0.5: startTan(1) = 0.5: startTan(2) = 0
  endTan(0) = 0.5: endTan(1) = 0.5: endTan(2) = 0
  fitPoints(0) = 1: fitPoints(1) = 1: fitPoints(2) = 0
  fitPoints(3) = 5: fitPoints(4) = 5: fitPoints(5) = 0
  fitPoints(6) = 10: fitPoints(7) = 0: fitPoints(8) = 0

  ' Create the spline
  Set splineObj = ThisDrawing.ModelSpace.AddSpline(fitPoints, startTan, endTan)
  ZoomAll
End Sub


About Creating Point Objects (VBA/ActiveX)

Point objects can be useful, for example, as node or reference points that you can snap to and offset objects from.

You can set the style of the point and its size relative to the screen or in absolute units.

The AutoCAD PDMODE and PDSIZE system variables control the appearance of Point objects. The PDMODE values 0, 2, 3, and 4 specify a figure to draw through the point. A value of 1 selects nothing to be displayed.

Adding 32, 64, or 96 to the previous value selects a shape to draw around the point in addition to the figure drawn through it:

PDSIZE controls the size of the point figures, except for PDMODE values 0 and 1. A 0 setting generates the point at 5 percent of the graphics area height. A positive PDSIZE value specifies an absolute size for the point figures. A negative value is interpreted as a percentage of the viewport size. The size of all points is recalculated when the drawing is regenerated.

After you change PDMODE and PDSIZE, the appearance of existing points changes the next time the drawing is regenerated.

To set PDMODE and PDSIZE, use the SetVariable method.

Create a Point object and change its appearance

The following code example creates a Point object in model space at the coordinate (5, 5, 0). The PDMODE and PDSIZE system variables are then updated.

Sub Ch4_CreatePoint()
  Dim pointObj As AcadPoint
  Dim location(0 To 2) As Double

  ' Define the location of the point
  location(0) = 5#: location(1) = 5#: location(2) = 0#

  ' Create the point
  Set pointObj = ThisDrawing.ModelSpace.AddPoint(location)
  ThisDrawing.SetVariable "PDMODE", 34
  ThisDrawing.SetVariable "PDSIZE", 1
  ZoomAll
End Sub


About Creating Solid-Filled Areas (VBA/ActiveX)

You can create triangular and quadrilateral areas filled with a color.

For quicker results, create these areas with the AutoCAD FILLMODE system variable off, then turn FILLMODE on to fill the finished area.

When you create a quadrilateral solid-filled area, the sequence of the third and fourth points determines its shape. Compare the following illustrations:

The first two points define one edge of the polygon. The third point is defined diagonally opposite from the second. If the fourth point is set equal to the third point, then a filled triangle is created.

To create a solid-filled area, use the AddSolid method.

Create a solid-filled object

The following code example creates a quadrilateral solid in model space using the coordinates (0, 0, 0), (5, 0, 0), (5, 8, 0), and (0, 8, 0).

Sub Ch4_CreateSolid()
  Dim solidObj As AcadSolid
  Dim point1(0 To 2) As Double
  Dim point2(0 To 2) As Double
  Dim point3(0 To 2) As Double
  Dim point4(0 To 2) As Double

  ' Define the solid
  point1(0) = 0#: point1(1) = 0#: point1(2) = 0#
  point2(0) = 5#: point2(1) = 0#: point2(2) = 0#
  point3(0) = 5#: point3(1) = 8#: point3(2) = 0#
  point4(0) = 0#: point4(1) = 8#: point4(2) = 0#

  ' Create the solid object in model space
  Set solidObj = ThisDrawing.ModelSpace.AddSolid(point1, point2, point3, point4)
  ZoomAll
End Sub


About Working with Regions (VBA/ActiveX)

Regions are two-dimensional enclosed areas you create from closed shapes called loops.

A loop is a curve or a sequence of connected curves that defines an area on a plane with a boundary that does not intersect itself. Loops can be combinations of lines, lightweight polylines, circles, arcs, ellipses, elliptical arcs, splines, 3D faces, traces, and solids. The objects that make up the loops must either be closed or form closed areas by sharing endpoints with other objects. They must also be coplanar (on the same plane). The loops that make up a region must be defined as an array of objects.

Topics in this section

  • About Creating Regions (VBA/ActiveX)

    To create a region, use the AddRegion method.

  • About Creating Composite Regions (VBA/ActiveX)

    You can create composite regions by subtracting, combining, or finding the intersection of regions or 3D solids.


About Creating Regions (VBA/ActiveX)

To create a region, use the AddRegion method.

This method will create a region out of every closed loop formed by the input array of curves. AutoCAD converts closed 2D and planar 3D polylines to separate regions, then converts polylines, lines, and curves that form closed planar loops. If more than two curves share an endpoint, the resulting region might be arbitrary. Because of this, several regions may actually be created when using the AddRegion method. Use a variant to hold the newly created array of regions.

To calculate the total number of Region objects created, use the UBound and LBound VBA functions, as in the following example:

UBound(objRegions) - LBound(objRegions) + 1

where objRegions is a variant containing the return value from AddRegion. This statement will calculate the total number of regions created.

Create a simple region

The following code example creates a region from a single circle.

Sub Ch4_CreateRegion()
  ' Define an array to hold the
  ' boundaries of the region.
  Dim curves(0 To 0) As AcadCircle

  ' Create a circle to become a
  ' boundary for the region.
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2
  center(1) = 2
  center(2) = 0
  radius = 5#
  Set curves(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Create the region
  Dim regionObj As Variant
  regionObj = ThisDrawing.ModelSpace.AddRegion(curves)

  ZoomAll
End Sub


About Creating Composite Regions (VBA/ActiveX)

You can create composite regions by subtracting, combining, or finding the intersection of regions or 3D solids.

You can then extrude or revolve composite regions to create complex solids. To create a composite region, use the Boolean method.

When you subtract one region from another, you call the Boolean method from the first region. This is the region from which you want to subtract. For example, to calculate how much carpeting is needed for a floor plan, call the Boolean method from the outer boundary of the floor space and use the uncarpeted areas, such as pillars and counters, as the object in the Boolean parameter list.

The operation performed on the regions is determined by the BooleanType parameter of the Boolean method. The BooleanType parameter can be one of the following:

  • acIntersection - Performs an intersection operation.
  • acSubtraction - Performs a subtraction operation.
  • acUnion - Performs a union operation.

Create a composite region

Sub Ch4_CreateCompositeRegions()
  ' Create two circles, one representing a room,
  ' the other a pillar in the center of the room
  Dim RoomObjects(0 To 1) As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 4
  center(1) = 4
  center(2) = 0
  radius = 2#
  Set RoomObjects(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)
  radius = 1#
  Set RoomObjects(1) = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Create a region from the two circles
  Dim regions As Variant
  regions = ThisDrawing.ModelSpace.AddRegion(RoomObjects)

  ' Copy the regions into the region variables for ease of use
  Dim RoundRoomObj As AcadRegion
  Dim PillarObj As AcadRegion

  If regions(0).Area > regions(1).Area Then
    ' The first region is the room
    Set RoundRoomObj = regions(0)
    Set PillarObj = regions(1)
  Else
    ' The first region is the pillar
    Set PillarObj = regions(0)
    Set RoundRoomObj = regions(1)
  End If

  ' Subtract the pillar space from the floor space to
  ' get a region that represents the total carpet area.
  RoundRoomObj.Boolean acSubtraction, PillarObj

  ' Use the Area property to determine the total carpet area
  MsgBox "The carpet area is: " & RoundRoomObj.Area
End Sub

Find the area of the resulting region with the Area property.


About Creating Hatches (VBA/ActiveX)

Hatching fills a specified area in a drawing with a pattern.

When creating the Hatch object, you specify the hatch pattern type, the hatch pattern name, and the associativity. Once the Hatch object has been created, you will not be able to change the hatch associativity.

The following explains the order in which a Hatch object is created and defined:

  1. Create the Hatch object.
  2. Specify the outer loop, which is the outermost boundary for the hatch.
  3. Specify any inner loops that may exist in the hatch.

To create a Hatch object, use the AddHatch method.

Associative Hatch

You can create associative or nonassociative hatches. Associative hatches are linked to their boundaries and updated when the boundaries are modified. Nonassociative hatches are independent of their boundaries.

Associativity can only be set when a hatch is created. Once a hatch has been created, you can unassociate it, but you cannot associate it again.

To make a hatch associative, set the Associativity parameter of the AddHatch method to TRUE. To make a hatch nonassociative, set the Associativity parameter of the AddHatch method to FALSE.

Topics in this section

  • About Assigning the Hatch Pattern Type and Name (VBA/ActiveX)

    AutoCAD supplies a solid-fill and more than fifty industry-standard hatch patterns.

  • About Defining the Hatch Boundaries (VBA/ActiveX)

    Once the Hatch object is created, the hatch boundaries can be added. Boundaries can be any combination of lines, arcs, circles, 2D polylines, ellipses, splines, and regions.


About Assigning the Hatch Pattern Type and Name (VBA/ActiveX)

AutoCAD supplies a solid-fill and more than fifty industry-standard hatch patterns.

Hatch patterns highlight a particular feature or area of a drawing. For example, patterns can help differentiate the components of a 3D object or represent the materials that make up an object.

You can use a pattern supplied with AutoCAD or one from an external pattern library.

To specify a unique pattern, you must enter both a pattern type and a pattern name when creating the Hatch object. The pattern type specifies where to look up the pattern name. When entering the pattern type, use one of the following constants:

acHatchPatternTypePredefined
Selects the pattern name from those defined in the acad.pat or acadiso.pat file.
acHatchPatternTypeUserDefined
Defines a pattern of lines using the current linetype.
acHatchPatternTypeCustomDefined
Selects the pattern name from a PAT other than the acad.pat or acadiso.pat file.

When entering the pattern name, use a name that is valid for the file specified by the pattern type.


About Assigning the Hatch Pattern Type and Name (VBA/ActiveX)
About Creating Hatches (VBA/ActiveX)
About Working with Selection Sets (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Creating Objects (VBA/ActiveX) > About Creating Hatches (VBA/ActiveX) >

About Defining the Hatch Boundaries (VBA/ActiveX)

Once the Hatch object is created, the hatch boundaries can be added. Boundaries can be any combination of lines, arcs, circles, 2D polylines, ellipses, splines, and regions.

The first boundary added must be the outer boundary, which defines the outermost limits to be filled by the hatch. To add the outer boundary, use the AppendOuterLoop method.

Once the outer boundary is defined, you can continue adding inner boundaries. Add inner boundaries with the AppendInnerLoop method.

Inner boundaries define islands within the hatch. How these islands are handled by the Hatch object depends on the setting of the HatchStyle property. The HatchStyle property can be set to one of the following conditions:

Hatch style definitions
HatchStyle | Condition | Description
 | Normal | Specifies standard style, or normal. This option hatches inward from the outermost area boundary. If AutoCAD encounters an internal boundary, it turns off hatching until it encounters another boundary. This is the default setting for the HatchStyle property.
 | Outer | Fills the outermost areas only. This style also hatches inward from the area boundary, but it turns off hatching if it encounters an internal boundary and does not turn it back on again.
 | Ignore | Ignores internal structure. This option hatches through all internal objects.

When you have finished defining the hatch it must be evaluated before it can be displayed. Use the Evaluate method to do this.

Create a Hatch object

This example creates an associate hatch in model space. Once the hatch has been created, you can change the size of the circle that the hatch is associated with. The hatch will change to match the current circle size.

Sub Ch4_CreateHatch()
  Dim hatchObj As AcadHatch
  Dim patternName As String
  Dim PatternType As Long
  Dim bAssociativity As Boolean

  ' Define the hatch
  patternName = "ANSI31"
  PatternType = 0
  bAssociativity = True

  ' Create the associative Hatch object
  Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)

  ' Create the outer boundary for the hatch. (a circle)
  Dim outerLoop(0 To 0) As AcadEntity
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 3: center(1) = 3: center(2) = 0
  radius = 1
  Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Append the outer boundary to the hatch
  ' object, and display the hatch
  hatchObj.AppendOuterLoop (outerLoop)
  hatchObj.Evaluate
  ThisDrawing.Regen True
End Sub


About Working with Selection Sets (VBA/ActiveX)

A selection set can consist of a single object, or it can be a more complex grouping: for example, the set of objects of a certain layer.

Defining a selection set is a two-step process. First, you must create a new selection set and add it to the SelectionSets collection. Once created, you then populate the selection set with the objects you want to process.

Topics in this section

  • About Creating a Selection Set (VBA/ActiveX)

    To create a named selection set, use the Add method. This method requires only a single parameter—the name of the selection set.

  • About Adding Objects to a Selection Set (VBA/ActiveX)

    You can add objects to the active selection set.

  • About Defining Rules for Selection Sets (VBA/ActiveX)

    You can limit selection sets by property or by object type using filter lists.

  • About Displaying Information About a Selection Set (VBA/ActiveX)

    To refer to an existing selection set whose name you know, refer to it by name.

  • About Removing Objects from a Selection Set (VBA/ActiveX)

    After you create a selection set, you can choose to remove individual objects, or all the objects from that set.


About Creating a Selection Set (VBA/ActiveX)

To create a named selection set, use the Add method. This method requires only a single parameter—the name of the selection set.

If a selection set of the same name already exists, AutoCAD returns an error message. It is a good programming practice to delete a selection set when you no longer need it. Use the Delete method to delete a selection set, as in the following example:

ThisDrawing.SelectionSets.Item("NewSelectionSet").Delete

Create an empty selection set

This example creates a new selection set.

Sub Ch4_CreateSelectionSet()
  Dim selectionSet1 As AcadSelectionSet
  Set selectionSet1 = ThisDrawing.SelectionSets.Add("NewSelectionSet")
End Sub


About Adding Objects to a Selection Set (VBA/ActiveX)

You can add objects to the active selection set.

Use any of the following methods to add an object to a selection set:

AddItems
Adds one or more objects to the specified selection set.
Select
Selects objects and places them into the active selection set. You can select all objects, objects within and crossing a rectangular area, objects within and crossing a polygon area, all objects crossing a fence, the most recently created object, the objects in the most recent selection set, objects within a window, or objects within a window polygon.
SelectAtPoint
Selects objects passing through a given point and places them into the active selection set.
SelectByPolygon
Selects objects within a fence and adds them to the active selection set.
SelectOnScreen
Prompts the user to pick objects from the screen and adds them into the active selection set.

Add selected objects to a selection set

This example prompts the user to select objects, then adds those objects to the selection set.

Sub Ch4_AddToASelectionSet()
  ' Create a new selection set
  Dim sset As AcadSelectionSet
  Set sset = ThisDrawing.SelectionSets.Add("SS1")

  ' Prompt the user to select objects
  ' and add them to the selection set.
  ' To finish selecting, press ENTER.
  sset.SelectOnScreen
End Sub


About Adding Objects to a Selection Set (VBA/ActiveX)
About Working with Selection Sets (VBA/ActiveX)
About Using Filter Lists to Define Selection Set Rules (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Working with Selection Sets (VBA/ActiveX) >

About Defining Rules for Selection Sets (VBA/ActiveX)

You can limit selection sets by property or by object type using filter lists.

For example, you can copy only the blue objects in a circuit board drawing, or only objects on a certain layer. You can also combine selection criteria in your filter list. For example, you can tell AutoCAD to include an object in a selection set only if it is a blue circle on a specific layer. Filter lists can be specified for the Select, SelectAtPoint, SelectByPolygon, and SelectOnScreen methods.

NoteFiltering recognizes only linetypes explicitly assigned to objects, not those inherited by the layer.

Topics in this section

  • About Using Filter Lists to Define Selection Set Rules (VBA/ActiveX)

    Filter lists are composed of pairs of arguments.

  • About Specifying Multiple Criteria in a Selection Set Filter List (VBA/ActiveX)

    To specify multiple selection criteria, declare an array containing enough elements to represent each criterion, and assign each criterion to an element.

  • About Adding Complexity to Your Filter List Conditions (VBA/ActiveX)

    When you specify multiple selection criteria, AutoCAD assumes the selected object must meet each criterion. But you can qualify your criteria in other ways.

  • About Using Wild-Card Patterns in Selection Set Filter Criteria (VBA/ActiveX)

    Symbol names and strings in filter lists can include wild-card patterns.

  • About Filtering for Extended Data (VBA/ActiveX)

    External applications can attach data such as text strings, numeric values, 3D points, distances, and layer names to AutoCAD objects.


About Defining Rules for Selection Sets (VBA/ActiveX)
About Defining Rules for Selection Sets (VBA/ActiveX)
About Specifying Multiple Criteria in a Selection Set Filter List (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Working with Selection Sets (VBA/ActiveX) > About Defining Rules for Selection Sets (VBA/ActiveX) >

About Using Filter Lists to Define Selection Set Rules (VBA/ActiveX)

Filter lists are composed of pairs of arguments.

The first argument identifies the type of filter (for example, an object), and the second argument specifies the value you are filtering on (for example, circles). The filter type is a DXF group code that specifies which filter to use. A few of the most common filter types are listed here.

DXF codes for common filters
DXF code | Filter type
0 | Object Type (String) Such as “Line,” “Circle,” “Arc,” and so forth.
2 | Object Name (String) The table (given) name of a named object.
8 | Layer Name (String) Such as “Layer 0.”
60 | Object Visibility (Integer) Use 0 = visible, 1 = invisible.
62 | Color Number (Integer) Numeric index values ranging from 0 to 256. Zero indicates BYBLOCK. 256 indicates BYLAYER. A negative value indicates that the layer is turned off.
67 | Model/paper space indicator (Integer) Use 0 or omitted = model space, 1 = paper space.

The filter arguments are declared as arrays. The filter type is declared as an integer and the filter value as a variant. Each filter type must be paired with a filter value. For example:

FilterType(0) = 0            'Indicates filter refers to an object type
FilterData(0) = "Circle"     'Indicates the object type is "Circle"

Specify a single selection criterion for a selection set

The following code prompts users to select objects to be included in a selection set, but only adds the selected object if it is a circle:

Sub Ch4_FilterMtext()
  Dim sstext As AcadSelectionSet
  Dim FilterType(0) As Integer
  Dim FilterData(0) As Variant
  Set sstext = ThisDrawing.SelectionSets.Add("SS2")
  FilterType(0) = 0
  FilterData(0) = "Circle"
  sstext.SelectOnScreen FilterType, FilterData
End Sub


About Using Filter Lists to Define Selection Set Rules (VBA/ActiveX)
About Defining Rules for Selection Sets (VBA/ActiveX)
About Adding Complexity to Your Filter List Conditions (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Working with Selection Sets (VBA/ActiveX) > About Defining Rules for Selection Sets (VBA/ActiveX) >

About Specifying Multiple Criteria in a Selection Set Filter List (VBA/ActiveX)

To specify multiple selection criteria, declare an array containing enough elements to represent each criterion, and assign each criterion to an element.

Select objects that meet three criteria

The following code specifies two criteria: the object must be a circle and it must reside on layer 0. The code declares FilterType and FilterData as arrays of two elements, and assigns each criterion to an element:

Sub Ch4_FilterBlueCircleOnLayer0()
  Dim sstext As AcadSelectionSet
  Dim FilterType(1) As Integer
  Dim FilterData(1) As Variant
  Set sstext = ThisDrawing.SelectionSets.Add("SS4")

  FilterType(0) = 0
  FilterData(0) = "Circle"

  FilterType(1) = 8
  FilterData(1) = "0"

  sstext.SelectOnScreen FilterType, FilterData
End Sub


About Specifying Multiple Criteria in a Selection Set Filter List (VBA/ActiveX)
About Defining Rules for Selection Sets (VBA/ActiveX)
About Using Wild-Card Patterns in Selection Set Filter Criteria (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Working with Selection Sets (VBA/ActiveX) > About Defining Rules for Selection Sets (VBA/ActiveX) >

About Adding Complexity to Your Filter List Conditions (VBA/ActiveX)

When you specify multiple selection criteria, AutoCAD assumes the selected object must meet each criterion. But you can qualify your criteria in other ways.

For numeric items, you can specify relational operations (for example, the radius of a circle must be greater than or equal to 5.0). And for all items, you can specify logical operations (for example, Text or Mtext).

Use a -4 DXF code to indicate a relational operator in your filter specification. Specify the operator as a string. The allowable relational operators are shown in the following table.

Relational operators for selection set filter lists
Operator | Description
"*" | Anything goes (always true)
"=" | Equals
"!=" | Not equal to
"/=" | Not equal to
"<>" | Not equal to
"<" | Less than
"<=" | Less than or equal to
">" | Greater than
">=" | Greater than or equal to
"&" | Bitwise AND (integer groups only)
"&=" | Bitwise masked equals (integer groups only)

Logical operators in filter lists are also indicated by a -4 group code, and the operator is a string, but the operators must be paired. The opening operator is preceded by a less-than symbol (<), and the closing operator is followed by a greater-than symbol (>). The following table lists the logical operators allowed in selection set filtering.

Logical grouping operators for selection set filter lists
Starting operator | Encloses | Ending operator
"<AND" | One or more operands | "AND>"
"<OR" | One or more operands | "OR>"
"<XOR" | Two operands | "XOR>"
"<NOT" | One operand | "NOT>"

Select a circle whose radius is greater than or equal to 5.0

The following code specifies that the selected object must be a circle whose radius is greater than or equal to 5.0:

Sub Ch4_FilterRelational()
  Dim sstext As AcadSelectionSet
  Dim FilterType(2) As Integer
  Dim FilterData(2) As Variant
  Set sstext = ThisDrawing.SelectionSets.Add("SS5")

  FilterType(0) = 0
  FilterData(0) = "Circle"
  FilterType(1) = -4
  FilterData(1) = ">="
  FilterType(2) = 40
  FilterData(2) = 5#

  sstext.SelectOnScreen FilterType, FilterData
End Sub

Select either Text or Mtext

The following example specifies that either Text or Mtext objects can be selected:

Sub Ch4_FilterOrTest()
  Dim sstext As AcadSelectionSet
  Dim FilterType(3) As Integer
  Dim FilterData(3) As Variant
  Set sstext = ThisDrawing.SelectionSets.Add("SS6")
  FilterType(0) = -4
  FilterData(0) = "<or"
  FilterType(1) = 0
  FilterData(1) = "TEXT"
  FilterType(2) = 0
  FilterData(2) = "MTEXT"
  FilterType(3) = -4
  FilterData(3) = "or>"

  sstext.SelectOnScreen FilterType, FilterData
End Sub


About Adding Complexity to Your Filter List Conditions (VBA/ActiveX)
About Defining Rules for Selection Sets (VBA/ActiveX)
About Filtering for Extended Data (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Working with Selection Sets (VBA/ActiveX) > About Defining Rules for Selection Sets (VBA/ActiveX) >

About Using Wild-Card Patterns in Selection Set Filter Criteria (VBA/ActiveX)

Symbol names and strings in filter lists can include wild-card patterns.

The following table identifies the wild-card characters recognized by AutoCAD, and what each means in the context of a string:

Wild-card characters
Character | Definition
# (pound) | Matches any single numeric digit
@ (at) | Matches any single alphabetic character
. (period) | Matches any single nonalphanumeric character
* (asterisk) | Matches any character sequence, including an empty one, and it can be used anywhere in the search pattern: at the beginning, middle, or end
? (question mark) | Matches any single character
~ (tilde) | If it is the first character in the pattern, it matches anything except the pattern
[...] | Matches any one of the characters enclosed
[~...] | Matches any single character not enclosed
- (hyphen) | Used inside brackets to specify a range for a single character
, (comma) | Separates two patterns
` (reverse quote) | Escapes special characters (reads next character literally)

Use a single quote (`) to indicate that a character is not a wildcard, but is to be taken literally. For example, to specify that only an anonymous block named “*U2” be included in the selection set, use the following filter arguments:

FilterType(0) = 2
FilterData(0) = "`*U2"

Select Mtext where a specific word appears in the text

The following code defines the selection criteria as any Mtext in which “The” appears in the text string. This example also demonstrates use of the SelectByPolygon selection method:

Sub Ch4_FilterPolygonWildcard()
  Dim sstext As AcadSelectionSet
  Dim FilterType(1) As Integer
  Dim FilterData(1) As Variant
  Dim pointsArray(0 To 11) As Double
  Dim mode As Integer
  mode = acSelectionSetWindowPolygon
  pointsArray(0) = -12#: pointsArray(1) = -7#: pointsArray(2) = 0
  pointsArray(3) = -12#: pointsArray(4) = 10#: pointsArray(5) = 0
  pointsArray(6) = 10#: pointsArray(7) = 10#: pointsArray(8) = 0
  pointsArray(9) = 10#: pointsArray(10) = -7#: pointsArray(11) = 0
  Set sstext = ThisDrawing.SelectionSets.Add("SS10")

  FilterType(0) = 0
  FilterData(0) = "MTEXT"
  FilterType(1) = 1
  FilterData(1) = "*The*"

  sstext.SelectByPolygon mode, pointsArray, FilterType, FilterData
End Sub


About Using Wild-Card Patterns in Selection Set Filter Criteria (VBA/ActiveX)
About Defining Rules for Selection Sets (VBA/ActiveX)
About Displaying Information About a Selection Set (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Working with Selection Sets (VBA/ActiveX) > About Defining Rules for Selection Sets (VBA/ActiveX) >

About Filtering for Extended Data (VBA/ActiveX)

External applications can attach data such as text strings, numeric values, 3D points, distances, and layer names to AutoCAD objects.

This data is referred to as extended data, or xdata. You can filter entities containing extended data for a specified application.

Select circles that contain xdata

The following example filters for circles containing xdata added by the “MY_APP” application:

Sub Ch4_FilterXdata()
  Dim sstext As AcadSelectionSet
  Dim mode As Integer
  Dim pointsArray(0 To 11) As Double
  mode = acSelectionSetWindowPolygon
  pointsArray(0) = -12#: pointsArray(1) = -7#: pointsArray(2) = 0
  pointsArray(3) = -12#: pointsArray(4) = 10#: pointsArray(5) = 0
  pointsArray(6) = 10#: pointsArray(7) = 10#: pointsArray(8) = 0
  pointsArray(9) = 10#: pointsArray(10) = -7#: pointsArray(11) = 0
  Dim FilterType(1) As Integer
  Dim FilterData(1) As Variant
  Set sstext = ThisDrawing.SelectionSets.Add("SS9")

  FilterType(0) = 0
  FilterData(0) = "Circle"
  FilterType(1) = 1001
  FilterData(1) = "MY_APP"

  sstext.SelectByPolygon mode, pointsArray, FilterType, FilterData
End Sub


About Displaying Information About a Selection Set (VBA/ActiveX)

To refer to an existing selection set whose name you know, refer to it by name.

The following example refers to a selection set named “SS10:”

Sub GetObjInSet()
  Dim selset As AcadSelectionSet
  Set selset = ThisDrawing.SelectionSets("SS10")

  MsgBox ("Selection set " & selset.Name & " contains " & _
    selset.Count & " items")
End Sub

Each selection set in a drawing is a member of the SelectionSets collection. You can use the For Each statement to iterate through a drawing's SelectionSets collection and collect information about each selection set.

Display the name of each selection set in a drawing

The following code displays the name of each selection set in a drawing, and lists the types of objects included in each selection set:

Sub ListSelectionSets()
  Dim selsetCollection As AcadSelectionSets
  Dim selset As AcadSelectionSet
  Dim ent As Object
  Dim i, j As Integer

  Set selsetCollection = ThisDrawing.SelectionSets

  ' Find each selection set in the drawing
  i = 0
  For Each selset In selsetCollection
    MsgBox "Selection set " & CStr(i) & " is: " & selset.Name

    ' Now find each object in the selection set, and say what it is
    j = 0
    For Each ent In selset
       MsgBox "Item " & CStr(j + 1) & " in " & selset.Name _
         & "is: " & ent.EntityName
       j = j + 1
    Next
    i = i + 1
  Next
End Sub


About Removing Objects from a Selection Set (VBA/ActiveX)

After you create a selection set, you can choose to remove individual objects, or all the objects from that set.

For example, you can select an entire group of densely grouped objects and remove specific objects within the group, leaving only the objects you want to be in the set.

Use the following methods to remove items from the selection set:

RemoveItems
The RemoveItems method removes one or more items from a selection set. The removed items still exist, but they no longer reside in the selection set.
Clear
The Clear method will empty the selection set. The selection set will still exist, but contains no items. The items that previously resided in the selection still exist, but they no longer reside in the selection set.
Erase
The Erase method deletes all items in a selection set. The selection set still exists, but will contain no items. The items that previously resided in the selection set no longer exist.
Delete
The Delete method deletes a selection set and all items in the selection set. Neither the selection set nor the items previously in the selection set will exist after a call to the Delete method.


Modifying Objects

To modify an existing object, use the methods and properties associated with that object. If you modify a visible property of a graphic object, use the Update method to redraw the object on screen.

Topics in this section

  • About Working with Named Objects (VBA/ActiveX)

    In addition to the graphic objects used by AutoCAD, there are several types of nongraphical objects stored in drawing files.

  • About Copying Objects (VBA/ActiveX)

    You can copy single or multiple objects within the current drawing.

  • About Offsetting Objects (VBA/ActiveX)

    Offsetting an object creates a new object at a specified offset distance from the original object.

  • About Mirroring Objects (VBA/ActiveX)

    Mirroring creates a mirror image copy of an object around an axis or mirror line. You can mirror all drawing objects.

  • About Creating Rectangular Arrays (VBA/ActiveX)

    To create a 2D or 3D rectangular array, use the ArrayRectangular method provided for that object.

  • About Creating Polar Arrays (VBA/ActiveX)

    You can array all drawing objects to fill a circular pattern.

  • About Moving Objects Along a Vector (VBA/ActiveX)

    You can move all drawing objects and attribute reference objects along a specified vector.

  • About Rotating Objects (VBA/ActiveX)

    You can rotate all drawing objects and attribute reference objects.

  • About Erasing or Deleting Objects (VBA/ActiveX)

    You can erase or delete individual objects by using the Delete method.

  • About Scaling Objects (VBA/ActiveX)

    You scale an object by specifying a base point and a length, which is used as a scale factor based on the current drawing units. You can scale all the drawing objects, as well as attribute reference objects.

  • About Transforming Objects (VBA/ActiveX)

    You move, scale, or rotate an object given a 4 by 4 transformation matrix using the TransformBy method.

  • About Extending and Trimming Objects (VBA/ActiveX)

    You can change the angle of arcs and you can change the length of open lines, arcs, open polylines, elliptical arcs, and open splines. The results are similar to both extending and trimming objects.

  • About Exploding Objects (VBA/ActiveX)

    Exploding objects converts the objects from single objects to their constituent parts but has no visible effect.

  • About Editing Polylines (VBA/ActiveX)

    2D and 3D polylines, rectangles, polygons, and 3D polygon meshes are all polyline variants and are edited in the same way.

  • About Editing Splines (VBA/ActiveX)

    Existing spline objects can be edited using the object's properties and methods.

  • About Editing Hatches (VBA/ActiveX)

    You can edit both hatch boundaries and hatch patterns.


About Working with Named Objects (VBA/ActiveX)

In addition to the graphic objects used by AutoCAD, there are several types of nongraphical objects stored in drawing files.

These objects have descriptive designations associated with them, for example, blocks, layers, groups, and dimension styles. In most cases, you name objects as you create them, and rename them later. Names are stored in symbol tables. When you specify a named object, you are referencing the name and associated data of the object in the symbol table.

Topics in this section

  • About Purging Named Objects (VBA/ActiveX)

    You can purge unused, unreferenced named objects from a drawing at any time during an editing session.

  • About Renaming Objects (VBA/ActiveX)

    As your drawings become more complex, you can rename objects to keep the names meaningful or to avoid conflicts with names in other drawings you have inserted in the main drawings.


About Purging Named Objects (VBA/ActiveX)

You can purge unused, unreferenced named objects from a drawing at any time during an editing session.

Purging reduces drawing size. You cannot purge objects that are referenced by other objects. For example, a font file might be referenced by a text style. A layer is referenced by the objects on the layer.

To purge a drawing, use the PurgeAll method, as follows:

ThisDrawing.PurgeAll


About Renaming Objects (VBA/ActiveX)

As your drawings become more complex, you can rename objects to keep the names meaningful or to avoid conflicts with names in other drawings you have inserted in the main drawings.

You can rename any named object except those that AutoCAD names by default, for example, layer 0 or the CONTINUOUS linetype.

Names can be up to 255 characters long. In addition to letters and numbers, names can contain spaces (although AutoCAD removes spaces that appear directly before and after a name) and any special character not used by Microsoft Windows or AutoCAD for other purposes. Special characters that you cannot use include less-than and greater-than symbols (< >), forward slashes and backslashes (/ \), quotation marks ("), colons (:), semicolons (;), question marks (?), commas (,), asterisks (*), vertical bars (|), equal signs (=), and single quotes ('). You also cannot use special characters created with Unicode fonts.

To rename an object, use the Name property for that object.

Rename a layer

This example creates a layer called “NewLayer” and then renames the layer to “MyLayer”.

Sub Ch4_RenamingLayer()
  ' Create a layer
  Dim layerObj As AcadLayer
  Set layerObj = ThisDrawing.Layers.Add("NewLayer")

  ' Change the name of the layer
  layerObj.Name = "MyLayer"
End Sub


About Copying Objects (VBA/ActiveX)

You can copy single or multiple objects within the current drawing.

Offsetting creates new objects at a specified distance from selected objects, or through a specified point. Mirroring creates a mirror image of objects in a specified mirror line. Arraying creates sets of copied objects in a rectangular or circular pattern.

NoteYou cannot perform any of the copy methods while simultaneously iterating through a collection. An iteration will open the workspace for a read-only operation while these methods attempt to perform a read-write operation. Complete any iteration of a collection before you call these methods.

Topics in this section

  • About Copying an Object to the Same Location (VBA/ActiveX)

    To copy a single object, use the Copy method provided for that object.

  • About Copying Multiple Objects (VBA/ActiveX)

    To copy multiple objects, use the CopyObjects method or create an array of objects to use with the Copy method.


About Copying an Object to the Same Location (VBA/ActiveX)

To copy a single object, use the Copy method provided for that object.

The Copy method creates a new object that is a duplicate of the original object. The new object is located at the same position as the original, and is returned by the method.


About Copying Multiple Objects (VBA/ActiveX)

To copy multiple objects, use the CopyObjects method or create an array of objects to use with the Copy method.

To copy the objects in a selection set, iterate through the selection set and save the objects into an array. Iterate through the array, copying each object individually, and collect the newly created objects in a second array.

To copy multiple objects to a different drawing, use the CopyObjects method and set the Owner parameter to the drawing's model space.

Copy two Circle objects

This example creates two Circle objects and uses the CopyObjects method to make a copy of the circles.

Sub Ch4_CopyCircleObjects()
  Dim DOC1 As AcadDocument
  Dim circleObj1 As AcadCircle
  Dim circleObj2 As AcadCircle
  Dim circleObj1Copy As AcadCircle
  Dim circleObj2Copy As AcadCircle
  Dim centerPoint(0 To 2) As Double
  Dim radius1 As Double
  Dim radius2 As Double
  Dim radius1Copy As Double
  Dim radius2Copy As Double
  Dim objCollection(0 To 1) As Object
  Dim retObjects As Variant

  ' Define the Circle object
  centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
  radius1 = 5#: radius2 = 7#
  radius1Copy = 1#: radius2Copy = 2#

  ' Create a new drawing
  Set DOC1 = ThisDrawing.Application.Documents.Add

  ' Add two circles to the drawing
  Set circleObj1 = DOC1.ModelSpace.AddCircle(centerPoint, radius1)
  Set circleObj2 = DOC1.ModelSpace.AddCircle(centerPoint, radius2)
  ZoomAll

  ' Put the objects to be copied into a form
  ' compatible with CopyObjects
  Set objCollection(0) = circleObj1
  Set objCollection(1) = circleObj2

  ' Copy object and get back a collection of
  ' the new objects (copies)
  retObjects = DOC1.CopyObjects(objCollection)

  ' Get newly created object and apply
  ' new properties to the copies
  Set circleObj1Copy = retObjects(0)
  Set circleObj2Copy = retObjects(1)

  circleObj1Copy.Radius = radius1Copy
  circleObj1Copy.Color = acRed
  circleObj2Copy.Radius = radius2Copy
  circleObj2Copy.Color = acRed

  ZoomAll
End Sub

Copy objects to another drawing

This example creates Circle objects, then uses the CopyObjects method to copy the circles into a new drawing.

Sub Ch4_Copy_to_New_Drawing()
  Dim DOC0 As AcadDocument
  Dim circleObj1 As AcadCircle, circleObj2 As AcadCircle
  Dim centerPoint(0 To 2) As Double
  Dim radius1 As Double, radius2 As Double
  Dim radius1Copy As Double, radius2Copy As Double
  Dim objCollection(0 To 1) As Object
  Dim retObjects As Variant

  ' Define the Circle object
  centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
  radius1 = 5#: radius2 = 7#
  radius1Copy = 1#: radius2Copy = 2#

  ' Add two circles to the current drawing
  Set circleObj1 = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius1)
  Set circleObj2 = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius2)
  ThisDrawing.Application.ZoomAll

  ' Save pointer to the current drawing
  Set DOC0 = ThisDrawing.Application.ActiveDocument

  ' Copy objects
  '
  ' First put the objects to be copied into a form compatible
  ' with CopyObjects
  Set objCollection(0) = circleObj1
  Set objCollection(1) = circleObj2

  ' Create a new drawing and point to its model space
  Dim Doc1MSpace As AcadModelSpace
  Dim DOC1 As AcadDocument

  Set DOC1 = Documents.Add
  Set Doc1MSpace = DOC1.ModelSpace

  ' Copy the objects into the model space of the new drawing. A
  ' collection of the new (copied) objects is returned.
  retObjects = DOC0.CopyObjects(objCollection, Doc1MSpace)

  Dim circleObj1Copy As AcadCircle, circleObj2Copy As AcadCircle

  ' Get the newly created object collection and apply new
  ' properties to the copies.
  Set circleObj1Copy = retObjects(0)
  Set circleObj2Copy = retObjects(1)

  circleObj1Copy.radius = radius1Copy
  circleObj1Copy.Color = acRed
  circleObj2Copy.radius = radius2Copy
  circleObj2Copy.Color = acRed

  ThisDrawing.Application.ZoomAll

  MsgBox "Circles copied."
End Sub


About Offsetting Objects (VBA/ActiveX)

Offsetting an object creates a new object at a specified offset distance from the original object.

You can offset arcs, circles, ellipses, lines, lightweight polylines, polylines, splines, and xlines.

To offset an object, use the Offset method provided for that object. The only input to this method is the distance to offset the object. If this distance is negative, it is interpreted by AutoCAD as being an offset to make a “smaller” curve (that is, for an arc it would offset to a radius that is the given distance less than the starting curve's radius). If “smaller” has no meaning, then AutoCAD would offset in the direction of smaller X,Y,Z WCS coordinates. If the offset distance is invalid, then an error is returned.

For many objects, the result of this operation will be a single new curve (which may not be of the same type as the original curve). For example, offsetting an ellipse will result in a spline because the result does fit the equation of an ellipse. In some cases it may be necessary for the offset result to be several curves. Because of this, the method returns the new object, or array of objects, as a variant.

Offset a polyline

This example creates a lightweight polyline and then offsets the polyline.

Sub Ch4_OffsetPolyline()
  ' Create the polyline
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 11) As Double
  points(0) = 1: points(1) = 1
  points(2) = 1: points(3) = 2
  points(4) = 2: points(5) = 2
  points(6) = 3: points(7) = 2
  points(8) = 4: points(9) = 4
  points(10) = 4: points(11) = 1
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
  plineObj.Closed = True
  ZoomAll

  ' Offset the polyline
  Dim offsetObj As Variant
  offsetObj = plineObj.Offset(0.25)

  ZoomAll
End Sub


About Mirroring Objects (VBA/ActiveX)

Mirroring creates a mirror image copy of an object around an axis or mirror line. You can mirror all drawing objects.

To mirror an object, use the Mirror method provided for that object. This method requires two coordinates as input. The two coordinates specified become the endpoints of the mirror line around which the base object is reflected. In 3D, this line orients a mirroring plane perpendicular to the XY plane of the UCS containing the mirror line.

Unlike the MIRROR command in AutoCAD, this method places the reflected image into the drawing and retains the original object. (To remove the original object, use the Erase method.)

To manage the reflection properties of Text objects, use the AutoCAD MIRRTEXT system variable. The default setting of MIRRTEXT is On (1), which causes Text objects to be mirrored just as any other object. When MIRRTEXT is Off (0), text is not mirrored. Use the GetVariable and SetVariable methods to query and set the MIRRTEXT setting.

You can mirror a Viewport object in paper space, although doing so has no effect on its model space view or on model space objects.

Mirror a polyline about an axis

This example creates a lightweight polyline and mirrors that polyline about an axis. The newly created polyline is colored blue.

Sub Ch4_MirrorPolyline()
  ' Create the polyline
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 11) As Double
  points(0) = 1: points(1) = 1
  points(2) = 1: points(3) = 2
  points(4) = 2: points(5) = 2
  points(6) = 3: points(7) = 2
  points(8) = 4: points(9) = 4
  points(10) = 4: points(11) = 1
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
  plineObj.Closed = True
  ZoomAll

  ' Define the mirror axis
  Dim point1(0 To 2) As Double
  Dim point2(0 To 2) As Double
  point1(0) = 0: point1(1) = 4.25: point1(2) = 0
  point2(0) = 4: point2(1) = 4.25: point2(2) = 0

  ' Mirror the polyline
  Dim mirrorObj As AcadLWPolyline
  Set mirrorObj = plineObj.Mirror(point1, point2)

  Dim col As New AcadAcCmColor
  Call col.SetRGB(125, 175, 235)
  mirrorObj.TrueColor = col

  ZoomAll
End Sub


About Creating Rectangular Arrays (VBA/ActiveX)

To create a 2D or 3D rectangular array, use the ArrayRectangular method provided for that object.

This method requires you to provide the number of rows, number of columns, distance between rows, and distance between columns. When creating a 3D array, you must also specify the number of levels and distance between levels as well.

A rectangular array is constructed by replicating the object in the selection set the appropriate number of times. If you define one row, you must specify more than one column and vice versa.

The original object is assumed to be in the lower-left corner, and the array is generated up and to the right. If the distance between rows is a negative number, rows are added downward. If the distance between columns is a negative number, the columns are added to the left.

AutoCAD builds the rectangular array along a baseline defined by the current snap rotation angle. This angle is 0 by default, so the rows and columns of a rectangular array are orthogonal with respect to the X and Y drawing axes. You can change this angle and create a rotated array by setting the snap rotation angle to a nonzero value. To do this, use the SnapRotationAngle property.

Create a rectangular array

This example creates a circle and then performs a rectangular array of the circle, creating five rows and five columns of circles.

Sub Ch4_ArrayRectangularExample()
  ' Create the circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2#: center(1) = 2#: center(2) = 0#
  radius = 0.5
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
  ZoomAll

  ' Define the rectangular array
  Dim numberOfRows As Long
  Dim numberOfColumns As Long
  Dim numberOfLevels As Long
  Dim distanceBwtnRows As Double
  Dim distanceBwtnColumns As Double
  Dim distanceBwtnLevels As Double
  numberOfRows = 5
  numberOfColumns = 5
  numberOfLevels = 2
  distanceBwtnRows = 1
  distanceBwtnColumns = 1
  distanceBwtnLevels = 1

  ' Create the array of objects
  Dim retObj As Variant
  retObj = circleObj.ArrayRectangular _
      (numberOfRows, numberOfColumns, numberOfLevels, _
      distanceBwtnRows, distanceBwtnColumns, distanceBwtnLevels)

  ZoomAll
End Sub


About Creating Polar Arrays (VBA/ActiveX)

You can array all drawing objects to fill a circular pattern.

To create a polar array, use the ArrayPolar method provided for that object. This method requires you to provide the number of objects to create, the angle-to-fill, and the center point for the array. The number of objects must be a positive integer greater than 1. The angle-to-fill must be in radians. A positive value specifies counterclockwise rotation. A negative value specifies clockwise rotation. An error is returned for an angle that equals 0. The center point is a variant array containing three doubles. These doubles represent the 3D WCS coordinate specifying the center point for the polar array.

AutoCAD determines the distance from the array's center point to a reference point on the original object. The reference point used depends on the type of object. AutoCAD uses the center point of a circle or arc, the insertion point of a block or shape, the start point of text, and one endpoint of a line or trace.

This method does not support the Rotate While Copying option of the AutoCAD ARRAY command.

Create a polar array

This example creates a circle, and then performs a polar array of the circle. This creates four circles filling 180 degrees around a base point of (4, 4, 0).

Sub Ch4_ArrayingACircle()
  ' Create the circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2#: center(1) = 2#: center(2) = 0#
  radius = 1
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
  ZoomAll

  ' Define the polar array
  Dim noOfObjects As Integer
  Dim angleToFill As Double
  Dim basePnt(0 To 2) As Double
  noOfObjects = 4
  angleToFill = 3.14          ' 180 degrees
  basePnt(0) = 4#: basePnt(1) = 4#: basePnt(2) = 0#

  ' The following example will create 4 copies
  ' of an object by rotating and copying it about
  ' the point (3,3,0).
  Dim retObj As Variant
  retObj = circleObj.ArrayPolar(noOfObjects, angleToFill, basePnt)

  ZoomAll
End Sub


About Moving Objects Along a Vector (VBA/ActiveX)

You can move all drawing objects and attribute reference objects along a specified vector.

To move an object, use the Move method provided for that object. This method requires two coordinates as input. These coordinates define a displacement vector indicating how far the given object is to be moved and in what direction.

Move a circle along a vector

This example creates a circle and then moves that circle two units along the X axis.

Sub Ch4_MoveCircle()
  ' Create the circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2#: center(1) = 2#: center(2) = 0#
  radius = 0.5
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
  ZoomAll

  ' Define the points that make up the move vector.
  ' The move vector will move the circle 2 units
  ' along the x axis.
  Dim point1(0 To 2) As Double
  Dim point2(0 To 2) As Double
  point1(0) = 0: point1(1) = 0: point1(2) = 0
  point2(0) = 2: point2(1) = 0: point2(2) = 0

  ' Move the circle
  circleObj.Move point1, point2
  circleObj.Update
End Sub


About Rotating Objects (VBA/ActiveX)

You can rotate all drawing objects and attribute reference objects.

To rotate an object, use the Rotate method provided for that object. This method requires as input a base point and a rotation angle. The base point is a variant array with three doubles. These doubles represent a 3D WCS coordinate specifying the point through which the axis of rotation is defined. The angle of rotation is specified in radians. This angle determines how far an object rotates around the base point relative to its current location.

Rotate a polyline about a base point

This example creates a closed lightweight polyline, and then rotates the polyline 45 degrees about the base point (4, 4.25, 0).

Sub Ch4_RotatePolyline()
  ' Create the polyline
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 11) As Double
  points(0) = 1: points(1) = 2
  points(2) = 1: points(3) = 3
  points(4) = 2: points(5) = 3
  points(6) = 3: points(7) = 3
  points(8) = 4: points(9) = 4
  points(10) = 4: points(11) = 2
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
  plineObj.Closed = True
  ZoomAll

  ' Define the rotation of 45 degrees about a
  ' base point of (4, 4.25, 0)
  Dim basePoint(0 To 2) As Double
  Dim rotationAngle As Double
  basePoint(0) = 4: basePoint(1) = 4.25: basePoint(2) = 0
  rotationAngle = 0.7853981   ' 45 degrees

  ' Rotate the polyline
  plineObj.Rotate basePoint, rotationAngle
  plineObj.Update
End Sub


About Erasing or Deleting Objects (VBA/ActiveX)

You can erase or delete individual objects by using the Delete method.

NoteThe Collection objects in ActiveX Automation have a Delete method due to the manner in which these objects have been defined in the type library. However, the Collection objects, such as ModelSpace collection, Layers collection, and Dictionaries collection, should never be deleted. An error will result if you attempt to delete a collection.

Create and delete a polyline

This example creates a lightweight polyline, then deletes it.

Sub Ch4_DeletePolyline()
  ' Create the polyline
  Dim lwpolyObj As AcadLWPolyline
  Dim vertices(0 To 5) As Double
  vertices(0) = 2: vertices(1) = 4
  vertices(2) = 4: vertices(3) = 2
  vertices(4) = 6: vertices(5) = 4
  Set lwpolyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(vertices)
  ZoomAll

  ' Erase the polyline
  lwpolyObj.Delete
  ThisDrawing.Regen acActiveViewport
End Sub


About Scaling Objects (VBA/ActiveX)

You scale an object by specifying a base point and a length, which is used as a scale factor based on the current drawing units. You can scale all the drawing objects, as well as attribute reference objects.

To scale an object, use the ScaleEntity method provided for that object. This method scales the object equally in the X, Y, and Z directions. It takes as input the base point for the scale and a scale factor. The base point is a variant array with three doubles. These doubles represent a 3D WCS coordinate specifying the point from which the scale begins. The scale factor is the factor by which to scale the object. The dimensions of the object are multiplied by the scale factor. A scale factor greater than 1 enlarges the object. A scale factor between 0 and 1 reduces the object.

Scale a polyline

This example creates a closed lightweight polyline and then scales the polyline by 0.5.

Sub Ch4_ScalePolyline()
  ' Create the polyline
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 11) As Double
  points(0) = 1: points(1) = 2
  points(2) = 1: points(3) = 3
  points(4) = 2: points(5) = 3
  points(6) = 3: points(7) = 3
  points(8) = 4: points(9) = 4
  points(10) = 4: points(11) = 2
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
  plineObj.Closed = True
  ZoomAll

  ' Define the scale
  Dim basePoint(0 To 2) As Double
  Dim scalefactor As Double
  basePoint(0) = 4: basePoint(1) = 4.25: basePoint(2) = 0
  scalefactor = 0.5

  ' Scale the polyline
  plineObj.ScaleEntity basePoint, scalefactor
  plineObj.Update
End Sub


About Transforming Objects (VBA/ActiveX)

You move, scale, or rotate an object given a 4 by 4 transformation matrix using the TransformBy method.

The following table demonstrates the transformation matrix configuration, where R = Rotation and T = Translation:

Transformation matrix configuration
R00 | R01 | R02 | T0
R10 | R11 | R12 | T1
R20 | R21 | R22 | T2
0 | 0 | 0 | 1

To transform an object, first initialize the transformation matrix. The following example shows a transformation matrix, assigned to the variable tMatrix, which will rotate an entity by 90 degrees about the point (0, 0, 0):

tMatrix(0,0) = 0.0
tMatrix(0,1) = -1.0
tMatrix(0,2) = 0.0
tMatrix(0,3) = 0.0
tMatrix(1,0) = 1.0
tMatrix(1,1) = 0.0
tMatrix(1,2) = 0.0
tMatrix(1,3) = 0.0
tMatrix(2,0) = 0.0
tMatrix(2,1) = 0.0
tMatrix(2,2) = 1.0
tMatrix(2,3) = 0.0
tMatrix(3,0) = 0.0
tMatrix(3,1) = 0.0
tMatrix(3,2) = 0.0
tMatrix(3,3) = 1.0

After the transformation matrix is complete, apply the matrix to the object using the TransformBy method. The following line of code demonstrates applying a matrix (tMatrix) to an object (anObj):

anObj.TransformBy tMatrix

Rotate a line with a transformation matrix

This example creates a line and rotates it 90 degrees using a transformation matrix.

Sub Ch4_TransformBy()
  ' Create a line
  Dim lineObj As AcadLine
  Dim startPt(0 To 2) As Double
  Dim endPt(0 To 2) As Double
  startPt(0) = 2
  startPt(1) = 1
  startPt(2) = 0
  endPt(0) = 5
  endPt(1) = 1
  endPt(2) = 0
  Set lineObj = ThisDrawing.ModelSpace.AddLine(startPt, endPt)
  ZoomAll

  ' Initialize the transMat variable with a
  ' transformation matrix that will rotate
  ' an object by 90 degrees about the point(0,0,0)
  Dim transMat(0 To 3, 0 To 3) As Double
  transMat(0, 0) = 0#: transMat(0, 1) = -1#
  transMat(0, 2) = 0#: transMat(0, 3) = 0#
  transMat(1, 0) = 1#: transMat(1, 1) = 0#
  transMat(1, 2) = 0#: transMat(1, 3) = 0#
  transMat(2, 0) = 0#: transMat(2, 1) = 0#
  transMat(2, 2) = 1#: transMat(2, 3) = 0#
  transMat(3, 0) = 0#: transMat(3, 1) = 0#
  transMat(3, 2) = 0#: transMat(3, 3) = 1#

  ' Transform the line using the defined transformation matrix
  lineObj.TransformBy transMat
  lineObj.Update
End Sub

The following are more examples of transformation matrices:

Rotation Matrix: 90 degrees about point (0, 0, 0)
0.0 | -1.0 | 0.0 | 0.0
1.0 | 0.0 | 0.0 | 0.0
0.0 | 0.0 | 1.0 | 0.0
0.0 | 0.0 | 0.0 | 1.0
Rotation Matrix: 45 degrees about point (5, 5, 0)
0.707107 | -0.707107 | 0.0 | 5.0
0.707107 | 0.707107 | 0.0 | -2.071068
0.0 | 0.0 | 1.0 | 0.0
0.0 | 0.0 | 0.0 | 1.0
Translation Matrix: move an entity by (10, 10, 0)
1.0 | 0.0 | 0.0 | 10.0
0.0 | 1.0 | 0.0 | 10.0
0.0 | 0.0 | 1.0 | 0.0
0.0 | 0.0 | 0.0 | 1.0
Scaling Matrix: scale by 10,10 at point (0, 0, 0)
10.0 | 0.0 | 0.0 | 0.0
0.0 | 10.0 | 0.0 | 0.0
0.0 | 0.0 | 10.0 | 0.0
0.0 | 0.0 | 0.0 | 1.0
Scaling Matrix: scale by 10,10 at point (2, 2, 0)
10.0 | 0.0 | 0.0 | -18.0
0.0 | 10.0 | 0.0 | -18.0
0.0 | 0.0 | 10.0 | 0.0
0.0 | 0.0 | 0.0 | 1.0


About Extending and Trimming Objects (VBA/ActiveX)

You can change the angle of arcs and you can change the length of open lines, arcs, open polylines, elliptical arcs, and open splines. The results are similar to both extending and trimming objects.

You can extend or trim an object by editing its properties. For example, to lengthen a line, simply change the coordinates of the StartPoint or EndPoint properties. To change the angle of an arc, change the StartAngle or EndAngle property of the arc. Once you have altered an object's property or properties, use the Update method to see your changes in the drawing.

Lengthen a line

This example creates a line and then changes the endpoint of that line, resulting in a longer line.

Sub Ch4_LengthenLine()
  ' Define and create the line
  Dim lineObj As AcadLine
  Dim startPoint(0 To 2) As Double
  Dim endPoint(0 To 2)  As Double
  startPoint(0) = 0
  startPoint(1) = 0
  startPoint(2) = 0
  endPoint(0) = 1
  endPoint(1) = 1
  endPoint(2) = 1
  Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
  lineObj.Update

  ' Lengthen the line by changing the
  ' endpoint to 4, 4, 4
  endPoint(0) = 4
  endPoint(1) = 4
  endPoint(2) = 4
  lineObj.endPoint = endPoint
  lineObj.Update
End Sub


About Exploding Objects (VBA/ActiveX)

Exploding objects converts the objects from single objects to their constituent parts but has no visible effect.

For example, exploding forms simple lines and arcs from 3D polygons, polylines, polygon meshes, and regions. It replaces a block reference with copies of the simple objects that compose the block.

Explode a polyline

This example creates a lightweight polyline object. It then explodes the polyline into separate objects. The example then loops through the resulting objects and displays a message box containing the name of each object and its index in the list of exploded objects.

Sub Ch4_ExplodePolyline()
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 11) As Double

  ' Define the 2D polyline points
  points(0) = 1: points(1) = 1
  points(2) = 1: points(3) = 2
  points(4) = 2: points(5) = 2
  points(6) = 3: points(7) = 2
  points(8) = 4: points(9) = 4
  points(10) = 4: points(11) = 1

  ' Create a light weight Polyline object
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)

  ' Set the bulge on one segment to vary the
  ' type of objects in the polyline
  plineObj.SetBulge 3, -0.5
  plineObj.Update

  ' Explode the polyline
  Dim explodedObjects As Variant
  explodedObjects = plineObj.Explode

  ' Loop through the exploded objects
  ' and display a message box with
  ' the type of each object
  Dim I As Integer
  For I = 0 To UBound(explodedObjects)
    explodedObjects(I).Update
    MsgBox "Exploded Object " & I & ": " & explodedObjects(I).ObjectName
    explodedObjects(I).Update
  Next
End Sub


About Editing Polylines (VBA/ActiveX)

2D and 3D polylines, rectangles, polygons, and 3D polygon meshes are all polyline variants and are edited in the same way.

AutoCAD recognizes both fit polylines and spline-fit polylines. A spline-fit polyline uses a curve fit, similar to a B-spline. There are two kinds of spline-fit polylines: quadratic and cubic. Both polylines are controlled by the AutoCAD SPLINETYPE system variable. A fit polyline uses standard curves for curve fit and utilizes any tangent directions set on any given vertex.

To edit a polyline, use the properties and methods of the LightweightPolyline or Polyline object. Use the following properties and methods to open or close a polyline, change the coordinates of a polyline vertex, or add a vertex:

Closed property
Opens or closes the polyline.
Coordinates property
Specifies the coordinates for each vertex in the polyline.

Use the following methods to update the bulge or width of a polyline:

AddVertex
Adds a vertex to a lightweight polyline.
SetBulge
Sets the bulge of a polyline, given the segment index.
SetWidth
Sets the start and end width of a polyline, given the segment index.

Edit a polyline

This example creates a lightweight polyline. It then adds a bulge to the third segment of the polyline, appends a vertex to the polyline, changes the width of the last segment, and finally closes the polyline.

Sub Ch4_EditPolyline()
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 9) As Double

  ' Define the 2D polyline points
  points(0) = 1: points(1) = 1
  points(2) = 1: points(3) = 2
  points(4) = 2: points(5) = 2
  points(6) = 3: points(7) = 2
  points(8) = 4: points(9) = 4

  ' Create a light weight Polyline object
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)

  ' Add a bulge to segment 3
  plineObj.SetBulge 3, -0.5

  ' Define the new vertex
  Dim newVertex(0 To 1) As Double
  newVertex(0) = 4: newVertex(1) = 1

  ' Add the vertex to the polyline
  plineObj.AddVertex 5, newVertex

  ' Set the width of the new segment
  plineObj.SetWidth 4, 0.1, 0.5

  ' Close the polyline
  plineObj.Closed = True
  plineObj.Update
End Sub


About Editing Splines (VBA/ActiveX)

Existing spline objects can be edited using the object's properties and methods.

Use the following editable properties to change splines:

ControlPoints
Specifies the control points of a spline.
EndTangent
Specifies the end tangent of the spline as a directional vector.
FitPoints
Specifies all the fit points of a spline.
FitTolerance
Refits the spline to the existing points with new tolerance values.
Knots
Specifies the knots vector for the spline.
StartTangent
Specifies the start tangent for the spline.

In addition, you can use the following methods to edit splines:

AddFitPoint
Adds a single fit point to the spline at a given index.
DeleteFitPoint
Deletes the fit point of a spline at a given index.
ElevateOrder
Elevates the order of the spline to the given order.
GetFitPoint
Gets the fit point of the spline at a given index. (Gets one fit point only. To query all the fit points of the spline, use the FitPoints property.)
Reverse
Reverses the direction of a spline.
SetControlPoint
Sets the control point of the spline at a given index.
SetFitPoint
Sets the fit point of the spline at a given index. (Sets one fit point only. To change all the fit points of the spline, use the FitPoints property.)
SetWeight
Sets the weight of the control point at a given index.

Use the following read-only properties to query splines:

Area
Gets the enclosed area of a spline.
Closed
Indicates whether the spline is open or closed.
Degree
Gets the degree of the spline's polynomial representation.
IsPeriodic
Specifies if the given spline is periodic.
IsPlanar
Specifies if the given spline is planar.
IsRational
Specifies if the given spline is rational.
NumberOfControlPoints
Gets the number of control points of the spline.
NumberOfFitPoints
Gets the number of fit points of the spline.

Change a control point on a spline

This example creates a spline and then changes the first control point for the spline.

Sub Ch4_ChangeSplineControlPoint()
  ' Create the spline
  Dim splineObj As AcadSpline
  Dim startTan(0 To 2) As Double
  Dim endTan(0 To 2) As Double
  Dim fitPoints(0 To 8) As Double

  startTan(0) = 0.5: startTan(1) = 0.5: startTan(2) = 0
  endTan(0) = 0.5: endTan(1) = 0.5: endTan(2) = 0
  fitPoints(0) = 1: fitPoints(1) = 1: fitPoints(2) = 0
  fitPoints(3) = 5: fitPoints(4) = 5: fitPoints(5) = 0
  fitPoints(6) = 10: fitPoints(7) = 0: fitPoints(8) = 0
  Set splineObj = ThisDrawing.ModelSpace.AddSpline(fitPoints, startTan, endTan)
  splineObj.Update

  ' Change the coordinate of the first fit point
  Dim controlPoint(0 To 2) As Double
  controlPoint(0) = 0
  controlPoint(1) = 3
  controlPoint(2) = 0
  splineObj.SetControlPoint 0, controlPoint
  splineObj.Update
End Sub


About Editing Hatches (VBA/ActiveX)

You can edit both hatch boundaries and hatch patterns.

If you edit the boundary of an associative hatch, the pattern is updated as long as the editing results in a valid boundary. Associative hatches are updated even if they're on layers that are turned off. You can modify hatch patterns or choose a new pattern for an existing hatch, but associativity can only be set when a hatch is created. You can check to see if a Hatch object is associative by using the AssociativeHatch property. (See the AddHatch method for more information on creating a hatch.)

You must re-evaluate a hatch using the Evaluate method to see any edits to the hatch.

Topics in this section

  • About Editing Hatch Boundaries (VBA/ActiveX)

    You can append or insert loops into the hatch boundaries. Associative hatches are updated to match any changes made to their boundaries. Non-associative hatches are not updated.

  • About Editing Hatch Patterns (VBA/ActiveX)

    You can change the angle or spacing of an existing hatch pattern or replace it with a solid-fill or one of the predefined patterns that AutoCAD offers.


About Editing Hatch Boundaries (VBA/ActiveX)

You can append or insert loops into the hatch boundaries. Associative hatches are updated to match any changes made to their boundaries. Non-associative hatches are not updated.

To edit a hatch boundary, use one of the following methods:

AppendInnerLoop
Appends an inner loop to the hatch.
AppendOuterLoop
Appends an outer loop to the hatch.
InsertLoopAt
Inserts a loop at a given index of a hatch.

Append an inner loop to a hatch

This example creates an associative hatch. It then creates a circle and appends the circle as an inner loop to the hatch.

Sub Ch4_AppendInnerLoopToHatch()
  Dim hatchObj As AcadHatch
  Dim patternName As String
  Dim PatternType As Long
  Dim bAssociativity As Boolean

  ' Define and create the hatch
  patternName = "ANSI31"
  PatternType = 0
  bAssociativity = True
  Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)

  ' Create the outer loop for the hatch.
  Dim outerLoop(0 To 1) As AcadEntity
  Dim center(0 To 2) As Double
  Dim radius As Double
  Dim startAngle As Double
  Dim endAngle As Double
  center(0) = 5: center(1) = 3: center(2) = 0
  radius = 3
  startAngle = 0
  endAngle = 3.141592
  Set outerLoop(0) = ThisDrawing.ModelSpace.AddArc(center, radius, startAngle, endAngle)
  Set outerLoop(1) = ThisDrawing.ModelSpace.AddLine(outerLoop(0).startPoint, outerLoop(0).endPoint)

  ' Append the outer loop to the hatch object
  hatchObj.AppendOuterLoop (outerLoop)

  ' Create a circle as the inner loop for the hatch.
  Dim innerLoop(0) As AcadEntity
  center(0) = 5: center(1) = 4.5: center(2) = 0
  radius = 1
  Set innerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Append the circle as an inner loop to the hatch
  hatchObj.AppendInnerLoop (innerLoop)

  ' Evaluate and display the hatch
  hatchObj.Evaluate
  ThisDrawing.Regen True
End Sub


About Editing Hatch Patterns (VBA/ActiveX)

You can change the angle or spacing of an existing hatch pattern or replace it with a solid-fill or one of the predefined patterns that AutoCAD offers.

The Pattern option in the Boundary Hatch dialog box displays a list of these patterns. To reduce file size, the hatch is defined in the drawing as a single graphic object.

Use the following properties and methods to edit the hatch patterns:

PatternAngle
Specifies the angle of the hatch pattern.
PatternDouble
Specifies if the user-defined hatch is double-hatched.
PatternName
Specifies the hatch pattern name (does not change the pattern type).
PatternScale
Specifies the hatch pattern scale.
PatternSpace
Specifies the user-defined hatch pattern spacing.
SetPattern
Sets the pattern name and pattern type for the hatch.

Change the pattern spacing of a hatch

This example creates a hatch. It then adds two to the current pattern spacing for the hatch.

Sub Ch4_ChangeHatchPatternSpace()
  Dim hatchObj As AcadHatch
  Dim patternName As String
  Dim PatternType As Long
  Dim bAssociativity As Boolean

  ' Define the hatch
  patternName = "ANSI31"
  PatternType = 0
  bAssociativity = True

  ' Create the associative Hatch object
  Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)

  ' Create the outer loop for the hatch.
  Dim outerLoop(0 To 0) As AcadEntity
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 5
  center(1) = 3
  center(2) = 0
  radius = 3
  Set outerLoop(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)
  hatchObj.AppendOuterLoop (outerLoop)
  hatchObj.Evaluate

  ' Change the spacing of the hatch pattern by
  ' adding 2 to the current spacing
  hatchObj.patternSpace = hatchObj.patternSpace + 2
  hatchObj.Evaluate
  ThisDrawing.Regen True
End Sub


About Adding Text to Drawings (VBA/ActiveX)

Text conveys important information in your drawing. Use text for title blocks, to label parts of the drawing, to give specifications, or to make annotations.

AutoCAD provides various ways to create text. For short, simple entries, use line text. For longer entries with internal formatting, use multiline text (MText). Although all entered text uses the current text style, which establishes the default font and format settings, you can use several methods to customize the text appearance.

Topics in this section

  • About Working with Text Styles (VBA/ActiveX)

    All text in an AutoCAD drawing has a style associated with it.

  • About Creating Line Text (VBA/ActiveX)

    Each individual line of text is a distinct object when using line text.

  • About Creating Multiline Text (VBA/ActiveX)

    You can create a multiline text object (MText object) by using the AddMText method.

  • About Using Unicode Characters, Control Codes, and Special Characters (VBA/ActiveX)

    You can use Unicode characters, control codes, and special characters in your text string to represent symbols. (All nontext characters must be entered as their ASCII equivalent.)

  • About Substituting Fonts (VBA/ActiveX)

    You can designate fonts to be substituted for other fonts or as defaults when AutoCAD cannot find a font specified in a drawing.

  • About Checking Spelling (VBA/ActiveX)

    During a spelling check, AutoCAD matches the words in the drawing to the words in the current main dictionary.


About Working with Text Styles (VBA/ActiveX)

All text in an AutoCAD drawing has a style associated with it.

When you enter text, AutoCAD uses the current text style, which sets the font, size, angle, orientation, and other text characteristics. You can use or modify the default style or create and load a new style. Once you have created a style, you can modify its attributes or delete it when you no longer need it.

Topics in this section

  • About Creating and Modifying Text Styles (VBA/ActiveX)

    New text inherits height, width factor, obliquing angle, and text generation properties from the current text style.

  • About Assigning Fonts (VBA/ActiveX)

    Fonts define the shapes of the text characters that make up each character set.

  • About Using TrueType Fonts (VBA/ActiveX)

    TrueType fonts always appear filled in your drawing; however, when you plot, the AutoCAD TEXTFILL system variable controls whether the fonts are filled.

  • About Using Unicode and Big Fonts (VBA/ActiveX)

    AutoCAD supports the Unicode character-encoding standard. A Unicode font can contain 65,535 characters, with shapes for many languages. All AutoCAD SHX shape fonts are now Unicode fonts.

  • About Setting Text Height (VBA/ActiveX)

    Text height determines the size in drawing units of the letters in the font you are using.

  • About Setting Obliquing Angle (VBA/ActiveX)

    The obliquing angle determines the forward or backward slant of the text.

  • About Setting Text Generation Flag (VBA/ActiveX)

    The text generation flag specifies if the text is displayed backward or upside-down.


About Working with Text Styles (VBA/ActiveX)
About Working with Text Styles (VBA/ActiveX)
About Assigning Fonts (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Working with Text Styles (VBA/ActiveX) >

About Creating and Modifying Text Styles (VBA/ActiveX)

New text inherits height, width factor, obliquing angle, and text generation properties from the current text style.

To create a text style, use the Add method to create a new TextStyle object and add it to the TextStyles collection. The Add method takes a TextStyle name as input. Once created, you cannot change the name of a text style through AutoCAD ActiveX Automation.

Style names can contain letters, numbers, and the special characters dollar sign ($), underscore (_), and hyphen (-). AutoCAD converts the characters to uppercase. If you did not enter a style name, AutoCAD automatically names the style Stylen, where n is a number that starts at 1. Each new style is shown in increments of 1.

You can modify an existing style by changing the properties of the TextStyle object. You can also update existing text of that style type to reflect the changes. Use the following properties to modify a TextStyle object:

FontFile
Specifies the file associated with a font (character style).
BigFontFile
Specifies the special shape definition file used for a non-ASCII character set.
Height
Specifies the character height.
Width
Specifies the expansion or compression of the characters.
ObliqueAngle
Specifies the slant of the characters.
TextGenerationFlag
Specifies backward text, upside-down text, or both.

If you change an existing style's font or orientation, all text using that style is changed to use the new font or orientation. Changing text height, width factor, and oblique angle does not change existing text but does change subsequently created text objects.

NoteYou must call the Regen or Update method to see any changes to the above properties.


About Creating and Modifying Text Styles (VBA/ActiveX)
About Working with Text Styles (VBA/ActiveX)
About Using TrueType Fonts (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Working with Text Styles (VBA/ActiveX) >

About Assigning Fonts (VBA/ActiveX)

Fonts define the shapes of the text characters that make up each character set.

A single font can be used by more than one style. To assign a font to a text style, use the FontFile property of the TextStyle object. By entering the font file containing an AutoCAD-compiled SHX font, you assign that font to the text style.

Set text fonts

This example gets the current font values for the active text style and then changes the typeface for the font to “PlayBill.” The new font is then set using the SetFont method. To see the effects of changing the typeface, add some MText or Text to your current drawing before running the example. Note that, if you don't have the PlayBill font on your system, you need to substitute a font you do have in order for this example to work.

Sub Ch4_UpdateTextFont()

  MsgBox ("Look at the text now...")

  Dim typeFace As String
  Dim SavetypeFace As String
  Dim Bold As Boolean
  Dim Italic As Boolean
  Dim charSet As Long
  Dim PitchandFamily As Long

  ' Get the current settings to fill in the
  ' default values for the SetFont method
  ThisDrawing.ActiveTextStyle.GetFont typeFace, Bold, Italic, charSet, PitchandFamily

  ' Change the typeface for the font
  SavetypeFace = typeFace
  typeFace = "PlayBill"
  ThisDrawing.ActiveTextStyle.SetFont typeFace, Bold, Italic, charSet, PitchandFamily
  ThisDrawing.Regen acActiveViewport
  MsgBox ("Now see how it looks after changing the font...")

  'Restore the original typeface
  ThisDrawing.ActiveTextStyle.SetFont SavetypeFace, Bold, Italic, charSet, PitchandFamily
  ThisDrawing.Regen acActiveViewport
End Sub


About Assigning Fonts (VBA/ActiveX)
About Working with Text Styles (VBA/ActiveX)
About Using Unicode and Big Fonts (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Working with Text Styles (VBA/ActiveX) >

About Using TrueType Fonts (VBA/ActiveX)

TrueType fonts always appear filled in your drawing; however, when you plot, the AutoCAD TEXTFILL system variable controls whether the fonts are filled.

By default TEXTFILL is set to 1 to plot the filled-in fonts. When you export the drawing to PostScript® format with the Export method and print it on a PostScript device, the font is plotted as designed.


About Using TrueType Fonts (VBA/ActiveX)
About Working with Text Styles (VBA/ActiveX)
About Setting Text Height (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Working with Text Styles (VBA/ActiveX) >

About Using Unicode and Big Fonts (VBA/ActiveX)

AutoCAD supports the Unicode character-encoding standard. A Unicode font can contain 65,535 characters, with shapes for many languages. All AutoCAD SHX shape fonts are now Unicode fonts.

The text files for some alphabets contain thousands of non-ASCII characters. To accommodate such text, AutoCAD supports a special type of shape definition known as a Big Font file. You can set a style to use both regular and Big Font files. Specify normal fonts using the FontFile property. Specify Big Fonts using the BigFontFile property.

NoteFont file names cannot contain commas.

AutoCAD provides ways to substitute one font for another or to specify a default font.

Change font files

This example changes the FontFile and BigFontFile properties. You need to replace the path information listed in this example with path and file names appropriate for your system.

Sub Ch4_ChangeFontFiles()
    ThisDrawing.ActiveTextStyle.BigFontFile = "C:/AutoCAD/Fonts/bigfont.shx"
    ThisDrawing.ActiveTextStyle.FontFile = "C:/AutoCAD/Fonts/italic.shx"
End Sub


About Using Unicode and Big Fonts (VBA/ActiveX)
About Working with Text Styles (VBA/ActiveX)
About Setting Obliquing Angle (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Working with Text Styles (VBA/ActiveX) >

About Setting Text Height (VBA/ActiveX)

Text height determines the size in drawing units of the letters in the font you are using.

The value usually represents the size of the uppercase letters, with the exception of TrueType fonts.

For TrueType fonts, the value specified for text height might not represent the height of uppercase letters. The height specified represents the height of a capital letter plus an accent area reserved for accent marks and other marks used in non-English languages. The relative portion of areas assigned to capital letters and accent characters is determined by the font designer at the time the font is designed, and, consequently, will vary from font to font.

In addition to the height of a capital letter and the ascent area that make up the height specified by the user, TrueType fonts have a descent area for portions of characters that extend below the text insertion line. Examples of such characters are y, j, p, g, and q.

You specify the text height using the Height property. This property accepts positive numbers only.

Change the height of a Text object

This example creates a line of text and then changes the height of the text.

Sub Ch4_ChangeTextHeight()
  Dim textObj As AcadText
  Dim textString As String
  Dim insertionPoint(0 To 2) As Double
  Dim height As Double

  ' Define the text object
  textString = "Hello, World."
  insertionPoint(0) = 3
  insertionPoint(1) = 3
  insertionPoint(2) = 0
  height = 0.5

  ' Create the text object in model space
  Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)

  ' Change the value of the Height to 1
  textObj.height = 1
  textObj.Update
End Sub


About Setting Text Height (VBA/ActiveX)
About Working with Text Styles (VBA/ActiveX)
About Setting Text Generation Flag (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Working with Text Styles (VBA/ActiveX) >

About Setting Obliquing Angle (VBA/ActiveX)

The obliquing angle determines the forward or backward slant of the text.

The angle represents the offset from its vertical axis (90 degrees). To set the obliquing angle, use the ObliqueAngle property. The obliquing angle must be provided in radians. A positive angle denotes a lean to the right, a negative value will have 2*PI added to it to convert it to its positive equivalent.

Create oblique text

This example creates a Text object then slants the text 45 degrees.

Sub Ch4_ObliqueText()
  Dim textObj As AcadText
  Dim textString As String
  Dim insertionPoint(0 To 2) As Double
  Dim height As Double

  ' Define the text object
  textString = "Hello, World."
  insertionPoint(0) = 3
  insertionPoint(1) = 3
  insertionPoint(2) = 0
  height = 0.5

  ' Create the text object in model space
  Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)

  ' Change the value of the ObliqueAngle
  ' to 45 degrees (.707 radians)
  textObj.ObliqueAngle = 0.707
  textObj.Update
End Sub


About Setting Obliquing Angle (VBA/ActiveX)
About Working with Text Styles (VBA/ActiveX)
About Creating Line Text (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Working with Text Styles (VBA/ActiveX) >

About Setting Text Generation Flag (VBA/ActiveX)

The text generation flag specifies if the text is displayed backward or upside-down.

To set the text generation flag, use the TextGenerationFlag property. To display the text backward, enter acTextFlagBackward for this property. To display the text upside-down, enter acTextFlagUpsideDown for this property. To display the text both backward and upside-down, add the two constants together by entering acTextFlagBackward+acTextFlagUpsidedown for this property.

Display text backward

This example creates a line of text, then sets it to be displayed backward using the TextGenerationFlag property.

Sub Ch4_ChangingTextGenerationFlag()
  Dim textObj As AcadText
  Dim textString As String
  Dim insertionPoint(0 To 2) As Double
  Dim height As Double

  ' Create the text object
  textString = "Hello, World."
  insertionPoint(0) = 3
  insertionPoint(1) = 3
  insertionPoint(2) = 0
  height = 0.5
  Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)

  ' Change the value of the TextGenerationFlag
  textObj.TextGenerationFlag = acTextFlagBackward
  textObj.Update
End Sub


About Creating Line Text (VBA/ActiveX)

Each individual line of text is a distinct object when using line text.

To create a line text object, use the AddText method. This method requires three values as input: the text string, the insertion point, and the height of the text.

The text string is the actual text to be displayed. Unicode, control code, and special characters are accepted. The insertion point is a variant array containing three doubles representing the 3D WCS coordinate in the drawing to place the text. The height of the text is a positive number representing the height of the uppercase text. Height is measured in the current units.

To Create Line Text

This example creates a line of text in model space, at the coordinate (2, 2, 0).

Sub Ch4_CreateText()
  Dim textObj As AcadText
  Dim textString As String
  Dim insertionPoint(0 To 2) As Double
  Dim height As Double

  ' Create the text object
  textString = "Hello, World."
  insertionPoint(0) = 2
  insertionPoint(1) = 2
  insertionPoint(2) = 0
  height = 0.5
  Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)
  textObj.Update
End Sub

Topics in this section

  • About Formatting Line Text (VBA/ActiveX)

    You can change the formatting of the Text object by changing the text style associated with it, or by editing the properties of the Text object. You cannot apply formats to individual words and characters.

  • About Aligning Line Text (VBA/ActiveX)

    You can justify line text horizontally and vertically. Left alignment is the default. To set the horizontal and vertical alignment options, use the Alignment property.

  • About Changing Line Text (VBA/ActiveX)

    Like any other object, Text objects can be moved, rotated, erased, and copied.


About Formatting Line Text (VBA/ActiveX)

You can change the formatting of the Text object by changing the text style associated with it, or by editing the properties of the Text object. You cannot apply formats to individual words and characters.

To change a text style associated with an individual Text object, set the StyleName property to a new text style. Once you have changed the text style, use the Update method for the Text object to see the changes in your drawing.

In addition to the standard editable properties for entities (color, layer, linetype, and so forth), other properties that you can change on a Text object include the following:

Alignment
Specifies the horizontal and vertical alignment for the text.
InsertionPoint
Specifies the insertion point for the text.
ObliqueAngle
Specifies the oblique angle of the individual text object.
Rotation
Specifies the rotation angle in radians for the text.
ScaleFactor
Specifies the scale factor for the text.
TextAlignmentPoint
Specifies the alignment point for the text.
TextGenerationFlag
Specifies whether the text is displayed backward, upside-down, or both simultaneously.
TextString
Specifies the actual text string displayed.

Once you have changed a property, use the Update method to see the changes in your drawing.


About Aligning Line Text (VBA/ActiveX)

You can justify line text horizontally and vertically. Left alignment is the default. To set the horizontal and vertical alignment options, use the Alignment property.

Realign text

This example creates a Text object and a Point object. The Point object is set to the text alignment point, and is changed to a red crosshair so that it is visible. The text alignment is changed and a message box is displayed so that the macro execution is halted. This allows you to see the impact of changing the text alignment.

Sub Ch4_TextAlignment()
  Dim textObj As AcadText
  Dim textString As String
  Dim insertionPoint(0 To 2) As Double
  Dim height As Double

  ' Define the new Text object
  textString = "Hello, World."
  insertionPoint(0) = 3
  insertionPoint(1) = 3
  insertionPoint(2) = 0
  height = 0.5

  ' Create the Text object in model space
  Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)

  ' Create a point over the text alignment point,
  ' so we can better visualize the alignment process
  Dim pointObj As AcadPoint
  Dim alignmentPoint(0 To 2) As Double
  alignmentPoint(0) = 3
  alignmentPoint(1) = 3
  alignmentPoint(2) = 0
  Set pointObj = ThisDrawing.ModelSpace.AddPoint(alignmentPoint)
  pointObj.Color = acRed

  ' Set the point style to crosshair
  ThisDrawing.SetVariable "PDMODE", 2

  ' Align the text to the Left
  textObj.Alignment = acAlignmentLeft
  ThisDrawing.Regen acActiveViewport
  MsgBox "The Text object is now aligned left"

  ' Align the text to the Center
  textObj.Alignment = acAlignmentCenter

  ' Align the text to the point (necessary for
  ' all but left aligned text.)
  textObj.TextAlignmentPoint = alignmentPoint

  ThisDrawing.Regen acActiveViewport
  MsgBox "The Text object is now centered"

  ' Align the text to the Right
  textObj.Alignment = acAlignmentRight
  ThisDrawing.Regen acActiveViewport
  MsgBox "The Text object is now aligned right"
End Sub


About Changing Line Text (VBA/ActiveX)

Like any other object, Text objects can be moved, rotated, erased, and copied.

You also can mirror text. If you do not want the text to be reversed when you mirror it, you can set the AutoCAD MIRRTEXT system variable to 0.

The following list represents a few of the methods a Text object has for use in editing.

ArrayPolar
Creates a polar array.
ArrayRectangular
Creates a rectangular array.
Copy
Copies the Text object.
Delete
Erases the Text object.
Mirror
Mirrors the Text object.
Move
Moves the Text object.
Rotate
Rotates the Text object.


About Creating Multiline Text (VBA/ActiveX)

You can create a multiline text object (MText object) by using the AddMText method.

The AddMText method requires three values as input: the text string, the insertion point in the drawing to place the text, and the width of the text bounding box.

The text string is the actual text to be displayed. Unicode, control code, and special characters are accepted. The insertion point is a variant array containing three doubles representing the 3D WCS coordinate in the drawing to place the text. The width of the text is a positive number representing the width of the bounding box for the text. Width is measured in the current units.

After the MText object is created, you can apply the text height, justification, rotation angle, and style to the MText object, or apply character formatting to selected characters.

To Create Multiline Text

The following code creates an MText object in model space, at the coordinate (2, 2, 0).

Sub Ch4_CreateMText()
  Dim mtextObj As AcadMText
  Dim insertPoint(0 To 2) As Double
  Dim width As Double
  Dim textString As String

  insertPoint(0) = 2
  insertPoint(1) = 2
  insertPoint(2) = 0
  width = 4
  textString = "This is a text string for the mtext object."

  ' Create a text Object in model space
  Set mtextObj = ThisDrawing.ModelSpace.AddMText(insertPoint, width, textString)
  ZoomAll
End Sub

Topics in this section

  • About Formatting Multiline Text (VBA/ActiveX)

    New text automatically assumes the characteristics of the current text style. The STANDARD text style is the default.


About Creating Multiline Text (VBA/ActiveX)
About Creating Multiline Text (VBA/ActiveX)
About Using Unicode Characters, Control Codes, and Special Characters (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) > About Creating Multiline Text (VBA/ActiveX) >

About Formatting Multiline Text (VBA/ActiveX)

New text automatically assumes the characteristics of the current text style. The STANDARD text style is the default.

You can override the default text style by applying formatting to individual characters and applying properties to the Text object. You also can indicate formatting or special characters using the methods described in this section.

Orientation options such as style, justification, width, and rotation affect all text within the text boundary, not specific words or characters. Use the AttachmentPoint property to change the justification of the MText object, and the Rotation property to control the angle of rotation of the text boundary.

The StyleName property sets the default fonts and formatting characteristics for new text. As you create text, you can select which style you want to use from a list of existing styles. When you change the style of an MText object that has character formatting applied to any portion of the text, the style is applied to the entire object, and some formatting of characters might not be retained. For instance, changing from a TrueType style to a style using an SHX font or to another TrueType font causes the text to use the new font for the entire object, and any character formatting is lost.

Formatting options such as underlining, stacked text, or fonts can be applied to individual words or characters within a paragraph. You also can change color, font, and text height. You can change the spaces between text characters or increase the width of the characters.

Use curly braces ({ }) to apply a format change only to the text within the braces. You can nest braces up to eight levels deep.

You also can enter the ASCII equivalent for control codes within lines or paragraphs to indicate formatting or special characters, such as tolerance or dimensioning symbols.

The following control characters can be used to create the text in the illustration. (For the ASCII equivalent of this string see the example following the illustration.)

{{\H1.5x; Big text} \A2; over text\A1;/\A0; under text}

Use control characters to format text

This example creates and formats an MText object.

Sub Ch4_FormatMText()
  Dim mtextObj As AcadMText
  Dim insertPoint(0 To 2) As Double
  Dim width As Double
  Dim textString As String

  insertPoint(0) = 2
  insertPoint(1) = 2
  insertPoint(2) = 0
  width = 4

  ' Define the ASCII characters for the control characters
  Dim OB As Long  ' Open Bracket  {
  Dim CB As Long  ' Close Bracket }
  Dim BS As Long  ' Back Slash    \
  Dim FS As Long  ' Forward Slash /
  Dim SC As Long  ' Semicolon     ;
  OB = Asc("{")
  CB = Asc("}")
  BS = Asc("\")
  FS = Asc("/")
  SC = Asc(";")

  ' Assign the text string the following line of control
  ' characters and text characters:
  ' {{\H1.5x; Big text}\A2; over text\A1;/\A0; under text}

  textString = Chr(OB) + Chr(OB) + Chr(BS) + "H1.5x" _
  + Chr(SC) + "Big text" + Chr(CB) + Chr(BS) + "A2" _
  + Chr(SC) + "over text" + Chr(BS) + "A1" + Chr(SC) _
  + Chr(FS) + Chr(BS) + "A0" + Chr(SC) + "under text" _
  + Chr(CB)

  ' Create a text Object in model space
  Set mtextObj = ThisDrawing.ModelSpace.AddMText(insertPoint, width, textString)
  ZoomAll
End Sub


About Using Unicode Characters, Control Codes, and Special Characters (VBA/ActiveX)

You can use Unicode characters, control codes, and special characters in your text string to represent symbols. (All nontext characters must be entered as their ASCII equivalent.)

You can create special characters by entering the following Unicode character strings:

Unicode character descriptions
Unicode character | Description
\U+00B0 | Degree symbol
\U+00B1 | Plus/minus tolerance symbol
\U+2205 | Diameter dimensioning symbol

In addition to using Unicode characters for special characters, you can specify a special character by including control information in the text string. Use a pair of percent signs (%%) to introduce each control sequence. For example, the following control code works with standard AutoCAD text and PostScript fonts to draw character number nnn:

%%nnn

In a VBA text string, this example would be entered as

Dim percent as Long
percent = ASC("%")
TextString = chr(percent) + chr(percent) + "nnn"

These control codes work with standard AutoCAD text fonts only:

Control code descriptions
Control code | Description
%%o | Toggles overscore mode on and off
%%u | Toggles underscore mode on and off
%%d | Draws degree symbol
%%p | Draws plus and minus tolerance symbol
%%c | Draws diameter dimensioning symbol
%%% | Draws single percent sign


About Using Unicode Characters, Control Codes, and Special Characters (VBA/ActiveX)
About Adding Text to Drawings (VBA/ActiveX)
About Specifying an Alternative Default Font (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Adding Text to Drawings (VBA/ActiveX) >

About Substituting Fonts (VBA/ActiveX)

You can designate fonts to be substituted for other fonts or as defaults when AutoCAD cannot find a font specified in a drawing.

The fonts used for the text in your drawing are determined by the text style and, for MText, by individual font formats applied to sections of text.

You can use font mapping tables to ensure that your drawing uses only certain fonts, or to convert the fonts you used to other fonts. You can use these font mapping tables to enforce corporate font standards, or to facilitate offline printing. AutoCAD comes with a default font mapping table. You can edit this file using any ASCII text editor. You also can specify a different font mapping table file by using the FontFileMap property on the Preferences object.

Topics in this section

  • About Specifying an Alternative Default Font (VBA/ActiveX)

    If your drawing specifies a font that is not currently on your system, AutoCAD automatically substitutes the font designated as your alternate font.


About Specifying an Alternative Default Font (VBA/ActiveX)

If your drawing specifies a font that is not currently on your system, AutoCAD automatically substitutes the font designated as your alternate font.

By default, AutoCAD uses the simplex.shx file. However, you can specify a different font if necessary. Use the AltFontFile property on the Preferences object to set the alternative font file name.

If you use a text style that uses a Big Font, you can map it to another font using the AltFontFile property. This system variable uses a default font file pair of txt.shx, bigfont.shx.

If AutoCAD cannot find a font file when a drawing is opened, it applies a default set of font substitution rules.


About Checking Spelling (VBA/ActiveX)

During a spelling check, AutoCAD matches the words in the drawing to the words in the current main dictionary.

Any words you add are stored in the custom dictionary that is current at the time of the spelling check. For example, you can add proper names so that AutoCAD no longer identifies them as misspelled words.

To check spelling in another language, you can change to a different main dictionary.

There is no method for checking spelling provided in AutoCAD ActiveX Automation. However, you can specify a different main dictionary using the MainDictionary property, or a different custom dictionary using the CustomDictionary property on the Preferences object.


About Working with Layers (VBA/ActiveX)

You are always drawing on a layer. It may be the default layer or a layer you create and name yourself.

Each layer has an associated color and linetype. For example, you can create a layer on which you draw only centerlines and assign the color blue and the linetype CENTER to that layer. Then, whenever you want to draw centerlines you can switch to that layer and start drawing.

All layers and linetypes are kept within their parent Collection objects. Layers are kept within the Layers collection, and linetypes are kept within the Linetypes collection.

Topics in this section

  • About Sorting Layers and Linetypes (VBA/ActiveX)

    You can iterate through the Layers and Linetypes collections to find all the layers and linetypes in a drawing.

  • About Creating and Naming Layers (VBA/ActiveX)

    You can create new layers and assign color and linetype properties to those layers.

  • About Making a Layer Active (VBA/ActiveX)

    You are always drawing on the active layer.

  • About Turning Layers On and Off (VBA/ActiveX)

    Turned-off layers are regenerated with the drawing but are not displayed or plotted.

  • About Freezing and Thawing Layers (VBA/ActiveX)

    You can freeze layers to speed up display changes, improve object selection performance, and reduce regeneration time for complex drawings.

  • About Locking and Unlocking Layers (VBA/ActiveX)

    You cannot edit the objects on a locked layer; however, they are still visible if the layer is on and thawed.

  • About Assigning Color to a Layer (VBA/ActiveX)

    You can assign color to a layer. Colors are identified by the AcCmColor object. This object can hold an RGB value, an ACI number (an integer from 1 to 255), or a named color.

  • About Assigning a Linetype to a Layer (VBA/ActiveX)

    When you are defining layers, linetypes provide another way to convey visual information.

  • About Deleting Layers (VBA/ActiveX)

    You can delete a layer at any time during a drawing session.


About Sorting Layers and Linetypes (VBA/ActiveX)

You can iterate through the Layers and Linetypes collections to find all the layers and linetypes in a drawing.

Iterate through the Layers collection

The following code iterates through the Layers collection to gather the names of all the layers in the drawing. The names are then displayed in a message box.

Sub Ch4_IteratingLayers()
  Dim layerNames As String
  Dim entry As AcadLayer
  layerNames = ""
  For Each entry In ThisDrawing.Layers
    layerNames = layerNames + entry.Name + vbCrLf
  Next
  MsgBox "The layers in this drawing are: " + vbCrLf + layerNames
End Sub


About Creating and Naming Layers (VBA/ActiveX)

You can create new layers and assign color and linetype properties to those layers.

Each individual layer is part of the Layers collection. Use the Add method to create a new layer and add it to the Layers collection.

You can assign a name to a layer when it is created. To change the name of a layer after it has been created, use the Name property. Layer names can include up to thirty-one characters and contain letters, digits, and the special characters dollar sign ($), hyphen (-), and underscore (_) but cannot include blank spaces.

Create a new layer, assign it the color red, and add an object to the layer

The following code creates a circle and a new layer. The new layer is assigned the color red. The circle is assigned to the layer, and the color of the circle changes accordingly.

Sub Ch4_NewLayer()
  ' Create a circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2: center(1) = 2: center(2) = 0
  radius = 1
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Create a color object
  Dim col As New AcadAcCmColor
  col.ColorMethod = AutoCAD.acColorMethodForeground

  ' Set the layer to the color
  Dim layColor As AcadAcCmColor
  Set layColor = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.20")
  Call layColor.SetRGB(122, 199, 25)
  ThisDrawing.ActiveLayer.TrueColor = layColor
  col.ColorMethod = AutoCAD.acColorMethodByLayer

  ' Assign the circle the color "ByLayer" so
  ' that the circle will automatically pick
  ' up the color of the layer on which it resides
  circleObj.Color = acByLayer
  circleObj.Update
End Sub


About Making a Layer Active (VBA/ActiveX)

You are always drawing on the active layer.

When you make a layer active, you can create new objects on that layer. If you make a different layer active, any new objects you create are created on that new active layer and use its color and linetype. You cannot make a layer active if it is frozen.

To make a layer active, use the ActiveLayer property. This property is set on the current drawing. For example:

Dim newlayer As AcadLayer
Set newlayer = ThisDrawing.Layers.Add("LAYER1")
ThisDrawing.ActiveLayer = newlayer


About Turning Layers On and Off (VBA/ActiveX)

Turned-off layers are regenerated with the drawing but are not displayed or plotted.

By turning layers off, you avoid regenerating the drawing every time you thaw a layer. When you turn a layer on that has been turned off, AutoCAD redraws the objects on that layer.

To turn layers on and off, use the LayerOn property. If you input a value of TRUE to this property, the layer is turned on. If you input a value of FALSE, the layer is turned off.

Turn off a layer

This example creates a new layer, adds a circle to the layer, then turns off the layer so that the circle is no longer visible.

Sub Ch4_LayerInvisible()
  ' Create a circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2: center(1) = 2: center(2) = 0
  radius = 1
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Create a new layer called "ABC"
  Dim layerObj As AcadLayer
  Set layerObj = ThisDrawing.Layers.Add("ABC")

  ' Assign the circle to the "ABC" layer
  circleObj.Layer = "ABC"
  circleObj.Update

  ' Turn off layer "ABC"
  layerObj.LayerOn = False
  ThisDrawing.Regen acActiveViewport
End Sub


About Freezing and Thawing Layers (VBA/ActiveX)

You can freeze layers to speed up display changes, improve object selection performance, and reduce regeneration time for complex drawings.

AutoCAD does not display, plot, or regenerate objects on frozen layers. Freeze layers that you want to be invisible for long periods. When you “thaw” a frozen layer, AutoCAD regenerates and displays the objects on that layer.

To freeze or thaw a layer, use the Freeze property. If you input a value of TRUE to this property, the layer is frozen. If you input a value of FALSE, the layer is thawed.

Freeze a layer

This example creates a new layer called “ABC” and then freezes the layer.

Sub Ch4_LayerFreeze()
  ' Create a new layer called "ABC"
  Dim layerObj As AcadLayer
  Set layerObj = ThisDrawing.Layers.Add("ABC")

  ' Freeze layer "ABC"
  layerObj.Freeze = True
End Sub


About Locking and Unlocking Layers (VBA/ActiveX)

You cannot edit the objects on a locked layer; however, they are still visible if the layer is on and thawed.

You can make a locked layer current and you can add objects to it. You can freeze and turn off locked layers and change their associated colors and linetypes.

To lock or unlock a layer, use the Lock property. If you input a value of TRUE to this property, the layer is locked. If you input a value of FALSE, the layer is unlocked.

Lock a layer

This example creates a new layer called “ABC” and then locks the layer.

Sub Ch4_LayerLock()
  ' Create a new layer called "ABC"
  Dim layerObj As AcadLayer
  Set layerObj = ThisDrawing.Layers.Add("ABC")

  ' Lock layer "ABC"
  layerObj.Lock = True
End Sub


About Assigning Color to a Layer (VBA/ActiveX)

You can assign color to a layer. Colors are identified by the AcCmColor object. This object can hold an RGB value, an ACI number (an integer from 1 to 255), or a named color.

To assign color to a layer, use the TrueColor property.

Constants have been provided for the standard seven colors and the BYBLOCK and BYLAYER designations.

If you use acByBlock, AutoCAD draws new objects in the default color (white or black, depending on your configuration) until they are grouped into the block. When the block is inserted in the drawing, the objects in the block inherit the current setting.

If you use acByLayer, new objects assume the color of the layer upon which they are drawn.


About Assigning a Linetype to a Layer (VBA/ActiveX)

When you are defining layers, linetypes provide another way to convey visual information.

A linetype is a repeating pattern of dashes, dots, and blank spaces you can use to distinguish the purpose of one line from another.

The linetype name and definition describe the particular dash-dot sequence, the relative lengths of dashes and blank spaces, and the characteristics of any included text or shapes.

To assign a linetype to a layer, use the Linetype property. This property takes the name of the linetype as input.


About Deleting Layers (VBA/ActiveX)

You can delete a layer at any time during a drawing session.

You cannot delete the current layer, layer 0, an xref-dependent layer, or a layer that contains objects.

To delete a layer, use the Delete method.

NoteLayers referenced by block definitions, along with the special layer named DEFPOINTS, cannot be deleted even if they do not contain visible objects.


About Working with Colors (VBA/ActiveX)

You can assign true colors to individual objects in a drawing using the AcCmColor object.

Using an RGB value in the AcCmColor object, you can choose from millions of colors when you set the color of lines, circles, and other individual objects. The AcCmColor object also contains methods and properties for specifying color names, color books, color indexes, color values, and color methods.

You can also assign colors to layers. Each color can be identified by a name or an AutoCAD Color Index (ACI) number, an integer from 1 through 255. Any number of objects and layers can have the same color number. You can assign each color number to a different pen on a pen plotter or use the color numbers to identify certain objects in the drawing, even though you cannot see the colors on your screen.

When specifying a color, you can enter the name of the color or its ACI number. The ACI provides 255 color numbers. Standard color names are available only for colors 1 through 7.

Colors 1 through 7
Color number | Color name
1 | Red
2 | Yellow
3 | Green
4 | Cyan
5 | Blue
6 | Magenta
7 | Black/White

Colors 8 through 255 must be assigned by a number or by selecting the color in a dialog box. The default color (7) is either white or black, depending on your background color.


About Working with Linetypes (VBA/ActiveX)

A linetype is a repeating pattern of dashes, dots, and blank spaces.

A complex linetype is a repeating pattern of symbols. To use a linetype you must first load it into your drawing. A linetype definition must exist in a LIN library file before a linetype can be loaded into a drawing. To load a linetype into your drawing, use the Load method.

NoteThe linetypes used internally by AutoCAD should not be confused with the hardware linetypes provided by some plotters. The two types of dashed lines produce similar results. Do not use both types at the same time, however, because the results can be unpredictable.

Linetype Descriptions

Linetypes can have a description associated with them. The description provides an ASCII representation of the linetype. You can assign or change a linetype description by using the Description property.

A linetype description can have up to 47 characters. The description can be a comment or a series of underscores, dots, dashes, and spaces to show a simple representation of the linetype pattern. For example:

ThisDrawing.ActiveLinetype.Description = "Exterior Wall"

Load a linetype into AutoCAD

This example attempts to load the linetype “CENTER” from the acad.lin file. If the linetype already exists, or the file does not exist, then a message is displayed.

Sub Ch4_LoadLinetype()
  On Error GoTo ERRORHANDLER

  Dim linetypeName As String
  linetypeName = "CENTER"

  ' Load "CENTER" line type from acad.lin file
  ThisDrawing.Linetypes.Load linetypeName, "acad.lin"
  Exit Sub

ERRORHANDLER:
  MsgBox Err.Description
End Sub

Topics in this section

  • About Making a Linetype Active (VBA/ActiveX)

    To use a linetype to draw on the current layer, you must make it active. All newly created objects are drawn using the active linetype.

  • About Renaming Linetypes (VBA/ActiveX)

    To rename a linetype, use the Name property.

  • About Deleting Linetypes (VBA/ActiveX)

    To delete a linetype, use the Delete method.

  • About Specifying Linetype Scale (VBA/ActiveX)

    You can specify the linetype scale for objects you create.


About Making a Linetype Active (VBA/ActiveX)

To use a linetype to draw on the current layer, you must make it active. All newly created objects are drawn using the active linetype.

NoteXref-dependent linetypes cannot be made active.

To make a linetype active, use the ActiveLinetype property. This property is set on the current drawing. For example:

ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("CONTINUOUS")


About Renaming Linetypes (VBA/ActiveX)

To rename a linetype, use the Name property.

When you rename a linetype, you are renaming only the linetype definition in your drawing. The name in the LIN library file is not being updated to reflect the new name.


About Deleting Linetypes (VBA/ActiveX)

To delete a linetype, use the Delete method.

You can delete a linetype at any time during a drawing session; however, linetypes that cannot be deleted include BYLAYER, BYBLOCK, CONTINUOUS, the current linetype, and xref-dependent linetypes. Also, linetypes referenced by block definitions cannot be deleted, even if they are not used by any objects.


About Specifying Linetype Scale (VBA/ActiveX)

You can specify the linetype scale for objects you create.

The smaller the scale, the more repetitions of the pattern are generated per drawing unit. By default, AutoCAD uses a global linetype scale of 1.0, which is equal to one drawing unit. You can change the linetype scale for all drawing objects, attribute references, and groups.

To change the linetype scale, use the LinetypeScale property.

The AutoCAD CELTSCALE system variable sets the linetype scale for newly created objects. LTSCALE globally changes the linetype scale of existing objects as well as new objects. To change the values of system variables using AutoCAD ActiveX Automation, use the SetVariable method.

Change the linetype scale for a circle

Sub Ch4_ChangeLinetypeScale()
  ' Save the current linetype
  Set currLineType = ThisDrawing.ActiveLinetype

  ' Change the active linetype to Border, so the scale change will
  ' be visible.
  ' First see if the Border linetype is already loaded
  On Error Resume Next          'Turn on error trapping
  ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("BORDER")
  If Err.Number = -2145386476 Then
    ' Error indicates linetype is not currently loaded, so load it.
    ThisDrawing.Linetypes.Load "BORDER", "acad.lin"
    ThisDrawing.ActiveLinetype = _
          ThisDrawing.Linetypes.Item("BORDER")
  End If

  On Error GoTo 0               ' Turn off error trapping

  ' Create a circle object in model space
  Dim center(0 To 2) As Double
  Dim radius As Double
  Dim circleObj As AcadCircle
  center(0) = 2
  center(1) = 2
  center(2) = 0
  radius = 4
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
  circleObj.Update
  MsgBox ("Here is the circle with the original linetype")

  ' Set the linetype scale of a circle to 3
  circleObj.LinetypeScale = 3#
  circleObj.Update
  MsgBox ("Here is the circle with the new linetype")

  ' Restore original active linetype
  ThisDrawing.ActiveLinetype = currLineType
End Sub


About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX)

Once you have defined layers, colors, and linetypes, you can assign them to objects in your drawing.

You can group associated components of a drawing by assigning objects to layers. You can control layer visibility, color, and linetype and specify whether objects on a layer can be edited. You can move objects from one layer to another and change the name of a layer.

The number of layers in a drawing and the number of objects per layer are virtually unlimited. You can assign a name to each layer and select any combination of layers for display.

You can define blocks from objects that were originally drawn on different layers with different colors and linetypes. You can preserve the layer, color, and linetype information of objects in a block. Then, each time you insert the block, you have each object drawn on its original layer with its original color and linetype.

Topics in this section

  • About Changing an Object's Layer (VBA/ActiveX)

    Once you have created an object and assigned layer, color, and linetype properties to it, you may wish to change the object's layer.

  • About Changing an Object's Color (VBA/ActiveX)

    To change an object's color, use the TrueColor property provided for that object.

  • About Changing an Object's Linetype (VBA/ActiveX)

    By default, objects inherit the linetype of the layer on which they are created.


About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX)
About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX)
About Changing an Object's Color (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX) >

About Changing an Object's Layer (VBA/ActiveX)

Once you have created an object and assigned layer, color, and linetype properties to it, you may wish to change the object's layer.

Changing an object's layer is useful if you accidentally create an object on the wrong layer or decide to change your layer organization later.

To change an object's layer, use the Layer property provided for that object. The Layer property takes the name of the layer as input.

Move an object to a different layer

This example creates a circle on the active layer and then creates a new layer called “ABC”. It then moves the circle to the new layer.

Sub Ch4_MoveObjectNewLayer()
  ' Create a circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2: center(1) = 2: center(2) = 0
  radius = 1
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

  ' Create a new layer called "ABC"
  Dim layerObj As AcadLayer
  Set layerObj = ThisDrawing.Layers.Add("ABC")

  ' Assign the circle to the "ABC" layer
  circleObj.Layer = "ABC"
  circleObj.Update
End Sub


About Changing an Object's Layer (VBA/ActiveX)
About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX)
About Changing an Object's Linetype (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX) >

About Changing an Object's Color (VBA/ActiveX)

To change an object's color, use the TrueColor property provided for that object.

You can assign colors to individual objects in a drawing. Each color is identified by an AcCmColor object. This object can hold an RGB value, an ACI number (an integer from 1 to 255), or a named color. Using an RGB value, you can choose from millions of colors.

Setting a color for the object overrides the color setting for the layer on which the object resides. If you want to retain an object on a specific layer but you do not want it to keep the color of that layer, you can change the object's color.

Change the color of a circle

This example creates a circle and then colors the circle blue.

Sub Ch4_ColorCircle()
  Dim color As AcadAcCmColor
  Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.20")
  Call color.SetRGB(80, 100, 244)

  Dim circleObj As AcadCircle
  Dim centerPoint(0 To 2) As Double
  Dim radius As Double
  centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
  radius = 5#
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
  circleObj.TrueColor = color
  ZoomAll
End Sub


About Changing an Object's Color (VBA/ActiveX)
About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX)
About Saving and Restoring Layer Settings (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Assigning Layers, Colors, and Linetypes to Objects (VBA/ActiveX) >

About Changing an Object's Linetype (VBA/ActiveX)

By default, objects inherit the linetype of the layer on which they are created.

To change an object's linetype, use the Linetype property provided for that object. The Linetype property takes the name of the linetype to assign to the object as input.

NoteBefore you can assign a linetype to an object, the linetype must be loaded into the current drawing. To load a linetype into the drawing, use the Load method.

Change the linetype of a circle

This example creates a circle. It then attempts to load the linetype “CENTER” from the acad.lin file. If the linetype already exists, or the file does not exist, then a message is displayed. Finally, it sets the linetype for the circle to be “CENTER.”

Sub Ch4_ChangeCircleLinetype()
  On Error Resume Next

  ' Create a circle
  Dim circleObj As AcadCircle
  Dim center(0 To 2) As Double
  Dim radius As Double
  center(0) = 2: center(1) = 2: center(2) = 0
  radius = 1
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)

  Dim linetypeName As String
  linetypeName = "CENTER"

  ' Load "CENTER" line type from acad.lin file
  ThisDrawing.Linetypes.Load linetypeName, "acad.lin"
  If Err.Description <> "" Then MsgBox Err.Description

  ' Assign the circle the linetype "CENTER"
  circleObj.Linetype = "CENTER"
  circleObj.Update
End Sub


About Saving and Restoring Layer Settings (VBA/ActiveX)

You can save layer settings in a drawing and restore them later. This makes it easy to return to specified settings for all layers during different stages when completing a drawing or when plotting a drawing.

Layer settings include whether or not a layer is turned on, frozen, locked, plotted, and automatically frozen in new viewports, and the layer's color, linetype, lineweight, and plot style. You can specify which settings you want to save, and you can save different groups of settings for a drawing.

A special object, the LayerStateManager, provides functions for working with layer settings using ActiveX.

Topics in this section

  • About How AutoCAD Saves Layer Settings (VBA/ActiveX)

    AutoCAD saves layer setting information in an extension dictionary in a drawing's Layers collection.

  • About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX)

    The LayerStateManager object is similar to the AutoCAD Utility object in that it provides a set of functions for manipulating data.


About Saving and Restoring Layer Settings (VBA/ActiveX)
About Saving and Restoring Layer Settings (VBA/ActiveX)
About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Saving and Restoring Layer Settings (VBA/ActiveX) >

About How AutoCAD Saves Layer Settings (VBA/ActiveX)

AutoCAD saves layer setting information in an extension dictionary in a drawing's Layers collection.

When you first save layer settings in a drawing, AutoCAD does the following:

  • Creates an extension dictionary in the Layers collection.
  • Creates a Dictionary object named ACAD_LAYERSTATE in the extension dictionary.
  • Stores the properties of each layer in the drawing in an XRecord object in the ACAD_LAYERSTATE dictionary. AutoCAD stores all layer settings in the XRecord, but identifies the specific settings you chose to save. When you restore the layer settings, AutoCAD restores only the settings you chose to save.

Each time you save another layer setting in the drawing, AutoCAD creates another XRecord object describing the saved settings and stores the XRecord in the ACAD_LAYERSTATE dictionary. The following diagram illustrates the process.

You do not need (and should not try) to interpret XRecords when working with layer settings using ActiveX. Use the functions of the LayerStateManager object to access saved layer settings.

List the saved layer settings in a drawing

If layer settings have been saved in the current drawing, the following code lists the names of all saved layer settings:

Sub Ch4_ListStates()
  On Error Resume Next

  Dim oLSMDict As AcadDictionary
  Dim XRec As Object
  Dim layerstateNames As String
  layerstateNames = ""

  ' Get the ACAD_LAYERSTATES dictionary, which is in the
  ' extension dictionary in the Layers object.
  Set oLSMDict = ThisDrawing.Layers.GetExtensionDictionary.Item("ACAD_LAYERSTATES")

  ' List the name of each saved layer setting. Settings are
  ' stored as XRecords in the dictionary.
  For Each XRec In oLSMDict
   layerstateNames = layerstateNames + XRec.Name + vbCrLf
  Next XRec
  MsgBox "The saved layer settings in this drawing are: " + vbCrLf + layerstateNames
End Sub


About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX)

The LayerStateManager object is similar to the AutoCAD Utility object in that it provides a set of functions for manipulating data.

These functions are methods for working with saved layer settings. Use the following LayerStateManager methods to work with saved layer settings:

Delete
Deletes a saved layer setting.
Export
Exports the specified saved layer setting to a file.
Import
Imports a saved layer setting from the specified file.
Rename
Renames a saved layer setting.
Restore
Restores the specified layer setting in the current drawing.
Save
Saves the specified layer states and properties.
SetDataBase
Associates an AutoCAD database with the LayerStateManager.

To access the LayerStateManager object, use the GetInterfaceObject method.

Dim oLSM As AcadLayerStateManager
Set oLSM = ThisDrawing.Application. _
   GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")

After you retrieve the LayerStateManager object, you must associate a database with it before you can access the object's methods. Use the SetDatabase method to associate a database with the LayerStateManager.

oLSM.SetDatabase ThisDrawing.Database

Topics in this section

  • About Saving Layer Settings (VBA/ActiveX)

    Use the Save method to save a set of layer settings in a drawing.

  • About Restoring Layer Settings (VBA/ActiveX)

    The Restore method resets all layer settings in the current drawing to values that were saved earlier.

  • About Exporting and Importing Saved Layer Settings (VBA/ActiveX)

    You can export and import saved layer settings to use those settings in other drawings.


About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX)
About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX)
About Restoring Layer Settings (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Saving and Restoring Layer Settings (VBA/ActiveX) > About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX) >

About Saving Layer Settings (VBA/ActiveX)

Use the Save method to save a set of layer settings in a drawing.

The Save method accepts two parameters. The first parameter is a string naming the layer settings you are saving. The second parameter identifies the layer properties you want to save. Use the constants in the following table to identify layer properties.

Constants for layer properties
Constant name | Layer property
acLsAll | All layer settings
acLsColor | Color
acLsFrozen | Frozen or thawed
acLsLineType | Linetype
acLsLineWeight | Lineweight
acLsLocked | Locked or unlocked
acLsNewViewport | New viewport layers frozen or thawed
acLsNone | None
acLsOn | On or off
acLsPlot | Plotting on or off
acLsPlotStyle | Plot style

Add the constants together to specify multiple properties.

If you try to save layer settings under a name that already exists, an error is returned. You must rename or delete the existing saved layer settings before you can reuse the name.

Save a layer's color and linetype settings

The following code saves the color and linetype settings of the current layer under the name ColorLinetype.

Sub Ch4_SaveLayerColorAndLinetype()
  Dim oLSM As AcadLayerStateManager
  ' Access the LayerStateManager object
  Set oLSM = ThisDrawing.Application. _
    GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")

  ' Associate the current drawing database with LayerStateManager
  oLSM.SetDatabase ThisDrawing.Database
  oLSM.Save "ColorLinetype", acLsColor + acLsLineType
End Sub

Rename a saved layer setting

The following code renames the ColorLinetype layer settings to OldColorLinetype.

Sub Ch4_RenameLayerSettings()
  Dim oLSM As AcadLayerStateManager
  Set oLSM = ThisDrawing.Application. _
    GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")

  oLSM.SetDatabase ThisDrawing.Database
  oLSM.Rename "ColorLinetype", "OldColorLinetype"
End Sub

Delete a saved layer setting

The following code deletes layer settings that were saved under the name ColorLinetype.

Sub Ch4_DeleteColorAndLinetype()
  Dim oLSM As AcadLayerStateManager
  Set oLSM = ThisDrawing.Application. _
    GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")

  oLSM.SetDatabase ThisDrawing.Database
  oLSM.Delete "ColorLinetype"
End Sub


About Saving Layer Settings (VBA/ActiveX)
About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX)
About Exporting and Importing Saved Layer Settings (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Saving and Restoring Layer Settings (VBA/ActiveX) > About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX) >

About Restoring Layer Settings (VBA/ActiveX)

The Restore method resets all layer settings in the current drawing to values that were saved earlier.

For example, if you save the drawing's color and linetype settings under the name “ColorLinetype” and subsequently change those settings, restoring “ColorLinetype” resets the layers to the colors and linetypes they had when “ColorLinetype” was saved. If you add new layers to the drawing after saving “ColorLinetype,” those new layers are not affected when you restore “ColorLinetype.”

Restore the color and linetype settings of a drawing's layers

Assuming that the color and linetype settings of the layers in the current drawing were previously saved under the name “ColorLinetype,” the following code resets the color and linetype settings of each layer in the drawing to the value they had when “ColorLinetype” was saved.

Sub Ch4_RestoreLayerSettings()
  Dim oLSM As AcadLayerStateManager
  Set oLSM = ThisDrawing.Application. _
    GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")

  oLSM.SetDatabase ThisDrawing.Database
  oLSM.Restore "ColorLinetype"
End Sub


About Restoring Layer Settings (VBA/ActiveX)
About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX)
Dimensions and Tolerances
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Create and Edit AutoCAD Entities > About Saving and Restoring Layer Settings (VBA/ActiveX) > About Using the LayerStateManager to Manage Layer Settings (VBA/ActiveX) >

About Exporting and Importing Saved Layer Settings (VBA/ActiveX)

You can export and import saved layer settings to use those settings in other drawings.

Use the LayerStateManager's Export method to save layer settings to a file; use the Import method to import saved layer settings into a drawing.

NoteImporting layer settings does not restore them; you must use the Restore method to set the layers in your drawing to the imported settings.

The Export method accepts two parameters. The first parameter is a string identifying the saved layer settings you are exporting. The second parameter is the name of the file you are exporting the settings to. If you do not specify a path for the file, it is saved in the AutoCAD installation directory. If the file name you specified already exists, the existing file is overwritten. Use a .las extension when naming files; this is the extension AutoCAD recognizes for exported layer setting files.

The Import method accepts one parameter: a string naming the file that contains the layer settings you are importing.

When you are importing layer settings, an error condition is raised if any properties referenced in the saved settings are not available in the drawing you're importing to. The import is completed, however, and default properties are used. For example, if an exported layer is set to a linetype that is not loaded in the drawing it is being imported into, an error condition is raised and the drawing's default linetype is substituted. Your code should account for this error condition and continue processing if it is raised.

If the imported file defines settings for layers that do not exist in the current drawing, those layers are created in the current drawing. When you use the Restore method, the properties specified when the settings were saved are assigned to the new layers; all other properties of the new layers are assigned default settings.

Export saved layer settings

The following code exports saved layer settings to a file named Colortype.las.

Sub Ch4_ExportLayerSettings()
  Dim oLSM As AcadLayerStateManager
  Set oLSM = ThisDrawing.Application. _
    GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")

  oLSM.SetDatabase ThisDrawing.Database
  oLSM.Export "ColorLinetype", "c:\my documents\ColorLType.las"
End Sub

Import saved layer settings

The following code imports layer settings from a file named Colortype.las.

Sub Ch4_ImportLayerSettings()
  Dim oLSM As AcadLayerStateManager
  Set oLSM = ThisDrawing.Application. _
    GetInterfaceObject("AutoCAD.AcadLayerStateManager.20")
  oLSM.SetDatabase ThisDrawing.Database

  ' If the drawing you're importing to does not contain
  ' all the linetypes referenced in the saved settings,
  ' an error is returned. The import is completed, though,
  ' and the default linetype is used.
  On Error Resume Next
  oLSM.Import "c:\my documents\ColorLType.las"
  If Err.Number = -2145386359 Then
     ' Error indicates a linetype is not defined
     MsgBox ("One or more linetypes specified in the imported " + _
 "settings is not defined in your drawing")
  End If

  On Error GoTo 0
End Sub


Dimensions and Tolerances

Topics in this section

  • About Dimensioning Concepts

    Dimensions show the geometric measurements of objects, the distances or angles between objects, or the X and Y coordinates of a feature.

  • About Creating Dimensions

    You can create linear, radial, angular, and ordinate dimensions.

  • About Editing Dimensions

    As with other graphical objects in AutoCAD, you can edit dimensions using the standard methods and properties provided for the object.

  • About Working with Dimension Styles

    A named dimension style is a group of settings that determines the appearance of the dimension. Using named dimension styles, you can establish and enforce drafting standards for drawings.

  • About Dimensioning in Model Space and Paper Space

    You can draw dimensions in both paper space and model space.

  • About Creating Leaders and Annotation

    A leader is a line that connects some annotation to a feature in a drawing.

  • About Using Geometric Tolerances

    Geometric tolerancing shows deviations of form, profile, orientation, location, and runout of a feature.


About Dimensioning Concepts (VBA/ActiveX)

Dimensions show the geometric measurements of objects, the distances or angles between objects, or the X and Y coordinates of a feature.

AutoCAD provides three basic types of dimensioning:

  • linear
  • radial
  • angular

Linear dimensions include aligned, rotated, and ordinate dimensions.

You can create dimensions for lines, multilines, arcs, circles, and polyline segments, or you can create dimensions that stand alone.

AutoCAD draws dimensions on the current layer. Every dimension has a dimension style associated with it, whether it's the default or one you define. The style controls characteristics such as color, text style, and linetype scale. Thickness information is not supported. Style families allow for subtle modifications to a base style for different types of dimensions. Overrides allow for style modifications to a specific dimension.

Topics in this section

  • About the Parts of a Dimension (VBA/ActiveX)

    This topic briefly defines the parts of a dimension.

  • About Defining the Dimension System Variables (VBA/ActiveX)

    The dimensioning system variables control the appearance of dimensions.

  • About Setting Dimension Text Styles (VBA/ActiveX)

    Dimension text refers to any kind of text associated with dimensions, including measurements, tolerances (both lateral and geometric), prefixes, suffixes, and textual notes in single-line or paragraph form.

  • About Leader Lines (VBA/ActiveX)

    A default leader line is a straight line with an arrowhead that refers to a feature in a drawing.

  • About Associative Dimensions (VBA/ActiveX)

    Associative dimensions automatically adjust their locations, orientations, and measurement values when the geometric objects associated with them are modified.


About the Parts of a Dimension (VBA/ActiveX)

This topic briefly defines the parts of a dimension.

A dimension line is a line that indicates the direction and extent of a dimension. For an angular dimension, the dimension line is an arc. Extension lines, also called projection lines or witness lines, extend from the feature being dimensioned to the dimension line. Arrowheads, also called symbols of termination or just termination, are added to each end of the dimension line. Dimension text is a text string that usually indicates the actual measurement. The text may also include prefixes, suffixes, and tolerances. A leader is a solid line leading from some annotation to the referenced feature. A center mark is a small cross that marks the center of a circle or arc. Centerlines are broken lines that mark the center of a circle or arc.


About Defining the Dimension System Variables (VBA/ActiveX)

The dimensioning system variables control the appearance of dimensions.

The dimension system variables include DIMAUNIT, DIMUPT, DIMTOFL, DIMFIT, DIMTIH, DIMTOH, DIMJUST, and DIMTAD. You can set these variables by using the SetVariable method. For example, the following line of code sets the DIMAUNIT system variable (the units format for angular dimensions) to radians (3):

ThisDrawing.SetVariable "DIMAUNIT", 3


About Setting Dimension Text Styles (VBA/ActiveX)

Dimension text refers to any kind of text associated with dimensions, including measurements, tolerances (both lateral and geometric), prefixes, suffixes, and textual notes in single-line or paragraph form.

You can use the default measurement computed by AutoCAD as the text, supply your own text, or suppress the text entirely. You can use dimension text to add information, such as special manufacturing procedures or assembly instructions.

Single-line dimension text uses the active text style as specified by the ActiveTextStyle property. Paragraphs of text use the active text style with any modifications you make in your text string.


About Leader Lines (VBA/ActiveX)

A default leader line is a straight line with an arrowhead that refers to a feature in a drawing.

Usually, a leader's function is to connect annotation with the feature. Annotation in this case means paragraph text, blocks, or feature control frames. Such leader lines are different from the simple leader lines AutoCAD creates automatically for radial, diameter, and linear dimensions whose text will not fit between extension lines.

Leader objects are associated with the annotation, so when the annotation is edited, the leader is updated accordingly. You can copy annotation used elsewhere in a drawing and append it to a leader, or you can create a new annotation. You can also create a leader with no annotation appended.


About Associative Dimensions (VBA/ActiveX)

Associative dimensions automatically adjust their locations, orientations, and measurement values when the geometric objects associated with them are modified.

The DIMASSOC system variable controls associative dimensioning. Set DIMASSOC to 2 to turn on associative dimensioning.


About Creating Dimensions (VBA/ActiveX)

You can create linear, radial, angular, and ordinate dimensions.

When creating dimensions, the active dimension style is used. Once created, you can modify the extension line origins, the dimension text location, and the dimension text content and its angle relative to the dimension line. You can also change the dimension style used by the dimension.

Topics in this section

  • About Creating Linear Dimensions (VBA/ActiveX)

    Linear dimensions allow you to label the distance between two points.

  • About Creating Radial Dimensions (VBA/ActiveX)

    Radial dimensions measure the radii and diameters of arcs and circles. To create a radial dimension, use the AddDimRadial method.

  • About Creating Angular Dimensions (VBA/ActiveX)

    Angular dimensions measure the angle between two lines or three points.

  • About Creating Ordinate Dimensions (VBA/ActiveX)

    Ordinate, or datum, dimensions measure the perpendicular distance from an origin point, called the datum, to a dimensioned feature, such as a hole in a part.


About Creating Linear Dimensions (VBA/ActiveX)

Linear dimensions allow you to label the distance between two points.

Linear dimensions can be aligned or rotated. Aligned dimensions have the dimension line parallel to the line along which the extension line origins lie. Rotated dimensions have the dimension line placed at an angle to the extension line origins.

To create a linear dimension, use the AddDimAligned or AddDimRotated method. After you create linear dimensions, you can modify the text, the angle of the text, or the angle of the dimension line. In the following illustrations, the extension line origins are designated explicitly. The resulting dimension line location is also shown:

To create an aligned dimension, use the AddDimAligned method. This method requires three coordinates as input: the origin of both extension lines and the text position.

To create a rotated dimension, use the AddDimRotated method. This method requires three coordinates and the angle of the dimension line as input. The three coordinates are the origin of both extension lines and the text position. The angle must be provided in radians and represents the angle of rotation for the dimension line.


About Creating Radial Dimensions (VBA/ActiveX)

Radial dimensions measure the radii and diameters of arcs and circles. To create a radial dimension, use the AddDimRadial method.

Different types of radial dimensions are created depending on the size of the circle or arc, the TextPosition property, and the values in the DIMUPT, DIMTOFL, DIMFIT, DIMTIH, DIMTOH, DIMJUST, and DIMTAD dimension system variables. (System variables can be queried or set using the GetVariable and SetVariable methods.)

For horizontal dimension text, if the angle of the dimension line is more than 15 degrees from horizontal, and is outside the circle or arc, AutoCAD draws a hook line, also called a landing or dogleg. The hook line is one arrowhead long, and is placed next to the dimension text, as shown in the following illustrations:

To create radial dimensions, use the AddDimRadial or AddDimDiametric method. These methods require three values as input: the coordinate of the circle or arc's center, the coordinate for the leader attachment, and the length of the leader.

These methods use the LeaderLength parameter as the distance from the ChordPoint to the point where the dimension will do a horizontal hook line to the annotation text (or stop if no hook line is necessary).

Create a radial dimension

This example creates a radial dimension in model space.

Sub Ch5_CreateRadialDimension()
    Dim dimObj As AcadDimRadial
    Dim center(0 To 2) As Double
    Dim chordPoint(0 To 2) As Double
    Dim leaderLen As Integer

    ' Define the dimension
    center(0) = 0
    center(1) = 0
    center(2) = 0
    chordPoint(0) = 5
    chordPoint(1) = 5
    chordPoint(2) = 0
    leaderLen = 5

    ' Create the radial dimension in model space
    Set dimObj = ThisDrawing.ModelSpace. _
 AddDimRadial(center, chordPoint, leaderLen)
    ZoomAll
End Sub
NoteThe LeaderLength setting is only used during the creation of the dimension (and even then only if the dimension is set to use the default text position value). After the dimension is closed for the first time, changing the LeaderLength value will not affect how the dimension is displayed, but the new setting will be stored and will show up in DXF, LISP, and ARX applications.


About Creating Angular Dimensions (VBA/ActiveX)

Angular dimensions measure the angle between two lines or three points.

For example, you can use them to measure the angle between two radii of a circle. The dimension line forms an arc.

To create an angular dimension, use the AddDimAngular method. This method requires three values as input: the angle vertex, the origins of the extension lines, and the text location. The AngleVertex is the center of the circle or arc, or the common vertex between the two lines being dimensioned. The origins of the extension lines are the points through which the two extension lines pass.

The AngleVertex can be the same as one of the origin points. If you need extension lines they will be added automatically.

Create an angular dimension

This example creates an angular dimension in model space.

Sub Ch5_CreateAngularDimension()
    Dim dimObj As AcadDimAngular
    Dim angVert(0 To 2) As Double
    Dim FirstPoint(0 To 2) As Double
    Dim SecondPoint(0 To 2) As Double
    Dim TextPoint(0 To 2) As Double

    ' Define the dimension
    angVert(0) = 0
    angVert(1) = 5
    angVert(2) = 0
    FirstPoint(0) = 1
    FirstPoint(1) = 7
    FirstPoint(2) = 0
    SecondPoint(0) = 1
    SecondPoint(1) = 3
    SecondPoint(2) = 0
    TextPoint(0) = 3
    TextPoint(1) = 5
    TextPoint(2) = 0

    ' Create the angular dimension in model space
    Set dimObj = ThisDrawing.ModelSpace. _
     AddDimAngular(angVert, FirstPoint, SecondPoint, TextPoint)
    ZoomAll
End Sub


About Creating Ordinate Dimensions (VBA/ActiveX)

Ordinate, or datum, dimensions measure the perpendicular distance from an origin point, called the datum, to a dimensioned feature, such as a hole in a part.

These dimensions prevent escalating errors by maintaining accurate offsets of the features from the datum.

Ordinate dimensions consist of an X or Y ordinate with a leader line. X-datum ordinate dimensions measure the distance of a feature from the datum along the X axis. Y-datum ordinate dimensions measure the same distance along the Y axis. AutoCAD uses the origin of the current user coordinate system (UCS) to determine the measured coordinates. The absolute value of the coordinate is used.

The text is aligned with the ordinate leader line regardless of the text orientation defined by the current dimension style. You can accept the default text or supply your own.

To create an ordinate dimension, use the AddDimOrdinate method. This method requires three values as input: a coordinate specifying the point to be dimensioned (A), a coordinate specifying the end of the leader (B), and a Boolean flag specifying whether the dimension is an X-datum ordinate dimension or a Y-datum ordinate dimension. If you enter TRUE for the Boolean flag, the method will create an X-datum ordinate dimension. If you enter FALSE, it will create a Y-datum ordinate dimension.

Create an ordinate dimension

This example creates an ordinate dimension in model space.

Sub Ch5_CreatingOrdinateDimension()
    Dim dimObj As AcadDimOrdinate
    Dim definingPoint(0 To 2) As Double
    Dim leaderEndPoint(0 To 2) As Double
    Dim useXAxis As Long

    ' Define the dimension
    definingPoint(0) = 5
    definingPoint(1) = 5
    definingPoint(2) = 0
    leaderEndPoint(0) = 10
    leaderEndPoint(1) = 5
    leaderEndPoint(2) = 0
    useXAxis = 5

    ' Create an ordinate dimension in model space
    Set dimObj = ThisDrawing.ModelSpace. _
 AddDimOrdinate(definingPoint, _
 leaderEndPoint, useXAxis)
    ZoomAll
End Sub


About Editing Dimensions (VBA/ActiveX)

As with other graphical objects in AutoCAD, you can edit dimensions using the standard methods and properties provided for the object.

The following properties are available for most dimension objects:

Rotation
Specifies the rotation angle in radians for the dimension line.
StyleName
Specifies the name of the dimension style.
TextOverride
Specifies the text string for the dimension.
TextPosition
Specifies the dimension text position.
TextRotation
Specifies the rotation angle of the dimension text.
Measurement
Specifies the actual measurement for the dimension.

In addition, certain dimension objects provide properties for editing the extension line origins and leader length.

The following methods are included for dimension object editing:

ArrayPolar
Creates a polar array.
ArrayRectangular
Creates a rectangular array.
Copy
Copies the dimension object.
Delete
Erases the dimension object.
Mirror
Mirrors the dimension object.
Move
Moves the dimension object.
Rotate
Rotates the dimension object.
ScaleEntity
Scales the dimension object.

Topics in this section

  • About Overriding Dimension Text (VBA/ActiveX)

    The dimension value that is displayed can be replaced using the TextOverride property. Using this property you can completely replace the displayed value of the dimension, or you can append text to the value.


About Overriding Dimension Text (VBA/ActiveX)

The dimension value that is displayed can be replaced using the TextOverride property. Using this property you can completely replace the displayed value of the dimension, or you can append text to the value.

Modify dimension text

This example appends some text to the value so that both the string and the dimension value are displayed.

Sub Ch5_OverrideDimensionText()
    Dim dimObj As AcadDimAligned
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    Dim location(0 To 2) As Double

    ' Define the dimension
    point1(0) = 5#: point1(1) = 3#: point1(2) = 0#
    point2(0) = 10#: point2(1) = 3#: point2(2) = 0#
    location(0) = 7.5: location(1) = 5#: location(2) = 0#

    ' Create an aligned dimension object in model space
    Set dimObj = ThisDrawing.ModelSpace. _
 AddDimAligned(point1, point2, location)

    ' Change the text string for the dimension
    dimObj.TextOverride = "The value is <>"
    dimObj.Update
End Sub


About Working with Dimension Styles (VBA/ActiveX)

A named dimension style is a group of settings that determines the appearance of the dimension. Using named dimension styles, you can establish and enforce drafting standards for drawings.

All dimensions are created using the active dimension style. If you do not define or apply a style before creating dimensions, AutoCAD applies the default style, STANDARD. To set the active dimension style, use the ActiveDimStyle property.

To set up a parent dimension style, you begin by naming and saving a style. The new style is based on the current style and includes all subsequent changes to the layout of the dimension parts, the positioning of text, and the appearance of annotation. Annotation in this case means primary and alternate units, tolerances, and text.

Topics in this section

  • About Creating, Modifying, and Copying Dimension Styles (VBA/ActiveX)

    You can create and modify dimension styles in a drawing by working with the DimStyles collection.

  • About Overriding the Dimension Style (VBA/ActiveX)

    Each dimension has the capability of overriding settings in the dimension style for that dimension.


About Creating, Modifying, and Copying Dimension Styles (VBA/ActiveX)

You can create and modify dimension styles in a drawing by working with the DimStyles collection.

To create a new dimension style, use the Add method. This method requires as input the name of the new dimension style.

AutoCAD ActiveX Automation allows you to add new dimension styles, and to change the active dimension style. You can also change the dimension style associated with a given dimension through the StyleName property.

You can also copy an existing style or set of overrides. Use the CopyFrom method to copy a dimension style from a source object to a new dimension style. The source object can be another DimStyle object, a dimension, Tolerance, or Leader object, or even a Document object. If you copy the style settings from another dimension style, the style is duplicated exactly. If you copy the style settings from a dimension, Tolerance, or Leader object, the current settings, including any object overrides, are copied to the new style. If you copy the style of a Document object, the active dimension style, plus any drawing overrides, is copied to the new style.

Copy dimension styles and overrides

This example creates three new dimension styles and copies the current settings for the document, a given dimension style, and a given dimension to each new dimension style respectively. By following the appropriate setup before running this example, you will find that different dimension styles have been created.

  1. Create a new drawing and make it the active drawing.
  2. Create a linear dimension in the new drawing. This dimension should be the only object in the drawing.
  3. Change the color of the dimension line to yellow.
  4. Change the DIMCLRD system variable to 5 (blue).
  5. Run the following example:
    Sub Ch5_CopyDimStyles()
    Dim newStyle1 As AcadDimStyle
    Dim newStyle2 As AcadDimStyle
    Dim newStyle3 As AcadDimStyle

    Set newStyle1 = ThisDrawing.DimStyles.Add _
 ("Style 1 copied from a dim")
    Call newStyle1.CopyFrom(ThisDrawing.ModelSpace(0))

    Set newStyle2 = ThisDrawing.DimStyles.Add _
 ("Style 2 copied from Style 1")
    Call newStyle2.CopyFrom(ThisDrawing.DimStyles.Item _
 ("Style 1 copied from a dim"))

    Set newStyle2 = ThisDrawing.DimStyles.Add _
 ("Style 3 copied from the running drawing values")
    Call newStyle2.CopyFrom(ThisDrawing)
End Sub

    Open the DIMSTYLE dialog box. You should now have three dimension styles listed. Style 1 should have a yellow dimension line. Style 2 should be the same as Style 1. Style 3 should have a blue dimension line.


About Creating, Modifying, and Copying Dimension Styles (VBA/ActiveX)
About Working with Dimension Styles (VBA/ActiveX)
About Dimensioning in Model Space and Paper Space (VBA/activeX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Dimensions and Tolerances > About Working with Dimension Styles (VBA/ActiveX) >

About Overriding the Dimension Style (VBA/ActiveX)

Each dimension has the capability of overriding settings in the dimension style for that dimension.

The following properties are available for most dimension objects:

AltRoundDistance
Specifies the rounding of alternate units.
AngleFormat
Specifies the unit format for angular dimensions.
Arrowhead1Block, Arrowhead2Block
Specifies the block to use as the custom arrowhead for the dimension line.
Arrowhead1Type, Arrowhead2Type
Specifies the type of arrowhead for the dimension line.
ArrowheadSize
Specifies the size of dimension line arrowheads, leader line arrowheads, and hook lines.
CenterMarkSize
Specifies the size of the center mark for radial and diameter dimensions.
CenterType
Specifies the type of center mark for radial and diameter dimensions.
DecimalSeparator
Specifies the character to be used as the decimal separator in decimal dimension and tolerance values.
DimensionLineColor
Specifies the color of the dimension line for a dimension, leader, or tolerance object.
DimensionLineWeight
Specifies the lineweight for the dimension lines.
DimLine1Suppress, DimLine2Suppress
Specifies the suppression of the dimension lines.
DimLineInside
Specifies the display of dimension lines inside the extension lines only.
ExtensionLineColor
Specifies the color for dimension extension lines.
ExtensionLineExtend
Specifies the distance the extension line extends beyond the dimension line.
ExtensionLineOffset
Specifies the distance the extension lines are offset from the origin points.
ExtensionLineWeight
Specifies the lineweight for the extension lines.
ExtLine1EndPoint, ExtLine2EndPoint
Specifies the endpoint of extension lines.
ExtLine1StartPoint, ExtLine2StartPoint
Specifies the start point of extension lines.
ExtLine1Suppress, ExtLine2Suppress
Specifies the suppression of extension lines.
Fit
Specifies the placement of text and arrowheads inside or outside extension lines.
ForceLineInside
Specifies if a dimension line is drawn between the extension lines even when the text is placed outside the extension lines.
FractionFormat
Specifies the format of fractional values in dimensions and tolerances.
HorizontalTextPosition
Specifies the horizontal justification for dimension text.
LinearScaleFactor
Specifies a global scale factor for linear dimensioning measurements.
PrimaryUnitsPrecision
Specifies the number of decimal places displayed for the primary units of a dimension or tolerance.
SuppressLeadingZeros, SuppressTrailingZeros
Specifies the suppression of leading and trailing zeros in dimension values.
SuppressZeroFeet, SuppressZeroInches
Specifies the suppression of a zero foot and zero inch measurement in dimension values.
TextColor
Specifies the color of the text for dimension and tolerance objects.
TextGap
Specifies the distance between the dimension text and the dimension line when you break the dimension line to accommodate dimension text.
TextHeight
Specifies the height for the dimension or tolerance text.
TextInside
Specifies if the dimension text is to be drawn inside the extension lines.
TextInsideAlign
Specifies the position of dimension text inside the extension lines for all dimension types except ordinate.
TextMovement
Specifies how dimension text is drawn when text is moved.
TextOutsideAlign
Specifies the position of dimension text outside the extension lines for all dimension types except ordinate.
TextPosition
Specifies the dimension text position.
TextPrecision
Specifies the precision of angular dimension text.
TextPrefix
Specifies the dimension value prefix.
TextRotation
Specifies the rotation angle of the dimension text.
TextSuffix
Specifies the dimension value suffix.
ToleranceDisplay
Specifies if tolerances are displayed with the dimension text.
ToleranceHeightScale
Specifies a scale factor for the text height of tolerance values relative to the dimension text height.
ToleranceJustification
Specifies the vertical justification of tolerance values relative to the nominal dimension text.
ToleranceLowerLimit
Specifies the minimum tolerance limit for dimension text.
TolerancePrecision
Specifies the precision of tolerance values in primary dimensions.
ToleranceSuppressLeadingZeros
Specifies the suppression of leading zeros in tolerance values.
ToleranceSuppressTrailingZeros
Specifies the suppression of trailing zeros in dimension values.
ToleranceUpperLimit
Specifies the maximum tolerance limit for dimension text.
UnitsFormat
Specifies the unit format for all dimensions except angular.
VerticalTextPosition
Specifies the vertical position of text in relation to the dimension line.

Enter a user-defined suffix for an aligned dimension

This example creates an aligned dimension in model space and uses the TextSuffix property to allow the user to change the text suffix for the dimension.

Sub Ch5_AddTextSuffix()
    Dim dimObj As AcadDimAligned
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    Dim location(0 To 2) As Double
    Dim suffix As String

    ' Define the dimension
    point1(0) = 0: point1(1) = 5: point1(2) = 0
    point2(0) = 5: point2(1) = 5: point2(2) = 0
    location(0) = 5: location(1) = 7: location(2) = 0

    ' Create an aligned dimension object in model space
    Set dimObj = ThisDrawing.ModelSpace. _
 AddDimAligned(point1, point2, location)

    ThisDrawing.Application.ZoomAll
    ' Allow the user to change the text suffix for the dimension
    suffix = InputBox("Enter a new text suffix for the dimension" _
 , "Set Dimension Suffix", ":SUFFIX")

    ' Apply the change to the dimension
    dimObj.TextSuffix = suffix
    ThisDrawing.Regen acAllViewports
End Sub


About Dimensioning in Model Space and Paper Space (VBA/activeX)

You can draw dimensions in both paper space and model space.

However, if the geometry you are dimensioning is in model space, it is better to draw dimensions in model space, because AutoCAD places the definition points in the space where the geometry is drawn.

If you draw a dimension in paper space that describes geometry in your model, the paper space dimension does not change when you use editing commands or change the magnification of the display in the model space viewport. The location of the paper space dimensions also stays the same when you change a view from paper space to model space.

If you are dimensioning in paper space and the global scale factor for linear dimensioning (the DIMLFAC system variable) is set at less than 0, the distance measured is multiplied by the absolute value of DIMLFAC. If you're dimensioning in model space, the value of 1.0 is used even if DIMLFAC is less than 0. AutoCAD computes a value for DIMLFAC if you change the variable at the Dim prompt and select the Viewport option. AutoCAD calculates the scaling of model space to paper space and assigns the negative of this value to DIMLFAC.


About Creating Leaders and Annotation (VBA/ActiveX)

A leader is a line that connects some annotation to a feature in a drawing.

Leaders and their annotation are associative, which means if you modify the annotation, the leader updates accordingly. Do not confuse the Leader object with the leader line AutoCAD automatically generates as part of a dimension line.

Topics in this section

  • About Creating Leader Lines (VBA/ActiveX)

    You can create a leader line from any point or feature in a drawing and control its appearance as you draw it.

  • About Adding the Annotation to a Leader Line (VBA/ActiveX)

    A leader annotation can be a Tolerance, MText, or BlockRef object. You can create a new annotation, or you can append a copy of an existing annotation. Annotation is added to the leader only when it is created.

  • About Leader Associativity (VBA/ActiveX)

    Leaders are associated with their annotation so that when the annotation moves, the endpoint of the leader moves with it.

  • About Editing Leader Associativity (VBA/ActiveX)

    Except for the associativity relation between the leader and annotation, the leader and its annotation are entirely separate objects in your drawing.

  • About Editing Leaders (VBA/ActiveX)

    Any modifications to leader annotation that change its position affect the position of the endpoint of the associated leader. Also, rotating the annotation causes the leader hook line (if any) to rotate.


About Creating Leader Lines (VBA/ActiveX)

You can create a leader line from any point or feature in a drawing and control its appearance as you draw it.

Leaders can be straight line segments or smooth spline curves. Leader color is controlled by the current dimension line color. Leader scale is controlled by the overall dimension scale set in the active dimension style. The type and size of the arrowhead, if one is present, is controlled by the first arrowhead defined in the active style.

A small line known as a hook line usually connects the annotation to the leader. Hook lines appear with MText and feature control frames if the last leader line segment is at an angle greater than 15 degrees from horizontal. The hook line is the length of a single arrowhead. If the leader has no annotation, it has no hook line.

To create a leader line, use the AddLeader method. This method requires three values as input: the array of coordinates specifying where to create the leader, the annotation object (or NULL if the leader is to have no annotation), and the type of leader to create.

The type of leader specifies whether the leader is to be a straight line or a smooth spline curve. It also determines whether or not the leader is to have arrows. Use one of the following constants to specify the type of leader: acLineNoArrow, acLineWithArrow, acSplineNoArrow, or acSplineWithArrow. These constants are mutually exclusive.

Create a leader line

This example creates a leader line in model space. There is no annotation associated with the leader line.

Sub Ch5_CreateLeader()
    Dim leaderObj As AcadLeader
    Dim points(0 To 8) As Double
    Dim leaderType As Integer
    Dim annotationObject As AcadObject

    points(0) = 0: points(1) = 0: points(2) = 0
    points(3) = 4: points(4) = 4: points(5) = 0
    points(6) = 4: points(7) = 5: points(8) = 0
    leaderType = acLineWithArrow
    Set annotationObject = Nothing

    ' Create the leader object in model space
    Set leaderObj = ThisDrawing.ModelSpace. _
          AddLeader(points, annotationObject, leaderType)
    ZoomAll
End Sub


About Adding the Annotation to a Leader Line (VBA/ActiveX)

A leader annotation can be a Tolerance, MText, or BlockRef object. You can create a new annotation, or you can append a copy of an existing annotation. Annotation is added to the leader only when it is created.

To add an annotation when a leader is being created, input the annotation to the AddLeader method.


About Leader Associativity (VBA/ActiveX)

Leaders are associated with their annotation so that when the annotation moves, the endpoint of the leader moves with it.

As you move text and feature control frame annotation, the final leader line segment alternates between attaching to the left side and to the right side of the annotation according to the relation of the annotation to the penultimate (second to last) point of the leader. If the midpoint of the annotation is to the right of the penultimate leader point, then the leader attaches to the right; otherwise, it attaches to the left.

Removing either object from the drawing using either the Delete, Add (to add a block), or WBlock method will break associativity. If the leader and its annotation are copied together in a single operation, the new copy is associative. If they are copied separately, they will not be associative. If associativity is broken for any reason, for example, by copying only the Leader object or by erasing the annotation, the hook line will be removed from the leader.

Associate a leader to the annotation

This example creates an MText object. A leader line is then created using the MText object as its annotation.

Sub Ch5_AddAnnotation()
    Dim leaderObj As AcadLeader
    Dim mtextObj As AcadMText
    Dim points(0 To 8) As Double
    Dim insertionPoint(0 To 2) As Double
    Dim width As Double
    Dim leaderType As Integer
    Dim annotationObject As Object
    Dim textString As String, msg As String

    ' Create the MText object in model space
    textString = "Hello, World."
    insertionPoint(0) = 5
    insertionPoint(1) = 5
    insertionPoint(2) = 0
    width = 2
    Set mtextObj = ThisDrawing.ModelSpace. _
 AddMText(insertionPoint, width, textString)

    ' Data for Leader
    points(0) = 0: points(1) = 0: points(2) = 0
    points(3) = 4: points(4) = 4: points(5) = 0
    points(6) = 4: points(7) = 5: points(8) = 0
    leaderType = acLineWithArrow

    ' Create the Leader object in model space and associate
    ' the MText object with the leader
    Set annotationObject = mtextObj
    Set leaderObj = ThisDrawing.ModelSpace. _
 AddLeader(points, annotationObject, leaderType)
    ZoomAll
End Sub


About Editing Leader Associativity (VBA/ActiveX)

Except for the associativity relation between the leader and annotation, the leader and its annotation are entirely separate objects in your drawing.

Editing of the leader does not affect the annotation, and editing of the annotation does not affect the leader.

Although text annotation is created using the DIMCLRT, DIMTXT, and DIMTXSTY system variables to define its color, height, and style, it cannot be changed by these system variables because it is not a true dimension object. Text annotation must be edited the same way as any other MText object.

Use the Evaluate method to evaluate the relation of the leader to its associated annotation. This method will update the leader geometry if necessary.


About Editing Leaders (VBA/ActiveX)

Any modifications to leader annotation that change its position affect the position of the endpoint of the associated leader. Also, rotating the annotation causes the leader hook line (if any) to rotate.

To resize a leader, you can scale it. Scaling updates only the scale of the selected object. For example, if you scale the leader, the annotation stays in the same position relative to the leader endpoint but isn't scaled.

In addition to scaling, you can also move, mirror, and rotate a leader. Use the ScaleEntity, Move, Mirror, and Rotate methods to edit the leader. You can also change the text style associated with the annotation by using the StyleName property.


About Using Geometric Tolerances (VBA/ActiveX)

Geometric tolerancing shows deviations of form, profile, orientation, location, and runout of a feature.

You add geometric tolerances in feature control frames. These frames contain all the tolerance information for a single dimension.

Topics in this section

  • About Creating Geometric Tolerances (VBA/ActiveX)

    To create a geometric tolerance, use the AddTolerance method.

  • About Editing Tolerances (VBA/ActiveX)

    Geometric tolerances can be modified using the properties and methods associated with the object, or by changing the values of system variables before creating a Tolerance object.


About Creating Geometric Tolerances (VBA/ActiveX)

To create a geometric tolerance, use the AddTolerance method.

This method requires three values as input: the text string comprising the tolerance symbol, the location in the drawing to place the tolerance, and a directional vector specifying the direction of the tolerance. You can also copy, move, erase, scale, and rotate tolerances.

Create a geometric tolerance

This example creates a simple geometric tolerance in model space.

Sub Ch5_CreateTolerance()
    Dim toleranceObj As AcadTolerance
    Dim textString As String
    Dim insertionPoint(0 To 2) As Double
    Dim direction(0 To 2) As Double

    ' Define the tolerance object
    textString = "Here is the Feature Control Frame"
    insertionPoint(0) = 5
    insertionPoint(1) = 5
    insertionPoint(2) = 0
    direction(0) = 1
    direction(1) = 1
    direction(2) = 0
    ' Create the tolerance object in model space
    Set toleranceObj = ThisDrawing.ModelSpace. _
        AddTolerance(textString, insertionPoint, direction)
    ZoomAll
End Sub


About Editing Tolerances (VBA/ActiveX)

Geometric tolerances can be modified using the properties and methods associated with the object, or by changing the values of system variables before creating a Tolerance object.

Tolerances are influenced by several system variables: DIMCLRD controls the color of the feature control frame; DIMCLRT controls the color of the tolerance text; DIMGAP controls the gap between the feature control frame and the text; DIMTXT controls the size of the tolerance text; and DIMTXSTY controls the style of the tolerance text. Use the SetVariable method to set the values of system variables.


Customize Toolbars and Menus

Topics in this section

  • About the MenuBar and MenuGroups Collections

    AutoCAD ActiveX provides several menu-related objects. The two most important are the MenuBar collection and the MenuGroups collection.

  • About Loading Menu Groups

    Menu groups are loaded into AutoCAD using the Load method.

  • About Changing the Menu Bar

    The menu bar can be completely replaced by a new menu group if that group is loaded as the base menu.

  • About Creating and Editing Pull-Down and Shortcut Menus

    AutoCAD ActiveX/VBA has the ability to customize two types of AutoCAD menus: pull-down menus and shortcut menus (sometimes called cursor menus).

  • About Creating and Editing Toolbars

    Using AutoCAD ActiveX/VBA you can create and edit toolbars within an existing menu group.

  • About Creating Macros

    A macro is a series of commands that executes specific actions when a toolbar item is selected.

  • About Creating Status-Line Help for Menu Items and Toolbar Items

    Status-line help messages are an important aspect of native help support. These are the simple, descriptive messages that appear in the status line when a menu or toolbar item is highlighted.

  • About Adding Entries to the Right-Click Menu

    The right-click menu, or shortcut menu, is a special menu included in the AutoCAD base menu group. This menu appears when the user holds Shift and clicks the right mouse button.


About the MenuBar and MenuGroups Collections (VBA/ActiveX)

AutoCAD ActiveX provides several menu-related objects. The two most important are the MenuBar collection and the MenuGroups collection.

The MenuBar collection contains all the menus that are displayed in the AutoCAD menu bar.

The MenuGroups collection contains the menu groups that are loaded in the current AutoCAD session. These menu groups contain all the menus that are available to the AutoCAD session, some or all of which may be displayed on the AutoCAD menu bar. In addition to the menus, the menu groups also contain all the toolbars that are available to the current AutoCAD session.

Each menu group contains a PopupMenus collection and a Toolbars collection. The PopupMenus collection contains all the menus within the menu group. Likewise, the Toolbars collection contains all the toolbars within the menu group.

Each PopupMenu is actually a collection that contains an individual object for each menu item that appears on that menu. Likewise, each Toolbar is also a collection that contains an individual object for each toolbar item that appears on that toolbar.


About Loading Menu Groups (VBA/ActiveX)

Menu groups are loaded into AutoCAD using the Load method.

For example, the following code loads the customization file acad.cuix:

ThisDrawing.Application.MenuGroups.Load "acad.cuix"

When using the Load method, set the BaseMenu parameter to True to load a new menu group to the menu bar. This will load the menu group as a base menu in the same manner as the AutoCAD MENU command.

To load a new menu group as a partial menu, omit the BaseMenu parameter. This will load the menu group in the same manner as the AutoCAD CUILOAD command. Once loaded into the MenuGroups collection, partial menus can be inserted into the menu bar by using the InsertMenuInMenuBar or InsertInMenuBar methods.

Once a menu group has been loaded, all the menus and toolbars defined by that menu group are available for use. You can

  • Add new menus to the menu bar
  • Remove menus from the menu bar
  • Rearrange menus on the menu bar
  • Add new items to an existing menu or toolbar
  • Remove items from an existing menu or toolbar
  • Create new menus and toolbars
  • Float or dock toolbars
  • Enable or disable menu and toolbar items
  • Check or uncheck a menu item
  • Change the tag, label, or help string of a menu or toolbar item
  • Reassign the macros associated to a menu or toolbar item
NoteYou can only edit popup menus and toolbars using ActiveX Automation. However, you can use ActiveX Automation to load and unload other menu types such as image tile menu items, or tablet menus.


About Changing the Menu Bar (VBA/ActiveX)

The menu bar can be completely replaced by a new menu group if that group is loaded as the base menu.

Additionally, individual menus on the menu bar can be added, removed, or rearranged.

Topics in this section

  • About Inserting Menus in the Menu Bar (VBA/ActiveX)

    To insert an existing menu in the menu bar, use the InsertMenuInMenuBar or the InsertInMenuBar method. Both methods accomplish the same goal—they insert an existing menu into the menu bar.

  • About Removing Menus from the Menu Bar (VBA/ActiveX)

    To remove a menu from the menu bar, use the RemoveMenuFromMenuBar or the RemoveFromMenuBar method. Both methods accomplish the same goal—they remove a menu from the menu bar.

  • About Rearranging Menu Items on the Menu Bar (VBA/ActiveX)

    To rearrange menus on the menu bar, insert and remove menus until the desired configuration is achieved.


About Inserting Menus in the Menu Bar (VBA/ActiveX)

To insert an existing menu in the menu bar, use the InsertMenuInMenuBar or the InsertInMenuBar method. Both methods accomplish the same goal—they insert an existing menu into the menu bar.

The difference between the two methods is the object from which they are called. The InsertMenuInMenuBar method is called from the PopupMenus collection. Using this method you can insert any menu from the collection into a specified location on the menu bar. This method requires as input the name of the menu to insert and the location on the menu bar to insert it.

The InsertInMenuBar method is called directly from the PopupMenu object to be inserted. The only input this method requires is a location on the menu bar. The name of the menu is not needed because you are calling the method directly from the object to be inserted.

You should use whichever method is more convenient for your application.

Insert a menu in the menu bar

This example creates a new menu called TestMenu and inserts a menu item into it. The menu item is assigned the OPEN command. The menu is then displayed on the menu bar.

Sub Ch6_InsertMenu()
 ' Define a variable for the current menu group
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application. _
 MenuGroups.Item(0)

 ' Create a new menu
 Dim newMenu As AcadPopupMenu
 Set newMenu = currMenuGroup.Menus.Add("TestMenu")

 ' Declare the variables for the menu item
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String

 ' Assign the macro string the VB equivalent of
 ' "ESC ESC _open " and create the menu item
 openMacro = Chr(3) + Chr(3) + "_open "
 Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, _
 "Open", openMacro)

 ' Display the menu on the menu bar
 currMenuGroup.Menus.InsertMenuInMenuBar "TestMenu", ""
End Sub


About Removing Menus from the Menu Bar (VBA/ActiveX)

To remove a menu from the menu bar, use the RemoveMenuFromMenuBar or the RemoveFromMenuBar method. Both methods accomplish the same goal—they remove a menu from the menu bar.

The difference between the two methods is the object from which they are called. The RemoveMenuFromMenuBar method is called from the PopupMenus collection. This method requires as input the name of the menu to remove, or the location on the menu bar of the menu to remove. For example, the following statement removes a menu named "TestMenu":

currMenuGroup.Menus.RemoveMenuFromMenuBar "TestMenu"

The RemoveFromMenuBar method is called directly from the PopupMenu object to be removed. This method does not require any input. The name of the menu is not needed because you are calling the method directly from the object to be removed.

You should use whichever method is more convenient for your application.

NoteMenus that have been removed from the menu bar are still available in their designated menu group. They are simply no longer visible to the user.


About Rearranging Menu Items on the Menu Bar (VBA/ActiveX)

To rearrange menus on the menu bar, insert and remove menus until the desired configuration is achieved.

Move the first menu to the end of the menu bar

This example removes the first menu on the menu bar and inserts it as the last menu on the menu bar.

Sub Ch6_MoveMenu()
 ' Define a variable to hold the menu to be moved
 Dim moveMenu As AcadPopupMenu
 Dim MyMenuBar As AcadMenuBar
 Set MyMenuBar = ThisDrawing.Application.menuBar

 ' Set moveMenu equal to the first menu displayed
 ' on the menu bar
 Set moveMenu = MyMenuBar.Item(0)

 ' Remove the first menu from the menu bar
 MyMenuBar.Item(0).RemoveFromMenuBar

 ' Add the menu back into the menu bar
 ' in the last position on the bar
 moveMenu.InsertInMenuBar (MyMenuBar.count)
End Sub


About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)

AutoCAD ActiveX/VBA has the ability to customize two types of AutoCAD menus: pull-down menus and shortcut menus (sometimes called cursor menus).

Both pull-down and shortcut menus are displayed as cascading menus. The shortcut menu can provide quick access to frequently used menu items such as Object Snap modes.

A pull-down menu can contain up to 999 menu items. A shortcut menu can contain up to 499 menu items. Both limits include all menus in the hierarchy. If the number of menu items in a menu exceeds these limits, AutoCAD ignores the extra items. If a pull-down or shortcut menu is taller than the available space on the graphics screen, it is truncated to fit on the screen.

Pull-down menus are always pulled down from the menu bar, but the shortcut menu is always displayed at or near the crosshairs on the graphics screen. The handling for both menu types is the same except the shortcut menu caption is not included on the menu bar. The shortcut menu caption is not displayed at all. Access to the shortcut menu is through a single menu in the base menu group. The shortcut menu can be identified with the ShortcutMenu property. If the ShortcutMenu property returns TRUE, then the queried menu is the shortcut menu for the group.

Topics in this section

  • About Creating New Menus (VBA/ActiveX)

    To create a new menu, use the Add method to add a new PopupMenu object to the PopupMenus collection.

  • About Adding New Menu Items to a Menu (VBA/ActiveX)

    To add a new menu item to a menu, use the AddMenuItem method. This method creates a new PopupMenuItem object and adds it to the designated menu.

  • About Adding Separators to a Menu (VBA/ActiveX)

    To add a separator to a menu, use the AddSeparator method. This method creates a new PopupMenuItem object and adds it to the designated menu.

  • About Assigning an Accelerator Key to a Menu Item (VBA/ActiveX)

    To assign the accelerator key for a menu item through AutoCAD ActiveX/VBA, use the Label property of the given menu item.

  • About Creating Cascading Submenus (VBA/ActiveX)

    To add a cascading submenu, create a submenu using the AddSubmenu method.

  • About Deleting Menu Items from a Menu (VBA/ActiveX)

    To remove menu items from a menu, use the Delete method found on the menu item.

  • About Exploring the Properties of Menu Items (VBA/ActiveX)

    Using the properties of a PopupMenuItem object, you can control the way it appears and behaves on a PopupMenu object.


About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Adding New Menu Items to a Menu (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX) >

About Creating New Menus (VBA/ActiveX)

To create a new menu, use the Add method to add a new PopupMenu object to the PopupMenus collection.

To create a new shortcut menu, you must delete an existing shortcut menu. There can be only one shortcut menu per menu group. If there is no other shortcut menu in a menu group, you can add a menu with the label “POP0”. This will tell AutoCAD you want to create a shortcut menu.

The Add method requires as input the name (label) of the menu to add. This name becomes the title for the menu when it is loaded on the menu bar. The name is also the easiest way of identifying the menu within the collection.

The menu name can be a simple string or it can contain special codes. You can change the name of a menu once it has been created. To change the name of an existing menu, use the Name property for that menu.

Create a new popup menu

This example creates a new popup menu called “TestMenu” in the first menu group of the MenuGroups collection.

Sub Ch6_CreateMenu()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new menu
 Dim newMenu As AcadPopupMenu
 Set newMenu = currMenuGroup.Menus.Add("TestMenu")
End Sub


About Creating New Menus (VBA/ActiveX)
About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Adding Separators to a Menu (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX) >

About Adding New Menu Items to a Menu (VBA/ActiveX)

To add a new menu item to a menu, use the AddMenuItem method. This method creates a new PopupMenuItem object and adds it to the designated menu.

The AddMenuItem method takes four parameters as input: Index, Label, Tag, and Macro.

Specify the Index Parameter

The Index parameter is an integer that specifies the position of the new menu item within the menu. The index begins with position zero (0) as the first position on the menu after the title. To add the new menu item to the end of a menu, set the Index parameter equal to the Count property of the menu. (The Count property of the menu represents the total number of menu items on that menu.)

The first index position is zero (0) and the separators are listed as individual menu items with their own index position. The Count property for the menu pictured would be six (6). To add a menu item between Tile Horizontally and Tile Vertically, set the Index parameter to two (2), which is the index of the Tile Vertically menu item. This inserts your new menu item into index two (2) and bumps all the remaining menu items down one index position.

Once a menu item has been created, you cannot change the index of the menu item through the Index property. To change the index of an existing menu item you must delete and re-add the menu item to a different position, or add or delete surrounding menu items until a proper placement is achieved.

Specify the Label Parameter

A label is a string that defines the content and formatting of menu items. Menu item labels can contain DIESEL string expressions that conditionally alter the labels each time they are displayed.

In addition to the DIESEL string expressions, the label may contain special codes. For example, an ampersand (&) placed directly before a character specifies that character as the accelerator key.

The text the user sees displayed for the menu item is called the Caption, and it is derived from the label by interpreting all the DIESEL string expressions and special codes contained in the label. For example, the label “&Edit” produces the caption “Edit.”

Once a menu item has been created, you can change the label for the menu item using the Label property.

Specify the Tag Parameter

The tag, or name tag, is a string consisting of alphanumeric and underscore (_) characters. This string uniquely identifies the menu item within a given menu.

Once a menu item has been created, you can change the tag for the menu item using the TagString property.

Specify the Macro Parameter

A macro is a series of commands that executes specific actions when a menu item is selected. Menu macros can simply be recordings of keystrokes that accomplish a task, or they can be a complex combination of commands, AutoLISP, DIESEL, or ActiveX programming code.

Once a menu item has been created, you can change the macro for the menu item using the Macro property.

Add menu items to a popup menu

This example creates a new menu called “TestMenu” and inserts a menu item. The menu item is given the name “Open,” and the macro assigned to the menu item is the OPEN command.

Sub Ch6_AddAMenuItem()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new menu
 Dim newMenu As AcadPopupMenu
 Set newMenu = currMenuGroup.Menus.Add("TestMenu")

 ' Add a menu item to the new menu
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String
 ' Assign the macro the VBA equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 Set newMenuItem = newMenu.AddMenuItem _
 (newMenu.count + 1, "Open", openMacro)

 ' Display the menu on the menu bar
 newMenu.InsertInMenuBar _
 (ThisDrawing.Application.menuBar.count + 1)
End Sub


About Adding New Menu Items to a Menu (VBA/ActiveX)
About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Assigning an Accelerator Key to a Menu Item (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX) >

About Adding Separators to a Menu (VBA/ActiveX)

To add a separator to a menu, use the AddSeparator method. This method creates a new PopupMenuItem object and adds it to the designated menu.

This kind of PopupMenuItem object is assigned the type of acSeparator. The type of a menu item can be found through the Type property.

The AddSeparator method takes the Index parameter as its only input. The Index parameter is an integer that specifies the position of the separator within the menu. The index begins with position zero (0) as the first position on the menu after the title.


About Adding Separators to a Menu (VBA/ActiveX)
About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Creating Cascading Submenus (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX) >

About Assigning an Accelerator Key to a Menu Item (VBA/ActiveX)

To assign the accelerator key for a menu item through AutoCAD ActiveX/VBA, use the Label property of the given menu item.

To specify an accelerator key, insert the ASCII equivalent of an ampersand (&) in the label directly in front of the character to be used as the accelerator. For example, the label Chr(Asc("&")) + "Edit" will be displayed as “Edit,” with the character “E” being used as the accelerator key.

Add accelerator keys to menus

This example adds accelerator keys for both the “TestMenu” and “Open” menus. The “s” is used as the accelerator key for the “TestMenu” menu and the “O” is used as the accelerator key for the “Open” menu.

Sub Ch6_AddAMenuItem()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new menu
 Dim newMenu As AcadPopupMenu
 Set newMenu = currMenuGroup.Menus.Add _
 ("Te" + Chr(Asc("&")) + "stMenu")

 ' Add a menu item to the new menu
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String
 ' Assign the macro the VBA equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 Set newMenuItem = newMenu.AddMenuItem _
 (newMenu.count + 1, Chr(Asc("&")) _
 + "Open", openMacro)

 ' Display the menu on the menu bar
 newMenu.InsertInMenuBar _
 (ThisDrawing.Application.menuBar.count + 1)
End Sub


About Assigning an Accelerator Key to a Menu Item (VBA/ActiveX)
About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Deleting Menu Items from a Menu (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX) >

About Creating Cascading Submenus (VBA/ActiveX)

To add a cascading submenu, create a submenu using the AddSubmenu method.

This method creates a new PopupMenuItem object and adds it to the designated menu. This special kind of PopupMenuItem object is assigned the type of acSubmenu.

The AddSubmenu method takes three parameters as input: Index, Label, and Tag.

The Index parameter is an integer that specifies the position of the new menu item within the menu. The index begins with position zero (0) as the first position on the menu after the title. To add the new menu item to the end of a menu, set the Index parameter equal to the Count property of the menu. (The Count property of the menu represents the total number of menu items on that menu.)

The Label parameter is a string that defines the content and formatting of menu items. The text that the user sees displayed for the menu item is called the Caption, and it is derived from the label by interpreting all the DIESEL string expressions and special codes contained in the label. For example, the label “&Edit” produces the caption “Edit.”

The Tag parameter, or name tag, is a string consisting of alphanumeric and underscore (_) characters. This string uniquely identifies the menu item within a given menu.

The AddSubmenu method does not return the PopupMenuItem object that it creates. Instead, it returns the new menu that the submenu points to. The new menu, which is returned as a PopupMenu object, can then be populated as a normal menu would be.

Create and populate a submenu

This example creates a new menu called “TestMenu” and adds it to a submenu called “OpenFile.” The submenu is then populated with a menu item called “Open,” which opens a drawing when executed. Finally, the menu is displayed on the menu bar.

Sub Ch6_AddASubMenu()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new menu
 Dim newMenu As AcadPopupMenu
 Set newMenu = currMenuGroup.Menus.Add("TestMenu")

 ' Add the submenu
 Dim FileSubMenu As AcadPopupMenu
 Set FileSubMenu = newMenu.AddSubMenu("", "OpenFile")

 ' Add a menu item to the sub menu
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String
 ' Assign the macro the VB equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 Set newMenuItem = FileSubMenu.AddMenuItem _
 (newMenu.count + 1, "Open", openMacro)

 ' Display the menu on the menu bar
 newMenu.InsertInMenuBar _
 (ThisDrawing.Application.menuBar.count + 1)
End Sub


About Creating Cascading Submenus (VBA/ActiveX)
About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Exploring the Properties of Menu Items (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX) >

About Deleting Menu Items from a Menu (VBA/ActiveX)

To remove menu items from a menu, use the Delete method found on the menu item.

WarningIf you delete a menu item, do not call another method or property that would directly or indirectly cause the same CUIx file to be loaded again within the same macro. For example, after deleting a menu item, do not use the MenuGroup.Load method or the Preferences.Profiles.ActiveProfile property, or issue the AutoCAD CUILOAD command using the Document.SendCommand method. These items directly or indirectly cause the loading of CUIx files. You should only use these methods or properties in a separate macro.

Delete a menu item from a menu

This example adds a menu item to the end of the last menu displayed on the menu bar. It then deletes the menu item.

Sub Ch6_DeleteMenuItem()
 Dim LastMenu As AcadPopupMenu
 Set LastMenu = ThisDrawing.Application.menuBar. _
 Item(ThisDrawing.Application.menuBar.count - 1)

 ' Add a menu item
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String
 ' Assign the macro the VB equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 Set newMenuItem = LastMenu.AddMenuItem _
 (LastMenu.count + 1, "Open", openMacro)

 ' Remove the menu item from the menu
 newMenuItem.Delete
End Sub


About Deleting Menu Items from a Menu (VBA/ActiveX)
About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX)
About Creating and Editing Toolbars (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Pull-Down and Shortcut Menus (VBA/ActiveX) >

About Exploring the Properties of Menu Items (VBA/ActiveX)

Using the properties of a PopupMenuItem object, you can control the way it appears and behaves on a PopupMenu object.

All menu items share the following properties:

TagString
A tag, or name tag, is a string consisting of alphanumeric and underscore (_) characters. This string uniquely identifies the menu item within a given menu. Tags identify the accelerator keys (keyboard key sequences) that correspond to the menu item.

You can read or write the value of a tag by using the TagString property.

Label
A label is a string that defines the content and formatting of menu items.

Menu item labels can contain DIESEL string expressions that conditionally alter the labels each time they are displayed.

You can read or write the value of a label by using the Label property.

Caption
A caption is the text that the user sees displayed on the menu. This property is read-only and is derived from the Label property by removing any DIESEL string expressions.

You can read the value of a caption by using the Caption property.

Macro
A macro is a series of commands that executes specific actions when a menu item is selected. Menu macros can simply be recordings of keystrokes that accomplish a task, or they can be a complex combination of commands, AutoLISP, DIESEL, or ActiveX programming code.

You can read or write the value of a menu macro by using the Macro property.

HelpString
A help string is the text string that appears in the AutoCAD status line when a user highlights a menu item for selection.

You can read or write the value of a help string by using the HelpString property.

Enable
Using the Enable property, you can enable or disable a menu item. You can also read the Enable property to determine if a menu item is currently enabled or disabled. Using this property to enable or disable a menu item overrides any setting for enabling in the DIESEL expression of the menu item.
Check
Using the Check property you can check or uncheck a menu item. You can also read the Check property to determine if a menu item is currently checked or unchecked. Using this property to check or uncheck a menu item overrides any setting for checking in the DIESEL expression of the menu item.
Index
The index of a menu item specifies the position of that menu item on the menu on which it belongs. The index position of a menu always begins with position 0. For example, if the item is the first item on a menu, it returns an index position of 0. If it is the second item on a menu, it returns an index position of 1 and so on.
Type
You can determine the type of a menu item by using the Type property. A menu item can be one of the following types: a regular menu, a separator, or the heading for a submenu. If the item is a regular menu item, this property returns acMenuItem. If the item is a separator, this property returns acMenuSeparator. If the item is a heading for a submenu, this property returns acSubMenu.
SubMenu
You can find the submenu by using the SubMenu property. If the menu item is of the type acSubMenu, this property returns the menu that is attached as the submenu, or embedded menu. The embedded menu is returned as a PopupMenu object.

If the menu item is not of the type acSubMenu, this property returns an error.

Parent
You can find the menu to which a menu item belongs by using the Parent property. This property returns the menu on which the menu item resides. The parent menu is returned as a PopupMenu object.

Enable and disable menu items

This example creates a new menu called “TestMenu” and inserts two menu items. The second menu item is then disabled using the Enable property and the menu is displayed on the menu bar.

Sub Ch6_DisableMenuItem()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new menu
 Dim newMenu As AcadPopupMenu
 Set newMenu = currMenuGroup.Menus.Add("TestMenu")

 ' Add two menu items and a menu separator to the new menu
 Dim MenuEnable As AcadPopupMenuItem
 Dim MenuDisable As AcadPopupMenuItem
 Dim MenuSeparator As AcadPopupMenuItem
 Dim openMacro As String

 ' Assign the macro the VB equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 Set MenuEnable = newMenu.AddMenuItem _
 (newMenu.count + 1, "OpenEnabled", openMacro)
 Set MenuSeparator = newMenu.AddSeparator("")
 Set MenuDisable = newMenu.AddMenuItem _
 (newMenu.count + 1, "OpenDisabled", openMacro)

 ' Disable the second menu item
 MenuDisable.Enable = False

 ' Display the menu on the menu bar
 newMenu.InsertInMenuBar _
 (ThisDrawing.Application.menuBar.count + 1)
End Sub


About Creating and Editing Toolbars (VBA/ActiveX)

Using AutoCAD ActiveX/VBA you can create and edit toolbars within an existing menu group.

Topics in this section

  • About Creating New Toolbars (VBA/ActiveX)

    To create a new toolbar, use the Add method to add a new Toolbar object to the Toolbars collection.

  • About Adding New Toolbar Buttons to a Toolbar (VBA/ActiveX)

    To add a new toolbar button to a toolbar, use the AddToolbarButton method. This method creates a new ToolbarItem object and adds it to the designated toolbar.

  • About Adding Separators to a Toolbar (VBA/ActiveX)

    To add a separator to a toolbar, use the AddSeparator method. This method creates a new ToolbarItem object and adds it to the designated toolbar.

  • About Defining the Toolbar Button Image (VBA/ActiveX)

    To define the images to be used on a toolbar button, use the SetBitmaps and GetBitmaps methods.

  • About Creating Flyout Toolbars (VBA/ActiveX)

    To add a flyout toolbar button to a toolbar, use the AddToolbarButton method. This method creates a new ToolbarItem object and adds it to the designated toolbar.

  • About Floating and Docking Toolbars (VBA/ActiveX)

    Toolbars can be docked or floated programmatically.

  • About Deleting Toolbar Buttons from a Toolbar (VBA/ActiveX)

    To remove toolbar buttons from a toolbar, use the Delete method found on the toolbar button. You should only delete buttons from a toolbar while the toolbar is visible.

  • About Exploring the Properties of Toolbar Items (VBA/ActiveX)

    Using the properties of a ToolbarItem object, you can control the way it appears and behaves on a Toolbar object.


About Creating New Toolbars (VBA/ActiveX)

To create a new toolbar, use the Add method to add a new Toolbar object to the Toolbars collection.

The Add method requires as input the name of the toolbar to add. The name is a string of alphanumeric characters with no punctuation other than a dash (-) or an underscore (_). The name is the easiest way of identifying the toolbar within the collection.

You can change the name of a toolbar once it has been created. To change the name of an existing toolbar, use the Name property for that toolbar.

Create a new toolbar

This example creates a new toolbar called “TestToolbar” in the first menu group in the MenuGroups collection.

Sub Ch6_CreateToolbar()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new toolbar
 Dim newToolbar As AcadToolbar
 Set newToolbar = currMenuGroup.Toolbars.Add("TestToolbar")
End Sub


About Adding New Toolbar Buttons to a Toolbar (VBA/ActiveX)

To add a new toolbar button to a toolbar, use the AddToolbarButton method. This method creates a new ToolbarItem object and adds it to the designated toolbar.

You should only add buttons to a toolbar while the toolbar is visible.

The AddToolbarButton method takes five parameters as input: Index, Name, HelpString, Macro, and FlyoutButton.

Index
The Index parameter is an integer that specifies the position of the new Toolbar item within the toolbar. The index begins with position zero (0) as the first position on the toolbar after the title. To add the new toolbar button to the end of a toolbar, set the Index parameter equal to the Count property of the toolbar. (The Count property of the toolbar represents the total number of toolbar buttons on that toolbar.)

Once a toolbar button has been created, you cannot change the index of the button through the Index property. To change the index of an existing toolbar button, you must delete and re-add the toolbar button to a different position, or add or delete surrounding toolbar buttons until a proper placement is achieved.

Name
A name is a string that identifies the toolbar button. The string must comprise alphanumeric characters with no punctuation other than a dash (-) or an underscore (_). This string is displayed as the tooltip when the cursor is placed over the toolbar button.

Once a toolbar button has been created, you can change the name using the Name parameter.

HelpString
A help string is the text string that appears in the AutoCAD status line when a user highlights a menu item for selection.

Once a toolbar button has been created, you can change the help string for the button using the HelpString parameter.

Macro
A macro is a series of commands that executes specific actions when a toolbar button is selected. Toolbar macros can be simply recordings of keystrokes that accomplish a task, or they can be a complex combination of commands, AutoLISP, DIESEL, or ActiveX programming code.

Once a Toolbar button has been created, you can change the macro for the button using the Macro parameter.

FlyoutButton
The FlyoutButton parameter is an optional flag stating whether or not the new button is to be a flyout button. If the new button is to be a flyout button, this parameter must be set to TRUE. If the new button is not to be a flyout button, this parameter can be set to FALSE or it can be ignored.

Add buttons to a new toolbar

This example creates a new toolbar and adds a button to the toolbar. The button is assigned a macro that will execute the OPEN command when the button is selected.

Sub Ch6_AddButton()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new toolbar
 Dim newToolbar As AcadToolbar
 Set newToolbar = currMenuGroup.Toolbars.Add("TestToolbar")

 ' Add a button to the new toolbar
 Dim newButton As AcadToolbarItem
 Dim openMacro As String

 ' Assign the macro the VB equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "
 Set newButton = newToolbar.AddToolbarButton _
 ("", "NewButton", "Open a file.", openMacro)
End Sub


About Adding Separators to a Toolbar (VBA/ActiveX)

To add a separator to a toolbar, use the AddSeparator method. This method creates a new ToolbarItem object and adds it to the designated toolbar.

This kind of ToolbarItem object is assigned the type of acSeparator. The type of a Toolbar button can be found through the Type property.

The AddSeparator method takes one parameter as input: Index. The Index parameter is an integer that specifies the position of the separator within the toolbar. The index begins with position zero (0) as the first position on the toolbar after the title.


About Defining the Toolbar Button Image (VBA/ActiveX)

To define the images to be used on a toolbar button, use the SetBitmaps and GetBitmaps methods.

The SetBitmaps method takes two parameters: SmallIconName and LargeIconName.

SmallIconName
The small icon name identifies the ID string of the small-image resource (16×16 bitmap). The string must comprise alphanumeric characters with no punctuation other than a dash (-) or an underscore (_), and should include the .bmp extension. The resource can be either a system bitmap or a user-defined bitmap. User-defined bitmaps must be of the appropriate size and must reside in the Support path.
LargeIconName
The large icon name identifies the ID string of the large-image resource (32×32 bitmap). The string must comprise alphanumeric characters with no punctuation other than a dash (-) or an underscore (_), and should include the .bmp extension. The resource can be either a system bitmap or a user-defined bitmap. User-defined bitmaps must be of the appropriate size and must reside in the Support path.

Query an existing toolbar to find the name of the icons for the buttons

Sub Ch6_GetButtonImages()
 Dim Button As AcadToolbarItem
 Dim Toolbar0 As AcadToolbar
 Dim MenuGroup0 As AcadMenuGroup
 Dim SmallButtonName As String
 Dim LargeButtonName As String
 Dim msg As String
 Dim ButtonType As String

 ' Get the first toolbar in the first menu group
 Set MenuGroup0 = ThisDrawing.Application. _
 MenuGroups.Item(0)
 Set Toolbar0 = MenuGroup0.Toolbars.Item(0)

 ' Clear the string variables
 SmallButtonName = ""
 LargeButtonName = ""

 ' Create a header for the message box and
 ' display the toolbar to be queried
 msg = "Toolbar: " + Toolbar0.Name + vbCrLf
 Toolbar0.Visible = True

 ' Iterate through the toolbar and collect data
 ' for each button in the toolbar. If the toolbar is
 ' a normal button or a flyout, collect the small
 ' and large button names for the button.
 For Each Button In Toolbar0
 ButtonType = Choose(Button.Type + 1, "Button", _
 "Separator", "Control", "Flyout")
 msg = msg & ButtonType & ":   "
 If Button.Type = acToolbarButton Or _
 Button.Type = acToolbarFlyout Then
 Button.GetBitmaps SmallButtonName, _
 LargeButtonName
 msg = msg + SmallButtonName + ", " _
 + LargeButtonName
 End If
 msg = msg + vbCrLf
 Next Button

 ' Display the results
 MsgBox msg
End Sub


About Creating Flyout Toolbars (VBA/ActiveX)

To add a flyout toolbar button to a toolbar, use the AddToolbarButton method. This method creates a new ToolbarItem object and adds it to the designated toolbar.

The AddToolbarButton method takes five parameters as input: Index, Name, HelpString, Macro, and FlyoutButton. By setting the FlyoutButton parameter to TRUE, the new button will be created as a flyout button. The return value from this method will be the new flyout toolbar. The flyout toolbar can then be populated as a normal toolbar would be.

Create a flyout toolbar button

This example creates two toolbars. The first toolbar contains a flyout button. The second toolbar is attached to the flyout button on the first toolbar.

Sub Ch6_AddFlyoutButton()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application. _
 MenuGroups.Item(0)

 ' Create the first toolbar
 Dim FirstToolbar As AcadToolbar
 Set FirstToolbar = currMenuGroup.Toolbars. _
 Add("FirstToolbar")

 ' Add a flyout button to the first menu on the menu bar
 Dim FlyoutButton As AcadToolbarItem
 Set FlyoutButton = FirstToolbar.AddToolbarButton _
 ("", "Flyout", "Demonstrates a flyout button", _
 "OPEN", True)

 ' Create the second toolbar. This will be attached to
 ' the first toolbar through the flyout button.
 Dim SecondToolbar As AcadToolbar
 Set SecondToolbar = currMenuGroup.Toolbars. _
 Add("SecondToolbar")

 ' Add a button to the next toolbar
 Dim newButton As AcadToolbarItem
 Dim openMacro As String

 ' Assign the macro the VB equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "
 Set newButton = SecondToolbar.AddToolbarButton _
 ("", "NewButton", "Open a file.", openMacro)

 ' Attach the second toolbar to the flyout
 ' button on the first toolbar
 FlyoutButton.AttachToolbarToFlyout currMenuGroup.Name, _
 SecondToolbar.Name

 ' Display the first toolbar, hide the second toolbar
 FirstToolbar.Visible = True
 SecondToolbar.Visible = False
End Sub


About Floating and Docking Toolbars (VBA/ActiveX)

Toolbars can be docked or floated programmatically.

To float a toolbar, use the Float method for the toolbar. The Float method takes three parameters as input: Top, Left, and NumberFloatRows. The Top and Left parameters specify the pixel location for the top and left edge of the toolbar. The NumberFloatRows parameter specifies the number of rows with which to create a horizontal toolbar. This number must be equal to or greater than one. The buttons of the toolbar will be distributed equally across the number of rows specified. For vertically aligned toolbars, this value specifies the number of columns.

To dock a toolbar, use the Dock method for the toolbar. The Dock method takes three parameters as input: Side, Row, and Column. The Side parameter specifies the side of the toolbar that you will be positioning in the docking maneuver. You can specify the top, bottom, left, or right side of the toolbar. The Row and Column parameters specify a number on the existing rows and columns of docked toolbars at which to dock the toolbar.

You can query a toolbar to see if it is docked by using the DockStatus property. The DockStatus property will return TRUE if the toolbar is docked and FALSE if the toolbar is floating.

Dock a toolbar

This example creates a new toolbar with three buttons on it. The toolbar is then displayed and docked on the left side of the screen.

Sub Ch6_DockToolbar()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application. _
 MenuGroups.Item(0)

 ' Create the new toolbar
 Dim newToolbar As AcadToolbar
 Set newToolbar = currMenuGroup.Toolbars. _
 Add("TestToolbar")

 ' Add three buttons to the new toolbar.
 ' All three buttons will have the same macro attached.
 Dim newButton1 As AcadToolbarItem
 Dim newButton2 As AcadToolbarItem
 Dim newButton3 As AcadToolbarItem
 Dim openMacro As String

 ' Assign the macro the VB equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 Set newButton1 = newToolbar.AddToolbarButton _
 ("", "NewButton1", "Open a file.", openMacro)
 Set newButton2 = newToolbar.AddToolbarButton _
 ("", "NewButton2", "Open a file.", openMacro)
 Set newButton3 = newToolbar.AddToolbarButton _
 ("", "NewButton3", "Open a file.", openMacro)

 ' Display the toolbar
 newToolbar.Visible = True

 ' Dock the toolbar to the left of the screen.
 newToolbar.Dock acToolbarDockLeft
End Sub


About Floating and Docking Toolbars (VBA/ActiveX)
About Creating and Editing Toolbars (VBA/ActiveX)
About Exploring the Properties of Toolbar Items (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Customize Toolbars and Menus > About Creating and Editing Toolbars (VBA/ActiveX) >

About Deleting Toolbar Buttons from a Toolbar (VBA/ActiveX)

To remove toolbar buttons from a toolbar, use the Delete method found on the toolbar button. You should only delete buttons from a toolbar while the toolbar is visible.


About Exploring the Properties of Toolbar Items (VBA/ActiveX)

Using the properties of a ToolbarItem object, you can control the way it appears and behaves on a Toolbar object.

All toolbar items share the following properties:

Tagstring
A tag, or name tag, is a string consisting of alphanumeric and underscore (_) characters. This string uniquely identifies the toolbar item within a given toolbar. A new tag is assigned automatically when a toolbar item is created.

You can read or write the value of a tag by using the Tagstring property.

Name
A name is a string identifying the toolbar item. It is also the string used for the tooltip text, which is the text string that pops up in AutoCAD when a user holds the mouse or another pointing device over the toolbar item.

You can read or write the value of a name by using the Name property.

Macro
A macro is a series of commands that executes specific actions when a toolbar item is selected. Macros can simply be recordings of keystrokes that accomplish a task, or they can be a complex combination of commands, AutoLISP, DIESEL, or ActiveX programming code.

You can read or write the value of a macro by using the Macro property.

HelpString
A help string is the text string that appears in the AutoCAD status line for a toolbar button.

You can read or write the value of a help string by using the HelpString property.

Index
The index of a toolbar item specifies the position of that toolbar item on the toolbar to which it belongs. The index position of a toolbar always begins with position 0. For example, if the item is the first item on a toolbar, it will have an index position of 0. If it is the second item on a toolbar, it will have an index position of 1, and so on.

You can read the index position of a toolbar item by using the Index property.

Type
A toolbar item can be one of the following types: a regular toolbar button, a separator, a flyout toolbar button, or a special control element. If the item is a regular toolbar button, this property returns acButton. If the item is a separator, this property returns acToolButtonSeparator. If the item is a flyout button, this property returns acFlyout. If the item is a special control element, this property returns acControl.

You can determine the type of a toolbar item by using the Type property.

Flyout
If the toolbar item is of the type acFlyout, this property returns the toolbar that is attached as the flyout toolbar. The flyout toolbar is returned as a Toolbar object.

If the menu item is not of the type acFlyout, this property returns NULL.

You can find the flyout toolbar of a toolbar item by using the Flyout property.

Parent
This property returns the toolbar on which the toolbar item resides. The Parent toolbar is returned as a Toolbar object.

You can find the toolbar to which a toolbar item belongs by using the Parent property.

Toolbar Properties
There are other properties that apply to all toolbar items on the toolbar. Such properties include whether the toolbar is docked or floating, visible or hidden, and whether the toolbar uses large buttons or small buttons.


About Creating Macros (VBA/ActiveX)

A macro is a series of commands that executes specific actions when a toolbar item is selected.

Macros can simply be recordings of keystrokes that accomplish a task, or they can be a complex combination of commands, AutoLISP, DIESEL, or ActiveX programming code.

If you intend to include command parameters in a menu macro, you must know the sequence in which that command expects its parameters. Every character in a menu macro is significant, even the blank spaces. As AutoCAD is revised and enhanced, the sequence of prompts for various commands (and sometimes even the command names) might change. Therefore, your custom menus might require minor changes when you upgrade to a new release of AutoCAD.

When command input comes from a menu item, the settings of the PICKADD and PICKAUTO system variables are assumed to be 1 and 0, respectively. This preserves compatibility with previous releases of AutoCAD and makes customization easier because you are not required to check the settings of these variables.

Topics in this section

  • Macro Characters Mapped to ASCII Equivalents Reference (VBA/ActiveX)

    Use the ASCII equivalent for these special characters when creating the string for the Macro property.

  • About Macro Termination (VBA/ActiveX)

    When a macro is executed, AutoCAD places a space at the end of the macro before processing the command sequence.

  • About Pausing for User Input (VBA/ActiveX)

    Macros can request input using the backslash (\) character.

  • About Canceling a Command (VBA/ActiveX)

    To make sure you have no previous incomplete commands, use ^C^C in a macro.

  • About Macro Repetition (VBA/ActiveX)

    Once you have selected a command, you are likely to use it several times before moving on to another command.

  • About Using Single Object Selection Mode (VBA/ActiveX)

    Single object selection puts object selection in single selection mode, disables the normal dialog conducted by object selection, and causes the selection to return the first object(s) selected by a subsequent option.


Macro Characters Mapped to ASCII Equivalents Reference (VBA/ActiveX)

Use the ASCII equivalent for these special characters when creating the string for the Macro property.

The following table provides a synopsis of special characters used in menu macros and their equivalent ASCII numbers as they are used in VB and VBA.

Special characters used in menu and toolbar macros
Character | ASCII Equivalent | Description
; | chr(59) | Issues Enter
^M | chr(13) | Issues Enter
^| | chr(94) + chr(124) | Issues Tab
Spacebar | chr(32) | Enters a space; blank space between command sequences in a menu item is equivalent to pressing the Spacebar
\ | chr(92) | Pauses for user input
_ | chr(95) | Translates AutoCAD commands and keywords that follow
+ | chr(43) | Continues menu macro to the next line (if last character)
=* | chr(61) + chr(42) | Displays the current top-level image, pull-down, or shortcut menu
*^C^C | chr(42) + chr(3) + chr(3) | Prefix for a repeating item
$ | chr(36) | Loads a menu section or introduces a conditional DIESEL macro expression
^B | chr(2) | Toggles Snap on or off (Ctrl+B)
^C | chr(3) | Cancels command (Ctrl+C)
Esc | chr(3) | Cancels command (Esc)
^D | chr(4) | Toggles Coords on or off (Ctrl+D)
^E | chr(5) | Sets the next isometric plane (Ctrl+E)
^G | chr(7) | Toggles Grid on or off (Ctrl+G)
^H | chr(8) | Issues backspace
^O | chr(15) | Toggles Ortho on or off (Ctrl+O)
^P | chr(16) | Toggles MENUECHO on or off
^Q | chr(17) | Echoes all prompts, status listings, and input to the printer (Ctrl+Q)
^T | chr(20) | Toggles Tablet on or off (Ctrl+T)
^V | chr(22) | Changes current viewport (Ctrl+V)
^Z | chr(26) | Null character that suppresses the automatic addition of Spacebar at the end of a menu item


About Macro Termination (VBA/ActiveX)

When a macro is executed, AutoCAD places a space at the end of the macro before processing the command sequence.

AutoCAD processes the following menu macro as though you had entered line Spacebar.

line

Sometimes this is undesirable; for example, the TEXT or DIM command must be terminated by Enter, not by a space. Also, it sometimes takes more than one space (or Enter) to complete a command, but some text editors don't let you create a line with trailing blanks. Two special conventions get around these problems.

  • When a semicolon (;) appears in a macro, AutoCAD substitutes an Enter.
  • If a line ends with a control character, a backslash (\), a plus sign (+), or a semicolon (;), AutoCAD does not add a blank after it.

Look at the following macro:

erase \;

If this item simply ended with the backslash (which indicates user input), it would fail to complete the ERASE operation, because AutoCAD does not add a blank after the backslash. Therefore, this macro uses a semicolon (;) to force an Enter after the user input. Here are more examples:

ucs
ucs ;
text \.4 0 DRAFT Inc;;;Main St.;;;City, State;

Selecting the first macro enters ucs and Spacebar at the Command prompt, and the following prompt appears:

Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>:

Selecting the second macro enters ucs, Spacebar, and semicolon (;) at the Command prompt, which accepts the default value, World. No difference between the first and second item would be evident on the screen; naturally, you would not put both on the same menu.

Selecting the third macro displays a prompt for a starting point and then draws the address on three lines. In the triple-semicolon (;;;), the first semicolon ends the text string, the second causes repetition of the TEXT command, and the third calls for the default placement below the previous line.

NoteAll special characters must be input using their ASCII equivalents.


About Pausing for User Input (VBA/ActiveX)

Macros can request input using the backslash (\) character.

Sometimes it is useful to accept input from the keyboard or the pointing device in the midst of a macro by placing a backslash (\) at the point where you want input.

circle \1
layer off \;

The first macro pauses to ask the user for the center point and then reads a radius of 1 from the macro. Note that there is no space after the backslash character (\). The next macro pauses to ask the user to enter one layer name, then turns that layer off and exits the LAYER command. The LAYER command normally prompts for another operation and exits only if you press Spacebar (blank) or Enter (;).

Normally, the macro resumes after one item is entered. Therefore, it isn't possible to construct a macro that accepts a variable number of inputs (as in object selection) and then continues. However, an exception is made for the SELECT command; a backslash suspends the macro until object selection has completed. For example, consider the following macro:

select \change previous ;properties color red ;

This macro uses the SELECT command to create a selection set of one or more objects. It then issues the CHANGE command, references this selection set using the Previous option, and changes the color of all selected objects to red.

Because the backslash character (\) causes a macro to pause for user input, you cannot use a backslash for any other purpose in a macro. When specifying file directory paths, use a forward slash (/) as the path delimiter: for example, /direct/file.

The following circumstances delay resumption of a macro:

  • If input of a point is expected, Object Snap modes may precede entry of the actual point.
  • If X/Y/Z point filters are used, the macro remains suspended until the entire point has been accumulated.
  • For the SELECT command only, the macro does not resume until object selection has been completed.
  • If the user responds with a transparent command, the suspended macro remains suspended until the transparent command is completed and the originally requested input is received.
  • If the user responds by choosing another macro (to supply options or to execute a transparent command), the original macro is suspended, and the newly selected item is processed to completion before the suspended macro is resumed.


About Canceling a Command (VBA/ActiveX)

To make sure you have no previous incomplete commands, use ^C^C in a macro.

This is the same as pressing Esc twice from the keyboard. Although a single ^C cancels most commands, ^C^C is required to return to the Command prompt from a DIM command. Therefore, ^C^C ensures that AutoCAD returns to the Command prompt in most cases.


About Macro Repetition (VBA/ActiveX)

Once you have selected a command, you are likely to use it several times before moving on to another command.

That is how most people use tools; you pick up a tool, do several things with it, then pick up another tool, and so on. To avoid picking up the tool before each use, AutoCAD provides a command repetition capability, triggered by a null response. However, you cannot use this feature to specify command options.

This feature makes it possible for you to repeat frequently used commands until you choose another command. If a macro begins with *^C^C immediately following the item label, the macro is saved in memory. Subsequent Command prompts are answered by that macro until it is terminated by Esc or by the selection of another macro.

Do not use ^C (Cancel) within a macro that begins with the string *^C^C; this cancels the macro repetition.

The following is an example of the repetitive, or modal, approach to command handling.

*^C^CMOVE Single
*^C^CCOPY Single
*^C^CERASE Single
*^C^CSTRETCH Single Crossing
*^C^CROTATE Single
*^C^CSCALE Single

Macro repetition does not work for items in image tile menus.


About Using Single Object Selection Mode (VBA/ActiveX)

Single object selection puts object selection in single selection mode, disables the normal dialog conducted by object selection, and causes the selection to return the first object(s) selected by a subsequent option.

This can be quite handy in a macro. For example, consider the following macro:

*^C^CERASE single

This macro terminates the current command and activates the ERASE command with the single selection option. After you select this item, you either point to the single object to be erased or point to a blank area and specify a window. The object(s) selected in this way are erased, and the macro is repeated (due to the leading asterisk) so that you can erase something else. Single selection mode leads to more dynamic interaction with AutoCAD.


About Creating Status-Line Help for Menu Items and Toolbar Items (VBA/ActiveX)

Status-line help messages are an important aspect of native help support. These are the simple, descriptive messages that appear in the status line when a menu or toolbar item is highlighted.

The status-line help for all menu and toolbar items is contained in the HelpString property for that item.

The HelpString property is empty when the menu or toolbar item is first created.

Add status-line help to a menu item

This example creates a new menu called “TestMenu” and then creates a menu item called “Open.” The menu item is then assigned status-line help with the HelpString property.

Sub Ch6_AddHelp()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Create the new menu
 Dim newMenu As AcadPopupMenu
 Set newMenu = currMenuGroup.Menus.Add _
 ("Te" + Chr(Asc("&")) + "stMenu")

 ' Add a menu item to the new menu
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String
 ' Assign the macro the VBA equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 ' Create the menu item
 Set newMenuItem = newMenu.AddMenuItem _
 (newMenu.count + 1, Chr(Asc("&")) _
 + "Open", openMacro)

 ' Add the status line help to the menu item
 newMenuItem.HelpString = "Opens an AutoCAD drawing file."

 ' Display the menu on the menu bar
 newMenu.InsertInMenuBar _
 (ThisDrawing.Application.menuBar.count + 1)
End Sub


About Adding Entries to the Right-Click Menu (VBA/ActiveX)

The right-click menu, or shortcut menu, is a special menu included in the AutoCAD base menu group. This menu appears when the user holds Shift and clicks the right mouse button.

AutoCAD finds the shortcut menu by looking in the base menu group for a menu with the ShortcutMenu property equal to TRUE.

New menu groups may or may not have a shortcut menu available. To create a shortcut menu for a menu group, create a new menu and use POP0 as the label for the new menu.

Add a menu item to the end of the right-click menu

This example adds the menu item “OpenDWG” to the end of the right-click menu.

Sub Ch6_AddMenuItemToshortcutMenu()
 Dim currMenuGroup As AcadMenuGroup
 Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)

 ' Find the shortcut menu and assign it to the
 ' shortcutMenu variable
 Dim scMenu As AcadPopupMenu
 Dim entry As AcadPopupMenu
 For Each entry In currMenuGroup.Menus
 If entry.shortcutMenu = True Then
 Set scMenu = entry
 End If
 Next entry

 ' Add a menu item to the shortcut menu
 Dim newMenuItem As AcadPopupMenuItem
 Dim openMacro As String
 ' Assign the macro the VBA equivalent of "ESC ESC _open "
 openMacro = Chr(3) + Chr(3) + "_open "

 Set newMenuItem = scMenu.AddMenuItem _
 ("", Chr(Asc("&")) _
 + "OpenDWG", openMacro)
End Sub


Use Events

Topics in this section

  • About the Events in AutoCAD

    AutoCAD supports different events that allow you to monitor changes to the application environment or drawings.

  • About Event Handlers

    It is important to remember that events simply provide information on the state or activities taking place within AutoCAD.

  • About Handling Application Level Events

    Application level events are not persistent in AutoCAD VBA.

  • About Handling Document Level Events

    Document level events are persistent in AutoCAD VBA. That is, they are automatically enabled when a VBA project is loaded.

  • About Handling Object Level Events

    The object level event is not persistent in AutoCAD VBA. That is, it is not automatically enabled when a VBA project is loaded.


About the Events in AutoCAD (VBA/ActiveX)

AutoCAD supports different events that allow you to monitor changes to the application environment or drawings.

There are three types of events in AutoCAD:

  • Application level events respond to changes in the AutoCAD application and its environment. These events respond to the opening, saving, closing and printing of drawings, creation of new drawings, issuing of AutoCAD commands, loading or unloading of ARX and LISP applications, changes to system variables, and changes to the Application window.
  • Document level events respond to the changes of a specific document or its contents. These events respond to the addition, deletion, or modification of objects, activation of a shortcut menu, changes in the pickfirst selection set, changes to the Drawing window, and regeneration of the drawing. There are also document level events for the opening, closing, and printing of a drawing, and the loading or unloading of ARX and LISP applications from the drawing.
  • Object level events respond to the changes of a specific object. Currently there is only one object level event. It is triggered whenever an object is modified.

Subroutines that respond to events are called event handlers and are executed automatically each and every time their designated event is triggered. Information contained in events, such as the drawing name in the BeginOpen event, are passed to event handlers through parameters.


About Event Handlers (VBA/ActiveX)

It is important to remember that events simply provide information on the state or activities taking place within AutoCAD.

Although event handlers can be written to respond to those events, AutoCAD is often in the middle of processing commands when the event handler is triggered. Event handlers, therefore, have some restrictions on what they can do if they are to provide safe operations in conjunction with AutoCAD and its database.

  • Do not rely on the sequence of events.

    When writing event handlers, do not rely on the sequence of events to happen in the exact order you think they occur. For example, if you issue an OPEN command, the events BeginCommand, BeginOpen, EndOpen, and EndCommand will all be triggered. However, they may not occur in that order. The only event sequence you can safely rely on is that a Begin event will occur before the corresponding End event. In the previous example, the events may get triggered in the following order: BeginCommand, BeginOpen, EndCommand, and EndOpen, or even BeginCommand, EndCommand, BeginOpen, and EndOpen.

  • Do not rely on the sequence of operations.

    If you delete object1 and then object2, do not rely on the fact that you will receive the ObjectErased event for object1 and then for object2. You may receive the ObjectErased event for object2 first.

  • Do not attempt any interactive functions from an event handler.

    Attempting to execute interactive functions from within an event handler can cause serious problems, as AutoCAD may still be processing a command at the time the event is triggered. Therefore, you should always avoid the use of input-acquisition methods such as GetPoint, GetEntity, GetKeyword, and so on, as well as selection set operations and the SendCommand method from within event handlers.

  • Do not launch a dialog box from within an event handler.

    Dialog boxes are considered interactive functions and can interfere with the current operation of AutoCAD. Message boxes and alert boxes are not considered interactive and can be issued safely; however issuing a message box within an event handler for the BeginModal, EndModal, Activate, Deactivate, and BeginRightClick events results in unexpected sequencing.

  • You can write data to any object in the database, except the object that issued the event.

    Obviously, any object causing an event to be triggered could still be open for use with AutoCAD and the operation currently in progress. Therefore, avoid writing any information to an object from an event handler for the same object. However, you can safely read information from the object triggering an event. For example, suppose you have a floor that is filled with tiles and you create an event handler attached to the border of the floor. If you change the size of the floor, the event handler will automatically add or subtract tiles to fill the new area. The event handler will be able to read the new area of the border, but it cannot attempt any changes on the border itself.

  • Do not perform any action from an event handler that will trigger the same event.

    If you perform the same action in an event handler that triggers that same event, you will create an infinite loop. For example, you should never attempt to open a drawing from within the BeginOpen event, or AutoCAD will simply continue to open more drawings until the maximum number of open drawings is reached.

  • Remember that no events will be fired while AutoCAD is displaying a modal dialog box.


About Handling Application Level Events (VBA/ActiveX)

Application level events are not persistent in AutoCAD VBA.

That is, they are not automatically enabled when a VBA project is loaded. Application level events must therefore be enabled for VBA and all other ActiveX® Automation controllers.

Once the application level events are enabled, you have a wide range of events available to you. These events include:

AppActivate
Triggered just before the main Application window is activated.
AppDeactivate
Triggered just before the main Application window is deactivated.
ARXLoaded
Triggered when an ObjectARX application has been loaded.
ARXUnloaded
Triggered when an ObjectARX application has been unloaded.
BeginCommand
Triggered immediately after a command is issued, but before it completes.
BeginFileDrop
Triggered when a file is dropped on the main Application window.
BeginLISP
Triggered immediately after AutoCAD receives a request to evaluate a LISP expression.
BeginModal
Triggered just before a modal dialog box is displayed.
BeginOpen
Triggered immediately after AutoCAD receives a request to open an existing drawing.
BeginPlot
Triggered immediately after AutoCAD receives a request to print a drawing.
BeginQuit
Triggered just before an AutoCAD session ends.
BeginSave
Triggered immediately after AutoCAD receives a request to save the drawing.
EndCommand
Triggered immediately after a command completes.
EndLISP
Triggered upon completion of evaluating a LISP expression.
EndModal
Triggered just after a modal dialog box is dismissed.
EndOpen
Triggered immediately after AutoCAD finishes opening an existing drawing.
EndPlot
Triggered after a document has been sent to the printer.
EndSave
Triggered when AutoCAD has finished saving the drawing.
LISPCancelled
Triggered when the evaluation of a LISP expression is canceled.
NewDrawing
Triggered just before a new drawing is created.
SysVarChanged
Triggered when the value of a system variable is changed.
WindowChanged
Triggered when there is a change to the Application window.
WindowMovedOrResized
Triggered just after the Application window has been moved or resized.

Topics in this section

  • About Enabling Application Level Events (VBA/ActiveX)

    Before you can use application level events you must create a new class module and declare an object of type AcadApplication with events.


About Handling Application Level Events (VBA/ActiveX)
About Handling Application Level Events (VBA/ActiveX)
To Create a New Class and Declare an Application Object with Events (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Use Events > About Handling Application Level Events (VBA/ActiveX) >

About Enabling Application Level Events (VBA/ActiveX)

Before you can use application level events you must create a new class module and declare an object of type AcadApplication with events.

For example, assume that a new class module is created and called EventClassModule. The new class module contains the declaration of the application with the VBA keyword WithEvents.

Prompt to continue when a drawing is dropped into AutoCAD

This example intercepts the load process when a file has been dragged and dropped into AutoCAD. A message box containing the name of the file that was dropped and Yes/No/Continue buttons that allow the user to decide if the file should continue to be loaded or displayed. If the user chooses to cancel out of the operation, that decision is returned through the Cancel parameter of the BeginFileDrop event and the file is not loaded.

Public WithEvents ACADApp As AcadApplication

Sub Example_AcadApplication_Events()
 ' This example intializes the public variable (ACADApp)
 ' which will be used to intercept AcadApplication Events
 '
 ' Run this procedure FIRST!

 ' We could get the application from the ThisDocument
 ' object, but that would require having a drawing open,
 ' so we grab it from the system.
 Set ACADApp = GetObject(, "AutoCAD.Application.20")
End Sub

Private Sub ACADApp_BeginFileDrop _
 (ByVal FileName As String, Cancel As Boolean)
 ' This example intercepts an Application BeginFileDrop event.
 '
 ' This event is triggered when a drawing file is dragged
 ' into AutoCAD.
 '
 ' To trigger this example event:
 '     1) Make sure to run the example that initializes
 '     the public variable (named ACADApp) linked to this event.
 '
 '     2) Drag an AutoCAD drawing file into the AutoCAD
 '        application from either the Windows Desktop
 '        or Windows Explorer

 ' Use the "Cancel" variable to stop the loading of the
 ' dragged file, and the "FileName" variable to  notify
 ' the user which file is about to be dragged in.

 If MsgBox("AutoCAD is about to load " & FileName & vbCrLf _
 & "Do you want to continue loading this file?", _
 vbYesNoCancel + vbQuestion) <> vbYes Then
 Cancel = True
 End If
End Sub

Topics in this section

  • To Create a New Class and Declare an Application Object with Events (VBA/ActiveX)

    You can declare a variable for a specific object type using the WithEvents keyword to get notified when an event is executed.

  • To Connect the Declared Object to the Application Object (VBA/ActiveX)

    Before a procedure related to the event of an object is executed, you must connect the declared object in the class module with the Application object.


About Enabling Application Level Events (VBA/ActiveX)
About Enabling Application Level Events (VBA/ActiveX)
To Connect the Declared Object to the Application Object (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Use Events > About Handling Application Level Events (VBA/ActiveX) > About Enabling Application Level Events (VBA/ActiveX) >

To Create a New Class and Declare an Application Object with Events (VBA/ActiveX)

You can declare a variable for a specific object type using the WithEvents keyword to get notified when an event is executed.

  1. In the VBA IDE, insert a class module. From the Insert menu, choose Class Module.
  2. Select the new class module in the Project Explorer window.
  3. Change the name of the class in the Properties window to EventClass-Module.
  4. Open the Code window for the class using F7, or by selecting the menu option View [image] Code.
  5. In the Code window for the class, add the following line:
    Public WithEvents App As AcadApplication

    After the new object has been declared with events, it appears in the Object drop-down list box in the class module, and you can write event procedures for the new object in the class module. (When you select the new object in the Object box, the valid events for that object are listed in the Procedure drop-down list box.)


To Create a New Class and Declare an Application Object with Events (VBA/ActiveX)
About Enabling Application Level Events (VBA/ActiveX)
About Handling Document Level Events (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Use Events > About Handling Application Level Events (VBA/ActiveX) > About Enabling Application Level Events (VBA/ActiveX) >

To Connect the Declared Object to the Application Object (VBA/ActiveX)

Before a procedure related to the event of an object is executed, you must connect the declared object in the class module with the Application object.

  1. In the Code window for your main module, add the following line to the declarations section:
    Dim X As New EventClassModule
  2. In the same window, add the following subroutine:
    Sub InitializeEvents()
  Set X.App = ThisDrawing.Application
End Sub
  3. In the code for your main module, add a call to the InitializeEvents subroutine:
    Call InitializeEvents

    Once the InitializeEvents procedure has been run, the App object in the class module points to the Application object specified, and any event procedures in the class module will run when the events occur.


About Handling Document Level Events (VBA/ActiveX)

Document level events are persistent in AutoCAD VBA. That is, they are automatically enabled when a VBA project is loaded.

However, they are not enabled for any other controller, such as VB. Document level events must therefore be enabled for all other ActiveX Automation controllers.

Once the document level events are enabled, you have a wide range of events available to you. These events include

Activate
Triggered when a Document window is activated.
BeginClose
Triggered immediately after AutoCAD receives a request to close a drawing.
BeginDocClose
Triggered just after a request is received to close a drawing.
BeginCommand
Triggered immediately after a command is issued, but before it completes.
BeginDoubleClick
Triggered after the user double-clicks on an object in the drawing.
BeginLISP
Triggered immediately after AutoCAD receives a request to evaluate a LISP expression.
BeginPlot
Triggered immediately after AutoCAD receives a request to print a drawing.
BeginRightClick
Triggered after the user right-clicks on the Drawing window.
BeginSave
Triggered immediately after AutoCAD receives a request to save the drawing.
BeginShortcutMenuCommand
Triggered after the user right-clicks on the Drawing window, and before the shortcut menu appears in Command mode.
BeginShortcutMenuDefault
Triggered after the user right-clicks on the Drawing window, and before the shortcut menu appears in Default mode.
BeginShortcutMenuEdit
Triggered after the user right-clicks on the Drawing window, and before the shortcut menu appears in Edit mode.
BeginShortcutMenuGrip
Triggered after the user right-clicks on the Drawing window, and before the shortcut menu appears in Grip mode.
BeginShortcutMenuOsnap
Triggered after the user right-clicks on the Drawing window, and before the shortcut menu appears in Osnap mode.
Deactivate
Triggered when the Drawing window is deactivated.
EndCommand
Triggered immediately after a command completes.
EndLISP
Triggered upon completion of evaluating a LISP expression.
EndPlot
Triggered after a document has been sent to the printer.
EndSave
Triggered when AutoCAD has finished saving the drawing.
EndShortcutMenu
Triggered after the shortcut menu appears.
LayoutSwitched
Triggered after the user switches to a different layout.
LISPCancelled
Triggered when the evaluation of a LISP expression is canceled.
ObjectAdded
Triggered when an object has been added to the drawing.
ObjectErased
Triggered when an object has been erased from the drawing.
ObjectModified
Triggered when an object in the drawing has been modified.
SelectionChanged
Triggered when the current pickfirst selection set changes.
WindowChanged
Triggered when there is a change to the Document window.
WindowMovedOrResized
Triggered just after the Drawing window has been moved or resized.

Topics in this section

  • About Enabling Document Level Events in Environments Other Than VBA (VBA/ActiveX)

    Before you can use document level events in VB or another environment besides VBA, you must create a new class module and declare an object of type AcadDocument with events.

  • About Coding Document Level Events in Environments Other Than VBA (VBA/ActiveX)

    Once the document level events have been enabled, you will find the Doc class variable available from the Object drop-down list of the Class Module Code window.

  • About Coding Document Level Events in VBA (VBA/ActiveX)

    Document level events are automatically enabled when a VBA project is loaded.


About Enabling Document Level Events in Environments Other Than VBA (VBA/ActiveX)

Before you can use document level events in VB or another environment besides VBA, you must create a new class module and declare an object of type AcadDocument with events.

For example, assume a new class module is created and called EventClassModule. The new class module contains the declaration of the application with the VBA keyword WithEvents.

Topics in this section

  • To Create a New Class and Declare a Document Object with Events (VBA/ActiveX)

    You can declare a variable for a specific object type using the WithEvents keyword to get notified when an event is executed.

  • To Connect the Declared Object to the Document Object (VBA/ActiveX)

    Before the procedures will run, however, you must connect the declared object in the class module with the Document object.


About Enabling Document Level Events in Environments Other Than VBA (VBA/ActiveX)
About Enabling Document Level Events in Environments Other Than VBA (VBA/ActiveX)
To Connect the Declared Object to the Document Object (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Use Events > About Handling Document Level Events (VBA/ActiveX) > About Enabling Document Level Events in Environments Other Than VBA (VBA/ActiveX) >

To Create a New Class and Declare a Document Object with Events (VBA/ActiveX)

You can declare a variable for a specific object type using the WithEvents keyword to get notified when an event is executed.

  1. In the VBA IDE, insert a class module. From the Insert menu, choose Class Module.
  2. Select the new class module in the Project Explorer window.
  3. Change the name of the class in the Properties window to EventClass-Module.
  4. Open the Code window for the class using F7, or by selecting the menu option View [image] Code.
  5. In the Code window for the class, add the following line:
    Public WithEvents Doc As AcadDocument

    After the new object has been declared with events, it appears in the Object drop-down list box in the class module, and you can write event procedures for the new object in the class module. (When you select the new object in the Object box, the valid events for that object are listed in the Procedure drop-down list box.)


To Create a New Class and Declare a Document Object with Events (VBA/ActiveX)
About Enabling Document Level Events in Environments Other Than VBA (VBA/ActiveX)
About Coding Document Level Events in Environments Other Than VBA (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Use Events > About Handling Document Level Events (VBA/ActiveX) > About Enabling Document Level Events in Environments Other Than VBA (VBA/ActiveX) >

To Connect the Declared Object to the Document Object (VBA/ActiveX)

Before the procedures will run, however, you must connect the declared object in the class module with the Document object.

  1. In the Code window for your main module, add the following line to the declarations section:
    Dim X As New EventClassModule
  2. In the same window, add the following subroutine:
    Sub InitializeEvents()
  Set X.Doc = ThisDrawing
End Sub
  3. In the code for your main module, add a call to the InitializeApp subroutine:
    Call InitializeEvents

    Once the InitializeEvents procedure has been run, the Doc object in the class module points to the Document object created, and any event procedures in the class module will run when the events occur.


About Coding Document Level Events in Environments Other Than VBA (VBA/ActiveX)

Once the document level events have been enabled, you will find the Doc class variable available from the Object drop-down list of the Class Module Code window.

Select the Doc class and the list of available events will appear in the Procedure drop-down list. Simply select the event you want to write a handler for and the handler skeleton is created automatically.


About Coding Document Level Events in VBA (VBA/ActiveX)

Document level events are automatically enabled when a VBA project is loaded.

To write event handlers for document level events in VBA, you simply select AcadDocument from the Object drop-down list in the Code window. The available events for the document will appear in the Procedure drop-down list. Simply select the event you want to write a handler for and the handler skeleton is created automatically.

Note that event handlers created in this fashion apply to the current active drawing.

The following example uses the event handler for the BeginShortcutMenuDefault event to add the “OpenDWG” menu item to the beginning of the shortcut menu. Then the event handler for the EndShortcutMenu event removes the additional menu item so that it is not saved permanently in the user's menu configuration.

Private Sub AcadDocument_BeginShortcutMenuDefault _
 (ShortcutMenu As AutoCAD.IAcadPopupMenu)
    On Error Resume Next
    ' Add a menu item to the cursor menu
    Dim newMenuItem As AcadPopupMenuItem
    Dim openMacro As String
    openMacro = Chr(vbKeyEscape) + Chr(vbKeyEscape) + "_open "
    Set newMenuItem = ShortcutMenu.AddMenuItem _
 (0, Chr(Asc("&")) _
 + "OpenDWG", openMacro)
End Sub

Private Sub AcadDocument_EndShortcutMenu _
 (ShortcutMenu As AutoCAD.IAcadPopupMenu)
    On Error Resume Next
    ShortcutMenu.Item("OpenDWG").Delete
End Sub


About Handling Object Level Events (VBA/ActiveX)

The object level event is not persistent in AutoCAD VBA. That is, it is not automatically enabled when a VBA project is loaded.

An object level event must be enabled for VBA and all other ActiveX Automation controllers.

Once the object level events is enabled, the Modified event is available to you. This event is triggered when an object in the drawing has been modified.

Topics in this section

  • About Enabling the Object Level Event (VBA/ActiveX)

    Before you can use object level events you must create a new class module and declare an object of type AcadObject with events.


About Enabling the Object Level Event (VBA/ActiveX)

Before you can use object level events you must create a new class module and declare an object of type AcadObject with events.

For example, assume that a new class module is created and called EventClassModule. The new class module contains the declaration of the application with the VBA keyword WithEvents.

Display the area of a closed polyline whenever the polyline is updated

This example creates a lightweight polyline with events. The event handler for the polyline then displays the new area whenever the polyline is changed. To trigger the event, simply change the size of the polyline in AutoCAD. Remember that you must run the CreatePLineWithEvents subroutine before the event handler is activated.

Public WithEvents PLine As AcadLWPolyline

Sub CreatePLineWithEvents()
 ' This example creates a light weight polyline
 Dim points(0 To 9) As Double
 points(0) = 1: points(1) = 1
 points(2) = 1: points(3) = 2
 points(4) = 2: points(5) = 2
 points(6) = 3: points(7) = 3
 points(8) = 3: points(9) = 2
 Set PLine = ThisDrawing.ModelSpace. _
 AddLightWeightPolyline(points)
 PLine.Closed = True
 ThisDrawing.Application.ZoomAll
End Sub

Private Sub PLine_Modified _
 (ByVal pObject As AutoCAD.IAcadObject)
 ' This event is triggered when the polyline is resized.
 ' If the polyline is deleted the modified event is still
 ' triggered, so we use the error handler to avoid
 ' reading data from a deleted object.
 On Error GoTo ERRORHANDLER
 MsgBox "The area of " & pObject.ObjectName & " is: " _
 & pObject.Area
 Exit Sub

ERRORHANDLER:
 MsgBox Err.Description
End Sub

Topics in this section

  • To Create a New Class and Declare a Circle Object with Events (VBA/ActiveX)

    You can declare a variable for a specific object type using the WithEvents keyword to get notified when an event is executed.

  • To Connect the Declared Object to the Automation Object (VBA/ActiveX

    Before the procedures will run, however, you must connect the declared object in the class module with the Circle object.


About Enabling the Object Level Event (VBA/ActiveX)
About Enabling the Object Level Event (VBA/ActiveX)
To Connect the Declared Object to the Automation Object (VBA/ActiveX
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Use Events > About Handling Object Level Events (VBA/ActiveX) > About Enabling the Object Level Event (VBA/ActiveX) >

To Create a New Class and Declare a Circle Object with Events (VBA/ActiveX)

You can declare a variable for a specific object type using the WithEvents keyword to get notified when an event is executed.

  1. In the VBA IDE, insert a class module. From the Insert menu, choose Class Module.
  2. Select the new class module in the Project Explorer window.
  3. Change the name of the class in the Properties window to EventClass-Module.
  4. Open the Code window for the class using F7, or by selecting the menu option View [image] Code.
  5. In the Code window for the class, add the following line:
    Public WithEvents Object As AcadCircle

    After the new object has been declared with events, it appears in the Object drop-down list box in the class module, and you can write event procedures for the new object in the class module. (When you select the new object in the Object box, the valid events for that object are listed in the Procedure drop-down list box.)


To Create a New Class and Declare a Circle Object with Events (VBA/ActiveX)
About Enabling the Object Level Event (VBA/ActiveX)
Work in Three-Dimensional Space
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Use Events > About Handling Object Level Events (VBA/ActiveX) > About Enabling the Object Level Event (VBA/ActiveX) >

To Connect the Declared Object to the Automation Object (VBA/ActiveX

Before the procedures will run, however, you must connect the declared object in the class module with the Circle object.

  1. In the Code window for your main module, add the following line to the declarations section:
    Dim X As New EventClassModule
  2. In the same window, create a circle called “MyCircle” and initialize it as containing events:
    Sub InitializeEvents()
 Dim MyCircle As AcadCircle
 Dim centerPoint(0 To 2) As Double
 Dim radius As Double
 centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
 radius = 5#
 Set MyCircle = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
 Set X.Object = MyCircle
End Sub
  3. In the code for your main module, add a call to the InitializeApp subroutine:
    Call InitializeEvents

    Once the InitializeEvents procedure has been run, the Circle object in the class module points to the Circle object created, and any event procedures in the class module will run when the events occur.

    NoteWhen coding in VBA, you must provide an event handler for all objects enabled for the Modified event. If you do not provide a handler, VBA may terminate unexpectedly.


Work in Three-Dimensional Space

Topics in this section

  • About Specifying 3D Coordinates

    Entering 3D world coordinate system (WCS) coordinates is similar to entering 2D WCS coordinates.

  • About Defining a User Coordinate System

    You define a user coordinate system ( UCS ) object to change the location of the (0, 0, 0) origin point and the orientation of the XY plane and Z axis.

  • About Converting Coordinates

    The TranslateCoordinates method translates a point or a displacement from one coordinate system to another.

  • About Creating 3D Objects

    AutoCAD supports three types of 3D modeling.

  • About Editing in 3D

    This section describes how to edit 3D objects by, for example, rotating, arraying, and mirroring.

  • About Editing 3D Solids

    Once you have created a solid, you can create more complex shapes by combining solids.


About Specifying 3D Coordinates (VBA/ActiveX)

Entering 3D world coordinate system (WCS) coordinates is similar to entering 2D WCS coordinates.

In addition to specifying X and Y values, you specify a Z value. As with the 2D coordinates, a variant is used to pass the coordinates to ActiveX® methods and properties, and to query the coordinates.

Define and query the coordinates for 2D and 3D polylines

This example creates two polylines, each with three coordinates. The first polyline is a 2D polyline, the second polyline is 3D. Notice that the length of the array containing the vertices is expanded to include the Z coordinates in the creation of the 3D polyline. The example concludes by querying the coordinates of the polylines and displaying the coordinates in a message box.

Sub Ch8_Polyline_2D_3D()
    Dim pline2DObj As AcadLWPolyline
    Dim pline3DObj As AcadPolyline

    Dim points2D(0 To 5) As Double
    Dim points3D(0 To 8) As Double

    ' Define three 2D polyline points
   points2D(0) = 1: points2D(1) = 1
   points2D(2) = 1: points2D(3) = 2
   points2D(4) = 2: points2D(5) = 2

    ' Define three 3D polyline points
   points3D(0) = 1: points3D(1) = 1: points3D(2) = 0
   points3D(3) = 2: points3D(4) = 1: points3D(5) = 0
   points3D(6) = 2: points3D(7) = 2: points3D(8) = 0

    ' Create the 2D light weight Polyline
    Set pline2DObj = ThisDrawing.ModelSpace. _
 AddLightWeightPolyline(points2D)
    pline2DObj.Color = acRed
    pline2DObj.Update

    ' Create the 3D polyline
    Set pline3DObj = ThisDrawing.ModelSpace. _
 AddPolyline(points3D)
    pline3DObj.Color = acBlue
    pline3DObj.Update

    ' Query the coordinates of the polylines
    Dim get2Dpts As Variant
    Dim get3Dpts As Variant

    get2Dpts = pline2DObj.Coordinates
    get3Dpts = pline3DObj.Coordinates

    ' Display the coordinates

    MsgBox ("2D polyline (red): " & vbCrLf & _
 get2Dpts(0) & ", " & get2Dpts(1) & vbCrLf & _
 get2Dpts(2) & ", " & get2Dpts(3) & vbCrLf & _
 get2Dpts(4) & ", " & get2Dpts(5))

    MsgBox ("3D polyline (blue): " & vbCrLf & _
 get3Dpts(0) & ", " & get3Dpts(1) & ", " & _
 get3Dpts(2) & vbCrLf & _
 get3Dpts(3) & ", " & get3Dpts(4) & ", " & _
 get3Dpts(5) & vbCrLf & _
 get3Dpts(6) & ", " & get3Dpts(7) & ", " & _
 get3Dpts(8))
End Sub


About Defining a User Coordinate System (VBA/ActiveX)

You define a user coordinate system ( UCS ) object to change the location of the (0, 0, 0) origin point and the orientation of the XY plane and Z axis.

You can locate and orient a UCS anywhere in 3D space, and you can define, save, and recall as many user coordinate systems as you require. Coordinate input and display are relative to the current UCS.

To indicate the origin and orientation of the UCS, you can display the UCS icon at the UCS origin point using the UCSIconAtOrigin property. If the UCS icon is turned on (see the UCSIconOn property) and is not displayed at the origin, it is displayed at the WCS coordinate defined by the UCSORG system variable.

You can create a new user coordinate system using the Add method. This method requires four values as input: the coordinate of the origin, a coordinate on the X and Y axes, and the name of the UCS.

All coordinates in the AutoCAD ActiveX Automation are entered in the world coordinate system. Use the GetUCSMatrix method to return the transformation matrix of a given UCS. Use this transformation matrix to find the equivalent WCS coordinates.

To make a UCS active, use the ActiveUCS property on the Document object. If changes are made to the active UCS, the new UCS object must be reset as the active UCS for the changes to appear. To reset the active UCS, simply call the ActiveUCS property again with the updated UCS object.

Create a new UCS, make it active, and translate the coordinates of a point into the UCS coordinates

The following subroutine creates a new UCS and sets it as the active UCS for the drawing. It then asks the user to pick a point in the drawing, and returns both WCS and UCS coordinates for the point.

Sub Ch8_NewUCS()
    ' Define the variables we will need
    Dim ucsObj As AcadUCS
    Dim origin(0 To 2) As Double
    Dim xAxisPnt(0 To 2) As Double
    Dim yAxisPnt(0 To 2) As Double
    ' Define the UCS points
    origin(0) = 4: origin(1) = 5: origin(2) = 3
    xAxisPnt(0) = 5: xAxisPnt(1) = 5: xAxisPnt(2) = 3
    yAxisPnt(0) = 4: yAxisPnt(1) = 6: yAxisPnt(2) = 3

    ' Add the UCS to the
    ' UserCoordinatesSystems collection
    Set ucsObj = ThisDrawing.UserCoordinateSystems. _
 Add(origin, xAxisPnt, yAxisPnt, "New_UCS")
    ' Display the UCS icon
    ThisDrawing.ActiveViewport.UCSIconAtOrigin = True
    ThisDrawing.ActiveViewport.UCSIconOn = True

    ' Make the new UCS the active UCS
    ThisDrawing.ActiveUCS = ucsObj
    MsgBox "The current UCS is : " & ThisDrawing.ActiveUCS.Name _
 & vbCrLf & " Pick a point in the drawing."

    ' Find the WCS and UCS coordinate of a point
    Dim WCSPnt As Variant
    Dim UCSPnt As Variant

    WCSPnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
    UCSPnt = ThisDrawing.Utility.TranslateCoordinates _
 (WCSPnt, acWorld, acUCS, False)

    MsgBox "The WCS coordinates are: " & WCSPnt(0) & ", " _
 & WCSPnt(1) & ", " & WCSPnt(2) & vbCrLf & _
 "The UCS coordinates are: " & UCSPnt(0) & ", " _
 & UCSPnt(1) & ", " & UCSPnt(2)
End Sub


About Converting Coordinates (VBA/ActiveX)

The TranslateCoordinates method translates a point or a displacement from one coordinate system to another.

A point argument, called OriginalPoint, can be interpreted as either a 3D point or a 3D displacement vector. This argument is distinguished by the Boolean argument, Disp. If the Disp argument is set to TRUE, the OriginalPoint argument is treated as a displacement vector; otherwise, it is treated as a point. Two more arguments determine which coordinate system the OriginalPoint is from, and to which coordinate system the OriginalPoint is to be converted. The following AutoCAD coordinate systems can be specified in the From and To arguments:

WCS
World coordinate system: The reference coordinate system. All other coordinate systems are defined relative to the WCS, which never changes. Values measured relative to the WCS are stable across changes to other coordinate systems. All points passed in and out of ActiveX methods and properties are expressed in the WCS unless otherwise specified.
UCS
User coordinate system (UCS): The working coordinate system. The user specifies a UCS to make drawing tasks easier. All points passed to AutoCAD commands, including those returned from AutoLISP routines and external functions, are points in the current UCS (unless the user precedes them with an * at the Command prompt). If you want your application to send coordinates in the WCS, OCS, or DCS to AutoCAD commands, you must first convert them to the UCS by calling the TranslateCoordinates method.
OCS
Object coordinate system: Point values specified by certain methods and properties for the Polyline and LightweightPolyline objects are expressed in this coordinate system, relative to the object. These points are usually converted into the WCS, current UCS, or current DCS, according to the intended use of the object. Conversely, points in WCS, UCS, or DCS must be translated into an OCS before they are written to the database by means of the same properties.

When converting coordinates to or from the OCS you must enter the normal for the OCS in the final argument of the TranslateCoordinates function.

DCS
Display coordinate system: The coordinate system where objects are transformed before they are displayed. The origin of the DCS is the point stored in the AutoCAD TARGET system variable, and its Z axis is the viewing direction. In other words, a viewport is always a plan view of its DCS. These coordinates can be used to determine where something will be displayed to the AutoCAD user.
PSDCS
Paper space DCS: This coordinate system can be transformed only to or from the DCS of the currently active model space viewport. This is essentially a 2D transformation, where the X and Y coordinates are always scaled and offset if the Disp argument is FALSE. The Z coordinate is scaled but never translated. Therefore, it can be used to find the scale factor between the two coordinate systems. The PSDCS can be transformed only into the current model space viewport. If the from argument equals PSDCS, then the to argument must equal DCS, and vice versa.

Translate OCS coordinates to WCS coordinates

This example creates a polyline in model space. The first vertex for the polyline is then displayed in both the OCS and WCS coordinates. The conversion from OCS to WCS requires the normal for the OCS be placed in the last argument of the TranslateCoordinates method.

Sub Ch8_TranslateCoordinates()
    ' Create a polyline in model space.
    Dim plineObj As AcadPolyline
    Dim points(0 To 14) As Double

    ' Define the 2D polyline points
    points(0) = 1: points(1) = 1: points(2) = 0
    points(3) = 1: points(4) = 2: points(5) = 0
    points(6) = 2: points(7) = 2: points(8) = 0
    points(9) = 3: points(10) = 2: points(11) = 0
    points(12) = 4: points(13) = 4: points(14) = 0

    ' Create a light weight Polyline object in model space
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)

    ' Find the X and Y coordinates of the
    ' first vertex of the polyline
    Dim firstVertex As Variant
    firstVertex = plineObj.Coordinate(0)

    ' Find the Z coordinate for the polyline
    ' using the elevation property
    firstVertex(2) = plineObj.Elevation

    ' Change the normal for the pline so that the
    ' difference between the coordinate systems
    ' is obvious.
    Dim plineNormal(0 To 2) As Double
    plineNormal(0) = 0#
    plineNormal(1) = 1#
    plineNormal(2) = 2#
    plineObj.Normal = plineNormal

    ' Translate the OCS coordinate into WCS
    Dim coordinateWCS As Variant
    coordinateWCS = ThisDrawing.Utility.TranslateCoordinates _
          (firstVertex, acOCS, acWorld, False, plineNormal)

    ' Display the coordinates of the point
    MsgBox "The first vertex has the following coordinates:" _
 & vbCrLf & "OCS: " & firstVertex(0) & ", " & _
 firstVertex(1) & ", " & firstVertex(2) & vbCrLf & _
 "WCS: " & coordinateWCS(0) & ", " & _
 coordinateWCS(1) & ", " & coordinateWCS(2)
End Sub


About Creating 3D Objects (VBA/ActiveX)

AutoCAD supports three types of 3D modeling.

The three types of supported 3D modeling are:

  • wireframe
  • surface
  • solid

Each type has its own creation and editing techniques.

Topics in this section

  • About Creating Wireframes (VBA/ActiveX)

    With AutoCAD you can create wireframe models by positioning any 2D planar object anywhere in 3D space.

  • About Creating Meshes (VBA/ActiveX)

    A rectangular mesh (PolygonMesh object) represents an object's surface using planar facets.

  • About Creating Polyface Meshes (VBA/ActiveX)

    Use the AddPolyfaceMesh method to create a polyface mesh, with each face capable of having numerous vertices.

  • About Creating Solids (VBA/ActiveX)

    A solid object (3DSolid object) represents the entire volume of an object.


About Creating Wireframes (VBA/ActiveX)

With AutoCAD you can create wireframe models by positioning any 2D planar object anywhere in 3D space.

You can position 2D objects in 3D space using several methods:

  • Create the object by entering 3D points. You enter a coordinate that defines the X, Y, and Z location of the point.
  • Set the default construction plane (XY plane) on which you will draw the object by defining a UCS.
  • Move the object to its proper orientation in 3D space after you create it.

Also, you can create some wireframe objects, such as polylines, that can exist in all three dimensions. Use the Add3DPoly method to create 3D polylines.


About Creating Meshes (VBA/ActiveX)

A rectangular mesh (PolygonMesh object) represents an object's surface using planar facets.

The mesh density, or number of facets, is defined in terms of a matrix of M and N vertices, similar to a grid consisting of columns and rows. M and N specify the column and row position, respectively, of any given vertex. You can create meshes in both 2D and 3D, but they are used primarily for 3D.

Use the Add3DMesh method for creating rectangular meshes. This method takes three values as input: the number of vertices in the M direction, the number of vertices in the N direction, and a variant array containing coordinates for all the vertices in the mesh.

Once the PolygonMesh is created, use the MClose and NClose properties to close the mesh.

Create a polygon mesh

This example creates a 4×4 polygon mesh. The direction of the active viewport is then adjusted so that the three-dimensional nature of the mesh is more easily viewed.

Sub Ch8_Create3DMesh()
    Dim meshObj As AcadPolygonMesh
    Dim mSize, nSize, Count As Integer
    Dim points(0 To 47) As Double

    ' create the matrix of points
    points(0) = 0: points(1) = 0: points(2) = 0
    points(3) = 2: points(4) = 0: points(5) = 1
    points(6) = 4: points(7) = 0: points(8) = 0
    points(9) = 6: points(10) = 0: points(11) = 1
    points(12) = 0: points(13) = 2: points(14) = 0
    points(15) = 2: points(16) = 2: points(17) = 1
    points(18) = 4: points(19) = 2: points(20) = 0
    points(21) = 6: points(22) = 2: points(23) = 1
    points(24) = 0: points(25) = 4: points(26) = 0
    points(27) = 2: points(28) = 4: points(29) = 1
    points(30) = 4: points(31) = 4: points(32) = 0
    points(33) = 6: points(34) = 4: points(35) = 0
    points(36) = 0: points(37) = 6: points(38) = 0
    points(39) = 2: points(40) = 6: points(41) = 1
    points(42) = 4: points(43) = 6: points(44) = 0
    points(45) = 6: points(46) = 6: points(47) = 0

    mSize = 4: nSize = 4

    ' creates a 3Dmesh in model space
    Set meshObj = ThisDrawing.ModelSpace. _
 Add3DMesh(mSize, nSize, points)

    ' Change the viewing direction of the viewport
    ' to better see the cylinder
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1
    NewDirection(1) = -1
    NewDirection(2) = 1
    ThisDrawing.ActiveViewport.Direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
End Sub


About Creating Polyface Meshes (VBA/ActiveX)

Use the AddPolyfaceMesh method to create a polyface mesh, with each face capable of having numerous vertices.

Creating a polyface mesh is similar to creating a rectangular mesh. To create a polyface mesh, specify coordinates for all its vertices and then define each face by entering vertex numbers for all the vertices of that face. As you create the polyface mesh, you can set specific edges to be invisible, assign them to layers, or give them colors.

To make an edge invisible, enter the vertex number for the edge as a negative value.

Create a polyface mesh

This example creates a PolyfaceMesh object in model space. The viewing direction of the active viewport is updated to display the three-dimensional nature of the mesh more easily.

Sub Ch8_CreatePolyfaceMesh()
    'Define the mesh vertices
    Dim vertex(0 To 17) As Double
    vertex(0) = 4: vertex(1) = 7: vertex(2) = 0
    vertex(3) = 5: vertex(4) = 7: vertex(5) = 0
    vertex(6) = 6: vertex(7) = 7: vertex(8) = 0
    vertex(9) = 4: vertex(10) = 6: vertex(11) = 0
    vertex(12) = 5: vertex(13) = 6: vertex(14) = 0
    vertex(15) = 6: vertex(16) = 6: vertex(17) = 1

    ' Define the face list
    Dim FaceList(0 To 7) As Integer
    FaceList(0) = 1
    FaceList(1) = 2
    FaceList(2) = 5
    FaceList(3) = 4
    FaceList(4) = 2
    FaceList(5) = 3
    FaceList(6) = 6
    FaceList(7) = 5
    ' Create the polyface mesh
    Dim polyfaceMeshObj As AcadPolyfaceMesh
    Set polyfaceMeshObj = ThisDrawing.ModelSpace.AddPolyfaceMesh _
 (vertex, FaceList)

    ' Change the viewing direction of the viewport to
    ' better see the polyface mesh
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1
    NewDirection(1) = -1
    NewDirection(2) = 1
    ThisDrawing.ActiveViewport.direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
End Sub


About Creating Solids (VBA/ActiveX)

A solid object (3DSolid object) represents the entire volume of an object.

Solids are the most informationally complete and least ambiguous of the 3D modeling types. Complex solid shapes are also easier to construct and edit than wireframes and meshes.

You create solids from one of the basic solid shapes of box, cone, cylinder, sphere, torus, and wedge or by extruding a 2D object along a path or revolving a 2D object about an axis. Use one of the following methods to create solids:

  • AddBox
  • AddCone
  • AddCylinder
  • AddEllipticalCone
  • AddEllipticalCylinder
  • AddExtrudedSolid
  • AddExtrudedSolidAlongPath
  • AddRevolvedSolid
  • AddSolid
  • AddSphere
  • AddTorus
  • AddWedge

Like meshes, solids are displayed as wireframes until you hide, shade, or render them. Additionally, you can analyze solids for their mass properties (volume, moments of inertia, center of gravity, and so forth). Use the following properties to analyze solids:

  • MomentOfInertia
  • PrincipalDirections
  • PrincipalMoments
  • ProductOfInertia
  • RadiiOfGyration
  • Volume

The ContourlinesPerSurface property controls the number of tessellation lines used to visualize curved portions of the wireframe. The RenderSmoothness property adjusts the smoothness of shaded and hidden-line objects.

Create a wedge solid

The following example creates a wedge-shaped solid in model space. The viewing direction of the active viewport is updated to display the three-dimensional nature of the wedge more easily.

Sub Ch8_CreateWedge()
    Dim wedgeObj As Acad3DSolid
    Dim center(0 To 2) As Double
    Dim length As Double
    Dim width As Double
    Dim height As Double

    ' Define the wedge
    center(0) = 5#: center(1) = 5#: center(2) = 0
    length = 10#: width = 15#: height = 20#

    ' Create the wedge in model space
    Set wedgeObj = ThisDrawing.ModelSpace. _
 AddWedge(center, length, width, height)

    ' Change the viewing direction of the viewport
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1
    NewDirection(1) = -1
    NewDirection(2) = 1
    ThisDrawing.ActiveViewport.direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    ZoomAll
End Sub


About Editing in 3D (VBA/ActiveX)

This section describes how to edit 3D objects by, for example, rotating, arraying, and mirroring.

Topics in this section

  • About Rotating in 3D (VBA/ActiveX)

    With the Rotate method, you can rotate objects in 2D about a specified point.

  • About Arraying in 3D (VBA/ActiveX)

    With the ArrayRectangular method, you can create a rectangular array in 3D.

  • About Mirroring Objects Along a Plane (VBA/ActiveX)

    With the Mirror3D method, you can mirror objects along a specified mirroring plane specified by three points.


About Rotating in 3D (VBA/ActiveX)

With the Rotate method, you can rotate objects in 2D about a specified point.

The direction of rotation is determined by the WCS. The Rotate3D method rotates objects in 3D about a specified axis. The Rotate3D method takes three values as input: the WCS coordinates of the two points defining the rotation axis and the rotation angle in radians.

To rotate 3D objects, use either the Rotate or Rotate3D method.

Create a 3D box and rotate it about an axis

This example creates a 3D box. It then defines the axis for rotation and finally rotates the box 30 degrees about the axis.

Sub Ch8_Rotate_3DBox()
    Dim boxObj As Acad3DSolid
    Dim length As Double
    Dim width As Double
    Dim height As Double
    Dim center(0 To 2) As Double

    ' Define the box
    center(0) = 5: center(1) = 5: center(2) = 0
    length = 5
    width = 7
    height = 10

    ' Create the box object in model space
    Set boxObj = ThisDrawing.ModelSpace. _
 AddBox(center, length, width, height)

    ' Define the rotation axis with two points
    Dim rotatePt1(0 To 2) As Double
    Dim rotatePt2(0 To 2) As Double
    Dim rotateAngle As Double
    rotatePt1(0) = -3: rotatePt1(1) = 4: rotatePt1(2) = 0
    rotatePt2(0) = -3: rotatePt2(1) = -4: rotatePt2(2) = 0
    rotateAngle = 30
    rotateAngle = rotateAngle * 3.141592 / 180#
    ' Rotate the box
    boxObj.Rotate3D rotatePt1, rotatePt2, rotateAngle
    ZoomAll
End Sub


About Arraying in 3D (VBA/ActiveX)

With the ArrayRectangular method, you can create a rectangular array in 3D.

In addition to specifying the number of columns (X direction) and rows (Y direction), you also specify the number of levels (Z direction).

Create a 3D rectangular array

This example creates a circle and then uses that circle to create a rectangular array of four rows, four columns, and three levels of circles.

Sub Ch8_CreateRectangularArray()
    ' Create the circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 2: center(1) = 2: center(2) = 0
    radius = 0.5
    Set circleObj = ThisDrawing.ModelSpace. _
 AddCircle(center, radius)

    ' Define the rectangular array
    Dim numberOfRows As Long
    Dim numberOfColumns As Long
    Dim numberOfLevels As Long
    Dim distanceBwtnRows As Double
    Dim distanceBwtnColumns As Double
    Dim distanceBwtnLevels As Double
    numberOfRows = 4
    numberOfColumns = 4
    numberOfLevels = 3
    distanceBwtnRows = 1
    distanceBwtnColumns = 1
    distanceBwtnLevels = 4

    ' Create the array of objects
    Dim retObj As Variant
    retObj = circleObj.ArrayRectangular _
        (numberOfRows, numberOfColumns, _
         numberOfLevels, distanceBwtnRows, _
         distanceBwtnColumns, distanceBwtnLevels)
    ZoomAll
End Sub


About Mirroring Objects Along a Plane (VBA/ActiveX)

With the Mirror3D method, you can mirror objects along a specified mirroring plane specified by three points.

Mirror in 3D

This example creates a box in model space. It then mirrors the box about a plane and colors the mirrored box red.

Sub Ch8_MirrorABox3D()
    ' Create the box object
    Dim boxObj As Acad3DSolid
    Dim length As Double
    Dim width As Double
    Dim height As Double
    Dim center(0 To 2) As Double
    center(0) = 5#: center(1) = 5#: center(2) = 0
    length = 5#: width = 7: height = 10#

    ' Create the box (3DSolid) object in model space
    Set boxObj = ThisDrawing.ModelSpace. _
 AddBox(center, length, width, height)

    ' Define the mirroring plane with three points
    Dim mirrorPt1(0 To 2) As Double
    Dim mirrorPt2(0 To 2) As Double
    Dim mirrorPt3(0 To 2) As Double

    mirrorPt1(0) = 1.25: mirrorPt1(1) = 0: mirrorPt1(2) = 0
    mirrorPt2(0) = 1.25: mirrorPt2(1) = 2: mirrorPt2(2) = 0
    mirrorPt3(0) = 1.25: mirrorPt3(1) = 2: mirrorPt3(2) = 2

    ' Mirror the box
    Dim mirrorBoxObj As Acad3DSolid
    Set mirrorBoxObj = boxObj.Mirror3D _
 (mirrorPt1, mirrorPt2, mirrorPt3)
    mirrorBoxObj.Color = acRed
    ZoomAll
End Sub


About Editing 3D Solids (VBA/ActiveX)

Once you have created a solid, you can create more complex shapes by combining solids.

You can join solids, subtract solids from each other, or find the common volume (overlapping portion) of solids. Use the Boolean or CheckInterference method to perform these combinations.

Solids are further modified by obtaining the 2D cross section of a solid or slicing a solid into two pieces. Use the SectionSolid method to find cross sections of solids, and the SliceSolid method for slicing a solid into two pieces.

Find the interference between two solids

This example creates a box and a cylinder in model space. It then finds the interference between the two solids and creates a new solid from that interference. For ease of viewing, the box is colored white, the cylinder is colored cyan, and the interference solid is colored red.

Sub Ch8_FindInterferenceBetweenSolids()
    ' Define the box
    Dim boxObj As Acad3DSolid
    Dim length As Double
    Dim width As Double
    Dim height As Double
    Dim center(0 To 2) As Double
    center(0) = 5: center(1) = 5: center(2) = 0
    length = 5
    width = 7
    height = 10

    ' Create the box object in model space
    ' and color it white
    Set boxObj = ThisDrawing.ModelSpace. _
 AddBox(center, length, width, height)
    boxObj.Color = acWhite

    ' Define the cylinder
    Dim cylinderObj As Acad3DSolid
    Dim cylinderRadius As Double
    Dim cylinderHeight As Double
    center(0) = 0: center(1) = 0: center(2) = 0
    cylinderRadius = 5
    cylinderHeight = 20

    ' Create the Cylinder and
    ' color it cyan
    Set cylinderObj = ThisDrawing.ModelSpace.AddCylinder _
 (center, cylinderRadius, cylinderHeight)
    cylinderObj.Color = acCyan

    ' Find the interference between the two solids
    ' and create a new solid from it. Color the
    ' new solid red.
    Dim solidObj As Acad3DSolid
    Dim bSolidsInterfere As Boolean
    Set solidObj = boxObj.CheckInterference(cylinderObj, True, bSolidsInterfere)
    solidObj.Color = acRed
    ZoomAll
End Sub

Slice a solid into two solids

This example creates a box in model space. It then slices the box based on a plane defined by three points. The slice is returned as a 3DSolid.

Sub Ch8_SliceABox()
    ' Create the box object
    Dim boxObj As Acad3DSolid
    Dim length As Double
    Dim width As Double
    Dim height As Double
    Dim center(0 To 2) As Double
    center(0) = 5#: center(1) = 5#: center(2) = 0
    length = 5#: width = 7: height = 10#

    ' Create the box (3DSolid) object in model space
    Set boxObj = ThisDrawing.ModelSpace. _
 AddBox(center, length, width, height)
    boxObj.Color = acWhite

    ' Define the section plane with three points
    Dim slicePt1(0 To 2) As Double
    Dim slicePt2(0 To 2) As Double
    Dim slicePt3(0 To 2) As Double

    slicePt1(0) = 1.5: slicePt1(1) = 7.5: slicePt1(2) = 0
    slicePt2(0) = 1.5: slicePt2(1) = 7.5: slicePt2(2) = 10
    slicePt3(0) = 8.5: slicePt3(1) = 2.5: slicePt3(2) = 10

    ' slice the box and color the new solid red
    Dim sliceObj As Acad3DSolid
    Set sliceObj = boxObj.SliceSolid _
 (slicePt1, slicePt2, slicePt3, True)
    sliceObj.Color = acRed
    ZoomAll
End Sub


Define Layers and Plot

Topics in this section

  • About Model Space and Paper Space

    Model space and paper space drawing environments are used to place geometry and control the output of your model.

  • About Layouts

    All the geometry of your drawing is contained in layouts.

  • About Viewports

    Viewports control which objects are displayed on screen and when outputting a drawing.

  • About Plotting Your Drawing

    You can plot your drawing as it is viewed in model space, or you can plot one of your prepared paper space layouts.


About Model Space and Paper Space (VBA/ActiveX)

Model space and paper space drawing environments are used to place geometry and control the output of your model.

Model space is the drawing environment in which you create the geometry for your model. Normally, as you begin to draw in model space, you designate your drawing limits to determine the extents of the drawing environment, and you draw in real world units.

Paper space represents the paper representation of your model as it will be plotted. In paper space you can lay out different views of your drawing, scale views independently from one another, and arrange the different views of your drawing as you want them to be plotted. There can be many different paper space representations of your drawing.


About Layouts (VBA/ActiveX)

All the geometry of your drawing is contained in layouts.

Model space geometry is contained on a single layout named Model. You cannot rename the model space layout, nor can you create another model space layout. There can be only one model space layout per drawing.

Paper space geometry is also contained on layouts. You can have many different paper space layouts in your drawing, each representing a different configuration to print. You can change the name of the paper space layouts.

In ActiveX® Automation the ModelSpace collection contains all the geometry in the model space layout. Because there can be more than one paper space layout in a drawing, the PaperSpace collection points to the last active paper space layout.

Topics in this section

  • About Layouts and Blocks (VBA/ActiveX)

    The content of any layout is distributed among two different ActiveX objects: the Layout object and the Block object.

  • About Plot Configurations (VBA/ActiveX)

    A PlotConfiguration object is similar to a Layout object, as both contain identical plot information.

  • About Layout Settings (VBA/ActiveX)

    Layout settings control the final plotted output.


About Layouts and Blocks (VBA/ActiveX)

The content of any layout is distributed among two different ActiveX objects: the Layout object and the Block object.

The Layout object contains the plot settings and the visual properties of the layout as it appears in the AutoCAD user interface. The Block object contains the geometry for the layout.

Each Layout object is associated with one, and only one, Block object. To access the Block object associated with a given layout, use the Block property. Conversely, each Block object is associated with one, and only one, Layout object. To access the Layout object associated with a given Block, use the Layout property for that block.


About Plot Configurations (VBA/ActiveX)

A PlotConfiguration object is similar to a Layout object, as both contain identical plot information.

The difference is that a Layout object is associated with a Block object containing the geometry to plot. A PlotConfiguration object is not associated with a particular Block object. It is simply a named collection of plot settings available for use with any geometry.


About Layout Settings (VBA/ActiveX)

Layout settings control the final plotted output.

These settings affect the paper size, plot scale, plot area, plot origin, and the plot device name. Understanding how to use layout settings ensures that the layout is plotted as expected. All the settings for a layout can be changed from the Layout object properties and methods.

Topics in this section

  • About Paper Size and Units (VBA/ActiveX)

    The choice of paper size depends on the plotter configured for your system.

  • About Adjusting the Plot Origin (VBA/ActiveX)

    The plot origin is the lower-left corner of the specified plotted area and is controlled with the PlotOrigin property.

  • About Setting the Plot Area (VBA/ActiveX)

    When you prepare to plot a layout, you can specify the plot area to determine what will be included in the plot.

  • About Setting the Plot Scale (VBA/ActiveX)

    Generally, you draw objects at their actual size. When you plot the drawing, you can either specify a precise scale or fit the image to the paper.

  • About Setting the Lineweight Scale (VBA/ActiveX)

    Lineweights can be scaled proportionately in a layout with the plot scale.

  • About Setting the Plot Device (VBA/ActiveX)

    The plot device name is specified in the ConfigName property.


About Paper Size and Units (VBA/ActiveX)

The choice of paper size depends on the plotter configured for your system.

Each different plotter will have a standard list of available paper sizes. You can change the paper size for a layout by using the CanonicalMediaName property.

You can also specify the units for your layout using the PaperUnits property. This property takes one of three values: acInches, acMillimeters, or acPixels. If your plotter is configured for raster output, you must specify the output size in pixels.


About Adjusting the Plot Origin (VBA/ActiveX)

The plot origin is the lower-left corner of the specified plotted area and is controlled with the PlotOrigin property.

Typically, the plot origin is set to (0, 0). However, you can center the plot on the sheet of paper by setting the CenterPlot property to TRUE. Centering the plot alters the plot origin.


About Setting the Plot Area (VBA/ActiveX)

When you prepare to plot a layout, you can specify the plot area to determine what will be included in the plot.

To specify the plot area, use the PlotType property. This property requires one of the following values as input:

acDisplay
Prints everything that is in the current model space display. This option is unavailable when plotting from a paper space layout.
acExtents
Prints everything that falls within the boundaries of the currently selected space.
acLimits
Prints everything that is in the limits of the current space.
acView
Prints the view named by the ViewToPlot property.
acWindow
Prints everything in the window specified by the SetWindowToPlot method.
acLayout
Prints everything that falls within the margins of the specified paper size. This option is not available when printing from model space.
NoteWhen you create a new paper space layout, the default option is acLayout.


About Setting the Plot Scale (VBA/ActiveX)

Generally, you draw objects at their actual size. When you plot the drawing, you can either specify a precise scale or fit the image to the paper.

To specify a scale, enter either a standard or custom plot scale.

To enter a standard scale, first set the UseStandardScale property to TRUE. You can then enter the desired scale using the StandardScale property.

To enter a custom scale, first set the UseStandardScale property to FALSE. You can then enter the custom scale using the SetCustomScale method.

When you are reviewing an early draft view, a precise scale is not always important. You can use the acScaleToFit value of the StandardScale property to plot the layout at the largest possible size that fits the paper.


About Setting the Lineweight Scale (VBA/ActiveX)

Lineweights can be scaled proportionately in a layout with the plot scale.

Typically, lineweights specify the linewidth of plotted objects and are plotted with the linewidth size regardless of the plot scale. Most often, you use the default plot scale of 1:1 when plotting a layout. However, if you want to plot an E-size layout that is scaled to fit on an A-size sheet of paper, for example, you can specify lineweights to be scaled in proportion to the new plot scale.

To scale lineweights, set the ScaleLineweights property to TRUE. If you do not want lineweights to be scaled, set this property to FALSE.


About Setting the Plot Device (VBA/ActiveX)

The plot device name is specified in the ConfigName property.

You can set this name to any valid device name for your system. If you do not set this property, plots will be sent to the default device for your system.


About Viewports (VBA/ActiveX)

Viewports control which objects are displayed on screen and when outputting a drawing.

When working in model space you draw geometry in tile viewports (referred to as Viewport objects in ActiveX Automation). You can display one or several different viewports at a time. If several tiled viewports are displayed, editing in one viewport affects all other viewports. However, you can set magnification, viewpoint, grid, and snap settings individually for each viewport.

In paper space, you work in floating paper space viewports (referred to as PViewport objects in ActiveX Automation) to contain different views of your model. Floating viewports are treated as objects you can move, resize, and shape to create a suitable layout. You also can draw objects, such as title blocks or annotations, directly in the paper space view without affecting the model itself.

Topics in this section

  • About Floating Viewports (VBA/ActiveX)

    To access the model in a PViewport object, toggle from paper space to model space using the ActiveSpace property.

  • About Switching to a Paper Space Layout (VBA/ActiveX)

    From model space, you can switch to the last active paper space layout.

  • About Switching to the Model Space Layout (VBA/ActiveX)

    From paper space, you can switch to model space floating viewports or model space tiled viewports.

  • About Creating Paper Space Viewports (VBA/ActiveX)

    Paper space viewports are created with the AddPViewport method.

  • About Changing Viewport Views and Content (VBA/ActiveX)

    The view within a Viewport object can be changed while you are in model space and the viewport is active.

  • About Scaling Views Relative to Paper Space (VBA/ActiveX)

    Before you plot, you can establish accurate zoom scale factors for each section of your drawing.

  • About Scaling Pattern Linetypes in Paper Space (VBA/ActiveX)

    In paper space, you can scale any type of linetype in two ways. The scale can be based on the drawing units of the space in which the object was created (model or paper).

  • About Using Shaded Viewports (VBA/ActiveX)

    If your drawing contains 3D faces, meshes, extruded objects, surfaces, or solids, you can plot from paper space using the As Displayed, Wireframe, Hidden, and Rendered options.


About Floating Viewports (VBA/ActiveX)

To access the model in a PViewport object, toggle from paper space to model space using the ActiveSpace property.

As a result, you can work with the model while keeping the overall layout visible. In PViewport objects, the editing and view-changing capabilities are almost the same as in Viewport objects. However, you have more control over the individual views. For example, you can freeze or turn off layers in some viewports without affecting others. You can turn an entire viewport display on or off. You can also align views between viewports and scale the views relative to the overall layout.

NoteYou cannot edit the model in paper space.

The following illustration shows how different views of a model are displayed in paper space. Each paper space image represents a PViewport object with a different view. In one view, the dimensioning layer is frozen. Notice that the title block, border, and annotation, which are drawn in paper space, do not appear in the Model Space view. Also, the layer containing the viewport borders has been turned off.

When you work in a Viewport object, the ActiveSpace property must always be set to acModelSpace. When you are working in a PViewport object, you can set the ActiveSpace property to either acModelSpace or acPaperSpace, thus allowing you to switch between paper space and model space as needed.

PViewport object, Viewport object, and ActiveSpace property settings

Type of viewport | Status | Usage
PViewport | ActiveSpace = acPaperspace | Arrange the layout by creating floating viewports and adding title block, borders, and annotation. Editing does not affect the model.
PViewport | ActiveSpace = acModelspace | Work within floating viewports to edit the model or change views. You can turn off or freeze layers in individual viewports.
Viewport | ActiveSpace = acModelspace | Split the screen into tiled viewports to edit different views of the model.

In AutoCAD® ActiveX Automation, the ActiveSpace property is used to control the TILEMODE system variable. Setting ThisDrawing.ActiveSpace = acModelSpace is equivalent to setting TILEMODE = on, and setting ThisDrawing.ActiveSpace = acPaperSpace is equivalent to setting TILEMODE = off.

Similarly, the MSpace property is the equivalent of both the MSPACE and PSPACE commands in AutoCAD. Setting ThisDrawing.MSpace = TRUE is the same as using the MSPACE command: it switches to model space. Setting ThisDrawing.MSpace = FALSE is the same as using the PSPACE command: it switches to paper space.

In addition, you are required to use the Display method before setting the MSpace property to TRUE. The Display method initializes certain graphic settings that must be set before switching to model space. In AutoCAD this is done “behind the scenes.” However, in the ActiveX Automation interface, the programmer must take care of this initialization.

NoteRemember, you must turn on the display using the Display method for at least one PViewport object before you can set the MSpace property to TRUE. Failure to turn on the display will result in an error being returned when you try to set the MSpace property.


About Switching to a Paper Space Layout (VBA/ActiveX)

From model space, you can switch to the last active paper space layout.

Topics in this section

  • To switch to the last active paper space layout (VBA/ActiveX)

    You can switch between model space and paper space.


About Switching to a Paper Space Layout (VBA/ActiveX)
About Switching to a Paper Space Layout (VBA/ActiveX)
About Switching to the Model Space Layout (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Define Layers and Plot > About Viewports (VBA/ActiveX) > About Switching to a Paper Space Layout (VBA/ActiveX) >

To switch to the last active paper space layout (VBA/ActiveX)

You can switch between model space and paper space.

  1. Set the ActiveSpace property to acPaperSpace.
    ThisDrawing.ActiveSpace = acPaperSpace
  2. Toggle the MSpace property to FALSE.
    ThisDrawing.MSpace = FALSE

When you are in paper space, AutoCAD displays the paper space user coordinate system (UCS) icon in the lower-left corner of the graphics area. The crosshairs indicate that the paper space layout area (not the views in the viewports) can be edited.


About Switching to the Model Space Layout (VBA/ActiveX)

From paper space, you can switch to model space floating viewports or model space tiled viewports.

Topics in this section

  • To switch to floating viewports (VBA/ActiveX)

    You can switch from paper space to model space in a floating viewport on a layout.

  • To switch to tiled viewports (VBA/ActiveX)

    Model space can be divided into multiple tiled viewports.


About Switching to the Model Space Layout (VBA/ActiveX)
About Switching to the Model Space Layout (VBA/ActiveX)
To switch to tiled viewports (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Define Layers and Plot > About Viewports (VBA/ActiveX) > About Switching to the Model Space Layout (VBA/ActiveX) >

To switch to floating viewports (VBA/ActiveX)

You can switch from paper space to model space in a floating viewport on a layout.

  1. Use the Display method to initialize graphic settings.
    ThisDrawing.ActivePViewport.Display TRUE
  2. Toggle the MSpace property to TRUE.
    ThisDrawing.MSpace = TRUE

    This will place you in model space, floating viewports.

    NoteYou must create floating viewports before you attempt to switch to model space.


To switch to floating viewports (VBA/ActiveX)
About Switching to the Model Space Layout (VBA/ActiveX)
About Creating Paper Space Viewports (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Define Layers and Plot > About Viewports (VBA/ActiveX) > About Switching to the Model Space Layout (VBA/ActiveX) >

To switch to tiled viewports (VBA/ActiveX)

Model space can be divided into multiple tiled viewports.

  • Set the ActiveSpace property to acModelSpace.
    ThisDrawing.ActiveSpace = acModelSpace


About Creating Paper Space Viewports (VBA/ActiveX)

Paper space viewports are created with the AddPViewport method.

The AddPViewport method requires a center point and the width and height of the new viewport. Before creating the viewport, use the ActiveSpace property to set paper space as the current space (normally done by setting TILEMODE to 0).

After creating the PViewport object, you can set properties of the view itself, such as viewing direction (Direction property), lens length for perspective views (LensLength property), and grid display (GridOn property). You can also control properties of the viewport itself, such as layer (Layer property), linetype (Linetype property), and linetype scaling (LinetypeScale property).

Create and enable a floating viewport

This example switches AutoCAD to paper space, creates a floating viewport, sets the view, and enables the viewport.

Sub Ch9_SwitchToPaperSpace()
   ' Set the active space to paper space
    ThisDrawing.ActiveSpace = acPaperSpace

   ' Create the paperspace viewport
    Dim newVport As AcadPViewport
    Dim center(0 To 2) As Double
    center(0) = 3.25
    center(1) = 3
    center(2) = 0
    Set newVport = ThisDrawing.PaperSpace. _
 AddPViewport(center, 6, 5)

   ' Change the view direction for the viewport
    Dim viewDir(0 To 2) As Double
    viewDir(0) = 1
    viewDir(1) = 1
    viewDir(2) = 1
    newVport.Direction = viewDir

   ' Enable the viewport
    newVport.Display True

   ' Switch to model space
    ThisDrawing.MSpace = True

   ' Set newVport current
   ' (not always necessary but a good idea)
    ThisDrawing.ActivePViewport = newVport

   ' Zoom Extents in model space
    ZoomExtents

   ' Turn model space editing off
    ThisDrawing.MSpace = False

    ' ZoomExtents in paperspace
    ZoomExtents
End Sub

The order of steps in the preceding code is important. In general, things must be done in the same order they would be done at the AutoCAD command line. The only unexpected actions involve defining the view and enabling the viewport.

NoteTo set or modify aspects of the view (view direction, lens length, and so forth), the Viewport object's Display method must be set to off (FALSE), and before you can set a viewport current the Display method must be set to on (TRUE).

Create four floating viewports

This example takes the example from "Create and enable a floating viewport" and continues it by creating four floating viewports and setting the view of each to top, front, right, and isometric views, respectively. Each view is scaled to half the scale of paper space. To ensure there is something to see in these viewports, you may want to create a 3D solid sphere before trying this example.

Sub Ch9_FourPViewports()
    Dim topVport, frontVport As AcadPViewport
    Dim rightVport, isoVport As AcadPViewport
    Dim pt(0 To 2) As Double
    Dim viewDir(0 To 2) As Double
    ThisDrawing.ActiveSpace = acPaperSpace
    ThisDrawing.MSpace = True
' Take the existing PViewport and make it the topVport
    pt(0) = 2.5: pt(1) = 5.5: pt(2) = 0
    Set topVport = ThisDrawing.ActivePViewport
    'No need to set Direction for top view
    topVport.center = pt
    topVport.width = 2.5
    topVport.height = 2.5
    topVport.Display True
    ThisDrawing.MSpace = True
    ThisDrawing.ActivePViewport = topVport
    ZoomExtents
    ZoomScaled 0.5, acZoomScaledRelativePSpace
'Create and setup frontVport
    pt(0) = 2.5: pt(1) = 2.5: pt(2) = 0
    Set frontVport = ThisDrawing.PaperSpace. _
 AddPViewport(pt, 2.5, 2.5)
    viewDir(0) = 0: viewDir(1) = 1: viewDir(2) = 0
    frontVport.direction = viewDir
    frontVport.Display acOn
    ThisDrawing.MSpace = True
    ThisDrawing.ActivePViewport = frontVport
    ZoomExtents
    ZoomScaled 0.5, acZoomScaledRelativePSpace
'Create and setup rightVport
    pt(0) = 5.5: pt(1) = 5.5: pt(2) = 0
    Set rightVport = ThisDrawing.PaperSpace. _
 AddPViewport(pt, 2.5, 2.5)
    viewDir(0) = 1: viewDir(1) = 0: viewDir(2) = 0
    rightVport.direction = viewDir
    rightVport.Display acOn
    ThisDrawing.MSpace = True
    ThisDrawing.ActivePViewport = rightVport
    ZoomExtents
    ZoomScaled 0.5, acZoomScaledRelativePSpace
'Create and set up isoVport
    pt(0) = 5.5: pt(1) = 2.5: pt(2) = 0
    Set isoVport = ThisDrawing.PaperSpace. _
 AddPViewport(pt, 2.5, 2.5)
    viewDir(0) = 1: viewDir(1) = 1: viewDir(2) = 1
    isoVport.direction = viewDir
    isoVport.Display acOn
    ThisDrawing.MSpace = True
    ThisDrawing.ActivePViewport = isoVport
    ZoomExtents
    ZoomScaled 0.5, acZoomScaledRelativePSpace
'Finish: Perform a regen in all viewports
    ThisDrawing.Regen True
End Sub


About Changing Viewport Views and Content (VBA/ActiveX)

The view within a Viewport object can be changed while you are in model space and the viewport is active.

Topics in this section

  • To edit a drawing in a floating viewport (VBA/ActiveX)

    The geometry displayed within a floating viewport can be modified by accessing model space.


About Changing Viewport Views and Content (VBA/ActiveX)
About Changing Viewport Views and Content (VBA/ActiveX)
About Scaling Views Relative to Paper Space (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Define Layers and Plot > About Viewports (VBA/ActiveX) > About Changing Viewport Views and Content (VBA/ActiveX) >

To edit a drawing in a floating viewport (VBA/ActiveX)

The geometry displayed within a floating viewport can be modified by accessing model space.

  1. In model space, make the viewport active by setting the ActiveViewport property.
    Thisdrawing.ActiveViewport = MyViewportObject
  2. Edit the drawing.

You can also create objects such as annotations, dimensions, and title blocks in paper space. You must, however, set the ActiveSpace property to FALSE, and turn paper space on using the MSpace property. Objects created in paper space are visible only in paper space.


About Scaling Views Relative to Paper Space (VBA/ActiveX)

Before you plot, you can establish accurate zoom scale factors for each section of your drawing.

Scaling views relative to paper space establishes a consistent scale for each displayed view. For example, the following illustration shows a paper space view with several viewports—each set to different scales and views. To scale the plotted drawing accurately, you must scale each view relative to paper space, not relative to the previous view or to the full-scale model.

When you work in paper space, the scale factor represents a ratio between the size of the plotted drawing and the actual size of the model displayed in the viewports. To derive this scale, divide paper space units by model space units. For a quarter-scale drawing, for example, you specify a scale factor of one paper space unit to four model space units (1:4).

Use the ZoomScaled method to scale viewports relative to paper space units. This method takes three values as input: the viewport to scale, the scale factor, and how you want that scale factor applied. The third value is optional and determines how the scale is applied:

  • Relative to the drawing limits
  • Relative to the current view
  • Relative to paper space units

To specify the scale relative to paper space units, enter the acZoomScaled-RelativePSpace constant for this value.

As shown in the illustrations, if you enter a scale of 2 relative to the paper space units, the scale in the viewport increases to twice the size of the paper space units. A scale of .5 relative to the paper space units sets the scale to half the size of the paper space units. The model is plotted at half its actual size.


About Scaling Pattern Linetypes in Paper Space (VBA/ActiveX)

In paper space, you can scale any type of linetype in two ways. The scale can be based on the drawing units of the space in which the object was created (model or paper).

The linetype scale also can be a uniform scale based on paper space units. You can use the PSLTSCALE system variable to maintain the same linetype scaling for objects displayed at different zoom scales in different viewports. It also affects the line display in 3D views.

In the following illustration, the pattern linetype of the lines in model space is scaled uniformly in paper space by the PSLTSCALE system variable. Notice that the linetype in the two viewports has the same scale, even though the objects have different zoom scales.

Use the SetVariable method to set the value of the PSLTSCALE system variable.


About Using Shaded Viewports (VBA/ActiveX)

If your drawing contains 3D faces, meshes, extruded objects, surfaces, or solids, you can plot from paper space using the As Displayed, Wireframe, Hidden, and Rendered options.

Shaded and rendered viewports are plot-previewed, plotted, and plotted to file with full shading and rendering.

To set an option for shaded viewport plotting in paper space, use the ShadePlot property of the PViewport object.

NoteTo hide lines in plots of model space viewports (Viewport objects) use the PlotHidden property of the Layout object. This property takes a Boolean value: TRUE to remove hidden lines, FALSE to draw them.


About Plotting Your Drawing (VBA/ActiveX)

You can plot your drawing as it is viewed in model space, or you can plot one of your prepared paper space layouts.

Plotting from model space is often preferable when you want to view or verify your drawing prior to creating a paper space layout. Once your model is ready, you can prepare and plot a paper space layout.

NoteThe BACKGROUNDPLOT system variable must be set to 0 before a script can plot multiple jobs.

Plotting involves working with two ActiveX Automation objects: the Layout object and the Plot object. The Layout object contains the plot settings for a given layout. The Plot object contains the methods and properties that initiate and monitor a plotting sequence.

Perform Basic Plotting

From the Plot object, you can use the following methods and properties:

PlotToFile
Plots to a file.
PlotToDevice
Plots to a plotter or printer.
DisplayPlotPreview
Displays a preview of the specified plot.
QuietErrorMode
Toggles the quiet error mode for plot error reporting.

Topics in this section

  • About Plotting from Model Space and Paper Space (VBA/ActiveX)

    Typically, when you plot a large drawing such as a floorplan, you can specify a scale to convert the real drawing units into plotted inches or millimeters.


About Plotting from Model Space and Paper Space (VBA/ActiveX)

Typically, when you plot a large drawing such as a floorplan, you can specify a scale to convert the real drawing units into plotted inches or millimeters.

However, when you plot from model space, the defaults that are used if there are no settings specified include plot to system printer, plot the current display, scaled to fit, 0 rotation, and 0,0 offset. To modify the plot settings, change the properties on the Layout object associated with model space.

Plot the extents of an active model space layout

This example first checks to make sure the active space is model space. The example then establishes several plot settings. Finally, the plot is sent using the PlotToDevice method.

Sub Ch9_PrintModelSpace()
    ' Verify that the active space is model space
    If ThisDrawing.ActiveSpace = acPaperSpace Then
        ThisDrawing.MSpace = True
        ThisDrawing.ActiveSpace = acModelSpace
    End If

    ' Set the extents and scale of the plot area
    ThisDrawing.ModelSpace.Layout.PlotType = acExtents
    ThisDrawing.ModelSpace.Layout. _
 StandardScale = acScaleToFit

    ' Set the number of copies to one
    ThisDrawing.Plot.NumberOfCopies = 1

    ' Initiate the plot
    ThisDrawing.Plot.PlotToDevice
End Sub

The device name can be specified using the ConfigName property. This device can be overridden in the PlotToDevice method by specifying a PC3 file.

Plot from Paper Space

You can plot a paper space layout. You can plot the active layout, as demonstrated in the previous section, or you can specify by name the layout to plot.


Advanced Drawing and Organizational Techniques

Topics in this section

  • About Working with Raster Images

    With AutoCAD, you can add raster images to your vector-based AutoCAD drawings, and then view and plot the resulting file.

  • About Using Blocks and Attributes

    AutoCAD provides several features to help you manage objects in your drawings. With blocks you can organize and manipulate many objects as one component.

  • About Using External References

    An external reference (xref) links another drawing to the current drawing.

  • About Assigning and Retrieving Extended Data

    You can use extended data (xdata) as a means for linking information with objects in a drawing.


About Working with Raster Images (VBA/ActiveX)

With AutoCAD®, you can add raster images to your vector-based AutoCAD drawings, and then view and plot the resulting file.

Topics in this section

  • About Attaching and Scaling a Raster Image (VBA/ActiveX)

    Images can be placed in a drawing file, but they are not actually part of the file. The image is linked to the drawing file through a path name or a data management document ID.

  • About Manage Raster Images (VBA/ActiveX)

    You can manage raster image name, file name, and file path using the properties of the Raster object.

  • About Modifying Images and Image Boundaries (VBA/ActiveX)

    After an image has been attached to a drawing, you can modify the raster image's properties and its boundary.

  • About Clipping Images (VBA/ActiveX)

    You can define a region of an image for display and plotting by clipping the image.


About Attaching and Scaling a Raster Image (VBA/ActiveX)

Images can be placed in a drawing file, but they are not actually part of the file. The image is linked to the drawing file through a path name or a data management document ID.

Linked image paths can be changed or removed at any time. To attach an image, you create a Raster object in your drawing using the AddRaster method. This method takes four values as input: the name of the image file to attach, the insertion point in the drawing to place the image, the scale factor of the image, and the rotation angle of the image. Remember, the Raster object represents an independent link to the image, not the image itself.

Once you have attached an image, you can reattach it many times, creating a new Raster object for each attachment. Each attachment has its own clip boundary and its own settings for brightness, contrast, fade, and transparency. A single image can be cut into multiple pieces and rearranged independently in your drawing.

You can set the raster image scale factor when you create the Raster object so that the image's geometry scale matches the scale of the geometry created in the AutoCAD drawing. When you select an image to attach, the image is inserted at a scale factor of 1 image unit of measurement to 1 AutoCAD unit of measurement. To set the image scale factor, you need to know the scale of the geometry on the image, and you need to know what unit of measurement (inches, feet, and so forth) you want to use to define 1 AutoCAD unit. The image file must contain resolution information defining the DPI, or dots per inch, and number of pixels in the image.

If an image has resolution information, AutoCAD combines it with the scale factor and the AutoCAD unit of measurement you supply to scale the image in your drawing. For example, if your raster image is a scanned blueprint on which the scale is 1 inch equals 50 feet, or 1:600, and your AutoCAD drawing is set up so that 1 unit represents 1 inch, then to set the scale factor of the image, you enter 600 for the ScaleFactor parameter of the AddRaster method. AutoCAD then inserts the image at a scale that brings the geometry in the image into alignment with the vector geometry in the drawing.

NoteIf no resolution information is defined with the attached image file, AutoCAD calculates the image's original width as one unit. After insertion, the image width in AutoCAD units is equal to the scale factor.

Attach a Raster Image

This example adds a raster image in model space. This example uses a file named watch.jpg. Replace the name and location of the image assigned to the imageName variable in the code with one that is available on your workstation.

Sub Ch10_AttachingARaster()
  Dim insertionPoint(0 To 2) As Double
  Dim scalefactor As Double
  Dim rotationAngle As Double
  Dim imageName As String
  Dim rasterObj As AcadRasterImage
  imageName = "C:/Program Files/AutoCAD Directory/sample/watch.jpg'
  insertionPoint(0) = 5
  insertionPoint(1) = 5
  insertionPoint(2) = 0
  scalefactor = 2
  rotationAngle = 0

  On Error GoTo ERRORHANDLER
  ' Attach the raster image in model space
  Set rasterObj = ThisDrawing.ModelSpace.AddRaster(imageName, insertionPoint, scalefactor, rotationAngle)
  ZoomAll
  Exit Sub

ERRORHANDLER:
  MsgBox Err.Description
End Sub


About Attaching and Scaling a Raster Image (VBA/ActiveX)
About Working with Raster Images (VBA/ActiveX)
About Modifying Images and Image Boundaries (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) >

About Manage Raster Images (VBA/ActiveX)

You can manage raster image name, file name, and file path using the properties of the Raster object.

Change Image File Paths

The path and file name of an image is queried or changed using the ImageFile property. The path set by this property is the actual path where AutoCAD looks for the image.

If AutoCAD cannot locate the drawing (for example, if you have moved the file to a different directory than the one saved with the ImageFile property), it removes relative or absolute path information from the name (for example, \images\tree.tga or c:\my project\images\tree.tga becomes tree.tga) and searches the paths you have defined using the SetProjectFilePath method on the Preferences object. If the drawing is not located in the paths, it attempts the first search path again.

You can remove the path from the file name or specify a relative path by resetting the ImageFile property.

Changing the path in the ImageFile property does not affect the project files' search-path settings.

Image Names

Image names are not necessarily the same as image file names. When you attach an image to a drawing, AutoCAD uses the file name without the file extension as the image name. You can change the image name without affecting the name of the file.

The image file is represented by the ImageFile property on the Raster object. Changing the ImageFile property will change the image in the drawing. The image name is represented by the Name property, and changing the Name property will change the name of the image only, not the file associated with it.


About Modifying Images and Image Boundaries (VBA/ActiveX)

After an image has been attached to a drawing, you can modify the raster image's properties and its boundary.

All images have an image boundary. When you attach an image to a drawing, the image boundary inherits the current property settings, including color, layer, linetype, and linetype scale. If the image is a bitonal image, the image color and boundary color are the same.

As with other AutoCAD objects, you can modify images and their boundary properties. For example, you can:

  • Display or hide the image boundary
  • Modify the image layer, boundary color, and linetype
  • Change the image location
  • Scale, rotate, and change the width and height of the image
  • Toggle the image visibility
  • Change the image transparency
  • Change the image brightness, contrast, and fade
  • Change the quality and speed of image display

Topics in this section

  • About Showing and Hiding Image Boundaries (VBA/ActiveX)

    Hiding an image boundary ensures that the image cannot accidentally be moved or modified and prevents the boundary from being plotted or displayed.

  • About Changing the Layer, Boundary Color, and Boundary Linetype for an Image (VBA/ActiveX)

    The Layer, Color, and Linetype properties affect the appearance of a Raster object's boundary.

  • About Changing the Scale, Rotation, Location, Width, and Height for an Image (VBA/ActiveX)

    The Scale, Rotation, Location, Width, and Height properties affect the appearance of a Raster object.

  • About Changing the Visibility of an Image (VBA/ActiveX)

    Image visibility affects the redraw speed by hiding images in the current drawing session.

  • About Modifying Bitonal Image Color and Transparency (VBA/ActiveX)

    Bitonal raster images are images consisting only of a foreground color and a background color.

  • About Adjusting Image Brightness, Contrast, and Fade (VBA/ActiveX)

    You can adjust image brightness, contrast, and fade in AutoCAD to the display of the image and to plotted output without affecting the original raster image file.


About Modifying Images and Image Boundaries (VBA/ActiveX)
About Modifying Images and Image Boundaries (VBA/ActiveX)
About Changing the Layer, Boundary Color, and Boundary Linetype for an Image (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) > About Modifying Images and Image Boundaries (VBA/ActiveX) >

About Showing and Hiding Image Boundaries (VBA/ActiveX)

Hiding an image boundary ensures that the image cannot accidentally be moved or modified and prevents the boundary from being plotted or displayed.

When image boundaries are hidden, clipped images are still displayed to their specified boundary limits; only the boundary is affected. Showing and hiding image boundaries affects all images attached to your drawing.

To show or hide the image boundaries, use the ClippingEnabled property.

NoteThis property affects only the image boundary. To see a change in the image when toggling this property, look closely at the small boundary surrounding the image.


About Showing and Hiding Image Boundaries (VBA/ActiveX)
About Modifying Images and Image Boundaries (VBA/ActiveX)
About Changing the Scale, Rotation, Location, Width, and Height for an Image (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) > About Modifying Images and Image Boundaries (VBA/ActiveX) >

About Changing the Layer, Boundary Color, and Boundary Linetype for an Image (VBA/ActiveX)

The Layer, Color, and Linetype properties affect the appearance of a Raster object's boundary.

You can change the color and linetype of image boundaries and the layer of an image using the following properties

Layer
Specifies the layer for the image
Color
Specifies the color of the image boundary
Linetype
Specifies the linetype of the image


About Changing the Layer, Boundary Color, and Boundary Linetype for an Image (VBA/ActiveX)
About Modifying Images and Image Boundaries (VBA/ActiveX)
About Changing the Visibility of an Image (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) > About Modifying Images and Image Boundaries (VBA/ActiveX) >

About Changing the Scale, Rotation, Location, Width, and Height for an Image (VBA/ActiveX)

The Scale, Rotation, Location, Width, and Height properties affect the appearance of a Raster object.

You can change the scale, rotation, location, width, and height of an image using the following methods and properties:

ScaleEntity
Scales the image
Rotate
Rotates the image
Origin
Specifies the image location
Width
Specifies the width of the image in pixels
Height
Specifies the height of the image in pixels
ImageWidth
Specifies the width of the image in database units
ImageHeight
Specifies the height of the image in database units
ShowRotation
Determines if the raster is displayed as rotated


About Changing the Scale, Rotation, Location, Width, and Height for an Image (VBA/ActiveX)
About Modifying Images and Image Boundaries (VBA/ActiveX)
About Modifying Bitonal Image Color and Transparency (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) > About Modifying Images and Image Boundaries (VBA/ActiveX) >

About Changing the Visibility of an Image (VBA/ActiveX)

Image visibility affects the redraw speed by hiding images in the current drawing session.

Hidden images are not displayed or plotted; only the drawing boundary is displayed. To hide images, set the ImageVisibility property to FALSE. To redisplay the images, set the ImageVisibility property to TRUE.


About Changing the Visibility of an Image (VBA/ActiveX)
About Modifying Images and Image Boundaries (VBA/ActiveX)
About Adjusting Image Brightness, Contrast, and Fade (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) > About Modifying Images and Image Boundaries (VBA/ActiveX) >

About Modifying Bitonal Image Color and Transparency (VBA/ActiveX)

Bitonal raster images are images consisting only of a foreground color and a background color.

When you attach a bitonal image, the foreground pixels in the image inherit the current layer settings for color. In addition to the modifications you can make to any attached image, you can modify bitonal images by changing the foreground color and by turning the transparency of the background on and off.

NoteBitonal images and bitonal image boundaries are always the same color.

To change the foreground color of a bitonal image, use the Color property. To turn the transparency on and off, use the Transparency property.


About Modifying Bitonal Image Color and Transparency (VBA/ActiveX)
About Modifying Images and Image Boundaries (VBA/ActiveX)
About Clipping Images (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) > About Modifying Images and Image Boundaries (VBA/ActiveX) >

About Adjusting Image Brightness, Contrast, and Fade (VBA/ActiveX)

You can adjust image brightness, contrast, and fade in AutoCAD to the display of the image and to plotted output without affecting the original raster image file.

Use the following properties to adjust brightness, contrast, and fade:

Brightness
Specifies the brightness level of an image
Contrast
Specifies the contrast level of an image
Fade
Specifies the fade level of an image


About Adjusting Image Brightness, Contrast, and Fade (VBA/ActiveX)
About Working with Raster Images (VBA/ActiveX)
About Showing and Hiding the Clipping Boundary (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) >

About Clipping Images (VBA/ActiveX)

You can define a region of an image for display and plotting by clipping the image.

The clipping boundary must be a 2D polygon or rectangle with vertices constrained to lie within the boundaries of the image. Multiple instances of the same image can have different boundaries.

Topics in this section

  • About Showing and Hiding the Clipping Boundary (VBA/ActiveX)

    You can display a clipped image using the clipping boundary, or you can hide the clipping boundary and display the original image boundaries.

  • To Clip an Image (VBA/ActiveX)

    Clipping an image limits how much of an image is displayed.


About Showing and Hiding the Clipping Boundary (VBA/ActiveX)

You can display a clipped image using the clipping boundary, or you can hide the clipping boundary and display the original image boundaries.

To hide a clipping boundary and display the original image, set the ClippingEnabled property to FALSE. To display the clipped image, set the ClippingEnabled property to TRUE.

Clip a raster image boundary

This example adds a raster image in model space. It then clips the image based on a clip boundary. This example uses the downtown.jpg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the imageName variable.

Sub Ch10_ClippingRasterBoundary()
 Dim insertionPoint(0 To 2) As Double
 Dim scalefactor As Double
 Dim rotationAngle As Double
 Dim imageName As String
 Dim rasterObj As AcadRasterImage

 imageName = "C:\AutoCAD\sample\downtown.jpg"
 insertionPoint(0) = 5
 insertionPoint(1) = 5
 insertionPoint(2) = 0
 scalefactor = 2
 rotationAngle = 0

 On Error GoTo ERRORHANDLER
 ' Creates a raster image in model space
 Set rasterObj = ThisDrawing.ModelSpace.AddRaster _
 (imageName, insertionPoint, _
 scalefactor, rotationAngle)
 ZoomAll
 ' Establish the clip boundary with an array of points
 Dim clipPoints(0 To 9) As Double
 clipPoints(0) = 6: clipPoints(1) = 6.75
 clipPoints(2) = 7: clipPoints(3) = 6
 clipPoints(4) = 6: clipPoints(5) = 5
 clipPoints(6) = 5: clipPoints(7) = 6
 clipPoints(8) = 6: clipPoints(9) = 6.75

 ' Clip the image
 rasterObj.ClipBoundary clipPoints

 ' Enable the display of the clip
 rasterObj.ClippingEnabled = True
 ThisDrawing.Regen acActiveViewport
 Exit Sub

ERRORHANDLER:
 MsgBox Err.Description
End Sub


About Showing and Hiding the Clipping Boundary (VBA/ActiveX)
About Clipping Images (VBA/ActiveX)
About Using Blocks and Attributes (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Working with Raster Images (VBA/ActiveX) > About Clipping Images (VBA/ActiveX) >

To Clip an Image (VBA/ActiveX)

Clipping an image limits how much of an image is displayed.

  1. Turn on the image boundaries using the ClippingEnabled property.
  2. Specify the clipping boundary and perform the clip using the ClipBoundary method. This method takes one value as input: a variant array of 2D world coordinate system coordinates specifying the clipping boundary of a raster image.


About Using Blocks and Attributes (VBA/ActiveX)

AutoCAD provides several features to help you manage objects in your drawings. With blocks you can organize and manipulate many objects as one component.

Attributes associate items of information with the blocks in your drawings—for example, part numbers and prices.

Using AutoCAD external references, or xrefs, you can attach or overlay entire drawings to your current drawing. When you open your current drawing, any changes made in the referenced drawing appear in the current drawing.

Topics in this section

  • About Working with Blocks (VBA/ActiveX)

    A block is a collection of objects you can associate together to form a single object, or a block reference.

  • About Working with Attributes (VBA/ActiveX)

    An attribute reference provides an interactive label or tag for you to attach text to a block. Examples of data are part numbers, prices, comments, and owners' names.


About Working with Blocks (VBA/ActiveX)

A block is a collection of objects you can associate together to form a single object, or a block reference.

You can insert, scale, and rotate a block reference in a drawing. You can explode a block reference into its component objects, modify them, and redefine the block. AutoCAD updates all future instances of that block reference based on the definition of the block.

Blocks can be defined from objects originally drawn on different layers with different colors and linetypes. You can preserve the layer, color, and linetype information of objects in a block. Then, each time you insert the block, you have each object within the block drawn on its original layer with its original color and linetype.

Topics in this section

  • About Defining Blocks (VBA/ActiveX)

    To create a new block, use the Add method.

  • About Inserting Blocks (VBA/ActiveX)

    You can insert blocks or entire drawings into the current drawing with the InsertBlock method.

  • About Exploding a Block Reference (VBA/ActiveX)

    Use the Explode method to break a block reference.

  • About Redefining a Block (VBA/ActiveX)

    Use any of the Block object methods and properties to redefine a block.


About Working with Blocks (VBA/ActiveX)
About Working with Blocks (VBA/ActiveX)
About Inserting Blocks (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) > About Working with Blocks (VBA/ActiveX) >

About Defining Blocks (VBA/ActiveX)

To create a new block, use the Add method.

This method requires two values as input: the location in the drawing where the block is added and the name of the block to create.

Once created, you can add any geometrical object, or another block, to the newly created block. You can then insert an instance of the block into the drawing. An inserted block is an object called a block reference.

You can also create a block by using the WBlock method to group objects in a separate drawing file. The drawing file can then be used as a block definition for other drawings. AutoCAD considers any drawing you insert into another drawing to be a block.


About Defining Blocks (VBA/ActiveX)
About Working with Blocks (VBA/ActiveX)
About Exploding a Block Reference (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) > About Working with Blocks (VBA/ActiveX) >

About Inserting Blocks (VBA/ActiveX)

You can insert blocks or entire drawings into the current drawing with the InsertBlock method.

The InsertBlock method takes six values as input: the insertion point, the name of the block or drawing to insert, the X-scale factor, the Y-scale factor, the Z-scale factor, and the rotation angle.

When you insert an entire drawing into another drawing, AutoCAD treats the inserted drawing like any other block reference. Subsequent insertions reference the block definition (which contains the geometric description of the block) with different position, scale, and rotation settings. If you change the original drawing after inserting it, the changes have no effect on the inserted block. If you want the inserted block to reflect the changes you made to the original drawing, you can redefine the block by reinserting the original drawing. This can be done with the InsertBlock method.

If you insert a drawing as a block, the file name is automatically used as the name of the block. You can change the name of the block by using the Name property once the block has been created.

By default, AutoCAD uses the coordinate (0, 0, 0) as the base point for inserted drawings. You can change the base point of a drawing by opening the original drawing and using the SetVariable method to specify a different insertion base point for the INSBASE system variable. AutoCAD uses the new base point the next time you insert the drawing.

If the drawing you insert contains PaperSpace objects, those objects are not included in the current drawing's block definition. To use the PaperSpace objects in another drawing, open the original drawing and use the Add method to define the PaperSpace objects as a block. You can insert the drawing into another drawing in either paper space or model space.

A block reference cannot be iterated to find the original objects that compose it. However, you can iterate the original block definition, or you can explode the block reference into its original components.

You can also insert an array of blocks using the AddMInsertBlock method. This method does not insert a single block into your drawing, as the InsertBlock does, but instead inserts an array of the specified block. This method returns an MInsertBlock object.

Define a block and insert the block into a drawing

This example defines a block and adds a circle to the block definition. It then inserts the block into the drawing as a block reference.

Sub Ch10_InsertingABlock()
 ' Define the block
 Dim blockObj As AcadBlock
 Dim insertionPnt(0 To 2) As Double
 insertionPnt(0) = 0
 insertionPnt(1) = 0
 insertionPnt(2) = 0
 Set blockObj = ThisDrawing.Blocks.Add _
 (insertionPnt, "CircleBlock")

 ' Add a circle to the block
 Dim circleObj As AcadCircle
 Dim center(0 To 2) As Double
 Dim radius As Double
 center(0) = 0
 center(1) = 0
 center(2) = 0
 radius = 1
 Set circleObj = blockObj.AddCircle(center, radius)

 ' Insert the block
 Dim blockRefObj As AcadBlockReference
 insertionPnt(0) = 2
 insertionPnt(1) = 2
 insertionPnt(2) = 0
 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
 (insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
 ZoomAll
 MsgBox "The circle belongs to " & blockRefObj.ObjectName
End Sub
NoteAfter insertion, the external file's WCS is aligned parallel to the XY plane of the current user coordinate system (UCS) in the current drawing. Thus, a block from an external file is inserted at any orientation in space by setting the UCS before inserting it.


About Inserting Blocks (VBA/ActiveX)
About Working with Blocks (VBA/ActiveX)
About Redefining a Block (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) > About Working with Blocks (VBA/ActiveX) >

About Exploding a Block Reference (VBA/ActiveX)

Use the Explode method to break a block reference.

By exploding a block reference, you can modify the block or add to or delete the objects that define it.

Display the results of an exploded block reference

This example creates a block and adds a circle to the definition of the block. The block is then inserted into the drawing as a block reference. The block reference is then exploded, and the objects resulting from the explode process are displayed along with their object types.

Sub Ch10_ExplodingABlock()
 ' Define the block
 Dim blockObj As AcadBlock
 Dim insertionPnt(0 To 2) As Double
 insertionPnt(0) = 0
 insertionPnt(1) = 0
 insertionPnt(2) = 0
 Set blockObj = ThisDrawing.Blocks.Add _
 (insertionPnt, "CircleBlock")

 ' Add a circle to the block
 Dim circleObj As AcadCircle
 Dim center(0 To 2) As Double
 Dim radius As Double
 center(0) = 0
 center(1) = 0
 center(2) = 0
 radius = 1
 Set circleObj = blockObj.AddCircle(center, radius)

 ' Insert the block
 Dim blockRefObj As AcadBlockReference
 insertionPnt(0) = 2
 insertionPnt(1) = 2
 insertionPnt(2) = 0
 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
 (insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
 ZoomAll
 MsgBox "The circle belongs to " & blockRefObj.ObjectName

 ' Explode the block reference
 Dim explodedObjects As Variant
 explodedObjects = blockRefObj.Explode

 ' Loop through the exploded objects
 Dim I As Integer
 For I = 0 To UBound(explodedObjects)
 explodedObjects(I).Color = acRed
 explodedObjects(I).Update
 MsgBox "Exploded Object " & I & ": " _
 & explodedObjects(I).ObjectName
 explodedObjects(I).Color = acByLayer
 explodedObjects(I).Update
 Next
End Sub


About Exploding a Block Reference (VBA/ActiveX)
About Working with Blocks (VBA/ActiveX)
About Working with Attributes (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) > About Working with Blocks (VBA/ActiveX) >

About Redefining a Block (VBA/ActiveX)

Use any of the Block object methods and properties to redefine a block.

When you redefine a block, all the references to that block in the drawing are immediately updated to reflect the new definition.

Redefinition affects previous and future insertions of a block. Constant attributes are lost and replaced by any new constant attributes. Variable attributes remain unchanged, even if the new block has no attributes.

Redefine the objects in a block definition

This example creates a block and adds a circle to the definition of the block. The block is then inserted into the drawing as a block reference. The circle in the block definition is updated, and the block reference is updated automatically.

Sub Ch10_RedefiningABlock()
 ' Define the block
 Dim blockObj As AcadBlock
 Dim insertionPnt(0 To 2) As Double
 insertionPnt(0) = 0
 insertionPnt(1) = 0
 insertionPnt(2) = 0
 Set blockObj = ThisDrawing.Blocks.Add _
 (insertionPnt, "CircleBlock")

 ' Add a circle to the block
 Dim circleObj As AcadCircle
 Dim center(0 To 2) As Double
 Dim radius As Double
 center(0) = 0
 center(1) = 0
 center(2) = 0
 radius = 1
 Set circleObj = blockObj.AddCircle(center, radius)

 ' Insert the block
 Dim blockRefObj As AcadBlockReference
 insertionPnt(0) = 2
 insertionPnt(1) = 2
 insertionPnt(2) = 0
 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
 (insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
 ZoomAll

 ' Redefine the circle in the block,
 ' and update the block reference
 circleObj.radius = 3
 blockRefObj.Update
End Sub


About Redefining a Block (VBA/ActiveX)
About Using Blocks and Attributes (VBA/ActiveX)
About Creating Attribute Definitions and Attribute References (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) >

About Working with Attributes (VBA/ActiveX)

An attribute reference provides an interactive label or tag for you to attach text to a block. Examples of data are part numbers, prices, comments, and owners' names.

You can extract attribute reference information from a drawing and use that information in a spreadsheet or database to produce items such as a parts list or bill of materials (BOM). You can associate more than one attribute reference with a block, provided that each attribute reference has a different tag. You can also define constant attributes. Because they have the same value in every occurrence of the block, AutoCAD does not prompt for a value when you insert the block.

Attributes can be invisible, which means the attribute reference is not displayed or plotted. However, information on the attribute reference is stored in the drawing file.

Topics in this section

  • About Creating Attribute Definitions and Attribute References (VBA/ActiveX)

    To create an attribute reference, first you must create an attribute definition on a block by using the AddAttribute method.

  • About Editing Attribute Definitions (VBA/ActiveX)

    You can use the Attribute object properties and methods to edit the attribute.

  • About Extracting Attribute Information (VBA/ActiveX)

    You can extract attribute information from a drawing using the GetAttributes and GetConstantAttributes methods.


About Working with Attributes (VBA/ActiveX)
About Working with Attributes (VBA/ActiveX)
About Editing Attribute Definitions (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) > About Working with Attributes (VBA/ActiveX) >

About Creating Attribute Definitions and Attribute References (VBA/ActiveX)

To create an attribute reference, first you must create an attribute definition on a block by using the AddAttribute method.

This method requires six values as input: the height of the attribute text, the Attribute mode, a prompt string, the insertion point, the tag string, and the default attribute value. The mode value is optional. There are five constants you can enter to specify the Attribute mode:

acAttributeModeNormal
Specifies that the current mode of each attribute is maintained.
acAttributeModeInvisible
Specifies that attribute values will not appear when you insert the block. The ATTDISP command overrides the Invisible mode.
acAttributeModeConstant
Gives attributes a fixed value for block insertions.
acAttributeModeVerify
Prompts you to verify that the attribute value is correct when you insert the block.
acAttributeModePreset
Sets the attribute to its default value when you insert a block containing a present attribute. The value cannot be edited in this mode.

You can enter none, any combination, or all of the options. To specify a combination of options, add the constants together. For example, you can enter acAttributeModeInvisible + acAttributeModeConstant.

The prompt string appears when a block containing the attribute is inserted. The default for this string is the Tag string. Input acAttributeModeConstant for the mode to disable the prompt.

The tag string identifies each occurrence of the attribute. You can use any characters except spaces or exclamation points. AutoCAD changes lowercase letters to uppercase.

Once the attribute definition is defined in a block, whenever you insert the block using the InsertBlock method you can specify a different value for the attribute reference.

An attribute definition is associated to the block upon which it is created. Attribute definitions created on model space or paper space are not considered attached to any given block.

Define an attribute definition

This example creates a block and then adds an attribute to the block. The block is then inserted into the drawing.

Sub Ch10_CreatingAnAttribute()
 ' Define the block
 Dim blockObj As AcadBlock
 Dim insertionPnt(0 To 2) As Double
 insertionPnt(0) = 0
 insertionPnt(1) = 0
 insertionPnt(2) = 0
 Set blockObj = ThisDrawing.Blocks.Add _
 (insertionPnt, "BlockWithAttribute")

 ' Add an attribute to the block
 Dim attributeObj As AcadAttribute
 Dim height As Double
 Dim mode As Long
 Dim prompt As String
 Dim insertionPoint(0 To 2) As Double
 Dim tag As String
 Dim value As String
 height = 1
 mode = acAttributeModeVerify
 prompt = "New Prompt"
 insertionPoint(0) = 5
 insertionPoint(1) = 5
 insertionPoint(2) = 0
 tag = "New Tag"
 value = "New Value"
 Set attributeObj = blockObj.AddAttribute(height, mode, _
 prompt, insertionPoint, tag, value)
 ' Insert the block, creating a block reference
 ' and an attribute reference
 Dim blockRefObj As AcadBlockReference
 insertionPnt(0) = 2
 insertionPnt(1) = 2
 insertionPnt(2) = 0
 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
 (insertionPnt, "BlockWithAttribute", 1#, 1#, 1#, 0)
End Sub


About Creating Attribute Definitions and Attribute References (VBA/ActiveX)
About Working with Attributes (VBA/ActiveX)
About Extracting Attribute Information (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) > About Working with Attributes (VBA/ActiveX) >

About Editing Attribute Definitions (VBA/ActiveX)

You can use the Attribute object properties and methods to edit the attribute.

Some of the properties on an attribute include the following:

Alignment
Specifies the horizontal and vertical alignment of the attribute
Backward
Specifies the direction of attribute text
FieldLength
Specifies the field length of the attribute
Height
Specifies the height of the attribute
InsertionPoint
Specifies the insertion point of the attribute
Mode
Specifies the mode of the attribute
PromptString
Specifies the prompt string of the attribute
Rotation
Specifies the rotation of the attribute
ScaleFactor
Specifies the scale factor of the attribute
TagString
Specifies the tag string of the attribute

Some of the methods you can use to edit the attribute include the following:

ArrayPolar
Creates a polar array
ArrayRectangular
Creates a rectangular array
Copy
Copies the attribute
Erase
Erases the attribute
Mirror
Mirrors the attribute
Move
Moves the attribute
Rotate
Rotates the attribute
ScaleEntity
Scales the attribute

Redefine an attribute definition

This example creates a block and then adds an attribute to the block. The block is then inserted into the drawing. The attribute text is then updated to be displayed backward.

Sub Ch10_RedefiningAnAttribute()
 ' Define the block
 Dim blockObj As AcadBlock
 Dim insertionPnt(0 To 2) As Double
 insertionPnt(0) = 0
 insertionPnt(1) = 0
 insertionPnt(2) = 0
 Set blockObj = ThisDrawing.Blocks.Add _
 (insertionPnt, "BlockWithAttribute")

 ' Add an attribute to the block
 Dim attributeObj As AcadAttribute
 Dim height As Double
 Dim mode As Long
 Dim prompt As String
 Dim insertionPoint(0 To 2) As Double
 Dim tag As String
 Dim value As String
 height = 1
 mode = acAttributeModeVerify
 prompt = "New Prompt"
 insertionPoint(0) = 5
 insertionPoint(1) = 5
 insertionPoint(2) = 0
 tag = "New Tag"
 value = "New Value"
 Set attributeObj = blockObj.AddAttribute(height, mode, _
 prompt, insertionPoint, tag, value)
 ' Insert the block, creating a block reference
 ' and an attribute reference
 Dim blockRefObj As AcadBlockReference
 insertionPnt(0) = 2
 insertionPnt(1) = 2
 insertionPnt(2) = 0
 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
 (insertionPnt, "BlockWithAttribute", 1#, 1#, 1#, 0)

 ' Redefine the attribute text to display backwards.
 attributeObj.Backward = True
 attributeObj.Update
End Sub


About Editing Attribute Definitions (VBA/ActiveX)
About Working with Attributes (VBA/ActiveX)
About Using External References (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Advanced Drawing and Organizational Techniques > About Using Blocks and Attributes (VBA/ActiveX) > About Working with Attributes (VBA/ActiveX) >

About Extracting Attribute Information (VBA/ActiveX)

You can extract attribute information from a drawing using the GetAttributes and GetConstantAttributes methods.

The GetAttributes method returns an array of the attribute references attached to a block, along with their current values. The GetConstantAttributes method returns an array of constant attributes attached to the block or external reference. The attributes returned by this method are the constant attribute definitions, not attribute references.

You do not need template files to extract attribute information, and no attribute information files are created. Simply iterate the array of attribute references, using the TagString and TextString properties of the attribute -reference to examine the attribute information.

The TagString property represents the individual tag for the attribute reference. The TextString property contains the value for the attribute reference.

Get attribute reference information

This example creates a block and then adds an attribute to the block. The block is then inserted into the drawing. The attribute data is then returned and displayed using a message box. The attribute data is then updated for the block reference, and once again the attribute data is returned and displayed.

Sub Ch10_GettingAttributes()
 ' Create the block
 Dim blockObj As AcadBlock
 Dim insertionPnt(0 To 2) As Double
 insertionPnt(0) = 0
 insertionPnt(1) = 0
 insertionPnt(2) = 0
 Set blockObj = ThisDrawing.Blocks.Add _
 (insertionPnt, "TESTBLOCK")

 ' Define the attribute definition
 Dim attributeObj As AcadAttribute
 Dim height As Double
 Dim mode As Long
 Dim prompt As String
 Dim insertionPoint(0 To 2) As Double
 Dim tag As String
 Dim value As String
 height = 1#
 mode = acAttributeModeVerify
 prompt = "Attribute Prompt"
 insertionPoint(0) = 5
 insertionPoint(1) = 5
 insertionPoint(2) = 0
 tag = "Attribute Tag"
 value = "Attribute Value"

 ' Create the attribute definition object on the block
 Set attributeObj = blockObj.AddAttribute _
 (height, mode, prompt, _
 insertionPoint, tag, value)

 ' Insert the block
 Dim blockRefObj As AcadBlockReference
 insertionPnt(0) = 2
 insertionPnt(1) = 2

 insertionPnt(2) = 0
 Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
 (insertionPnt, "TESTBLOCK", 1, 1, 1, 0)
 ZoomAll

 ' Get the attributes for the block reference
 Dim varAttributes As Variant
 varAttributes = blockRefObj.GetAttributes

 ' Move the attribute tags and values into a
 ' string to be displayed in a Msgbox
 Dim strAttributes As String
 strAttributes = ""
 Dim I As Integer
 For I = LBound(varAttributes) To UBound(varAttributes)
 strAttributes = strAttributes + "  Tag: " + _
 varAttributes(I).TagString + vbCrLf + _
 "   Value: " + varAttributes(I).textString
 Next
 MsgBox "The attributes for blockReference " + _
 blockRefObj.Name & " are: " & vbCrLf _
 & strAttributes

 ' Change the value of the attribute
 ' Note: There is no SetAttributes. Once you have the
 ' variant array, you have the objects.
 ' Changing them changes the objects in the drawing.
 varAttributes(0).textString = "NEW VALUE!"

 ' Get the attributes again
 Dim newvarAttributes As Variant
 newvarAttributes = blockRefObj.GetAttributes

 ' Again, display the tags and values
 strAttributes = ""
 For I = LBound(varAttributes) To UBound(varAttributes)
 strAttributes = strAttributes + "  Tag: " + _
 newvarAttributes(I).TagString + vbCrLf + _
 "   Value: " + newvarAttributes(I).textString
 Next
 MsgBox "The attributes for blockReference " & _
 blockRefObj.Name & " are: " & vbCrLf _
 & strAttributes
End Sub


About Using External References (VBA/ActiveX)

An external reference (xref) links another drawing to the current drawing.

When you insert a drawing as a block, the block and all of the associated geometry is stored in the current drawing database. It is not updated if the original drawing changes. When you insert a drawing as an xref, however, the xref is updated when the original drawing changes. A drawing that contains xrefs, therefore, always reflects the most current editing of each externally referenced file.

Like a block reference, an xref is displayed in the current drawing as a single object. However, an xref does not significantly increase the file size of the current drawing and cannot be exploded. As with blocks, you can nest xrefs that are attached to your drawing.

Topics in this section

  • About Updating Xrefs (VBA/ActiveX)

    When you open or plot your drawing, AutoCAD reloads each xref to reflect the latest state of the referenced drawing.

  • About Attaching Xrefs (VBA/ActiveX)

    Attaching an xref links one drawing (the reference file, or xref) to the current drawing.

  • About Detaching Xrefs (VBA/ActiveX)

    You can detach an xref definition to remove the xrefs completely from your drawing.

  • About Reloading Xrefs (VBA/ActiveX)

    If an externally referenced drawing os modified while you are working on the host drawing to which that xref is attached, you can update that xref drawing using the Reload method.

  • About Unloading Xrefs (VBA/ActiveX)

    To unload an xref, use the Unload method.

  • About Binding Xrefs (VBA/ActiveX)

    Binding an xref to a drawing using the Bind method makes the xref a permanent part of the drawing and no longer an externally referenced file.

  • About Clipping Blocks and Xrefs (VBA/ActiveX)

    ActiveX Automation does not provide a method to clip the boundaries of blocks and xrefs, instead use the XCLIP command.

  • About Demand Loading and Xref Performance (VBA/ActiveX)

    Through a combination of demand loading and saving drawings with indexes, you can increase the performance of drawings with external references.


About Updating Xrefs (VBA/ActiveX)

When you open or plot your drawing, AutoCAD reloads each xref to reflect the latest state of the referenced drawing.

After you make changes to an externally referenced drawing and save the file, other users can access your changes immediately by reloading the xref.


About Attaching Xrefs (VBA/ActiveX)

Attaching an xref links one drawing (the reference file, or xref) to the current drawing.

When a drawing references an xref, AutoCAD attaches only the xref definition to the drawing, unlike regular blocks, where the block definition and the contents of the block are stored with the current drawing. AutoCAD reads the reference drawing to determine what to display in the current drawing. If the reference file is missing or corrupt, its data is not displayed in the current drawing. Each time you open a drawing, AutoCAD loads all graphical and nongraphical (such as layers, linetypes, and text styles) objects from referenced files. If VISRETAIN is on, AutoCAD stores any updated xref-dependent layer information in the current drawing.

You can attach as many copies of an xref as you want, and each can have a different position, scale, and rotation. You can also control the dependent layers and linetype properties that are defined in the xref.

To attach an xref, use the AttachExternalReference method. This method requires you to input the path and file name of the drawing to be referenced, the name the xref is to use in the current drawing, the insertion point, the scale, and rotation information for the xref. The AttachExternalReference method returns the newly created ExternalReference object.

Attach an external reference to a drawing

This example displays all the blocks in the current drawing before and after adding an external reference. This example uses the 3D House.dwg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the PathName variable.

Sub Ch10_AttachingExternalReference()
 On Error GoTo ERRORHANDLER
 Dim InsertPoint(0 To 2) As Double
 Dim insertedBlock As AcadExternalReference
 Dim tempBlock As AcadBlock
 Dim msg As String, PathName As String

 ' Define external reference to be inserted
 InsertPoint(0) = 1
 InsertPoint(1) = 1
 InsertPoint(2) = 0
 PathName = "C:/Program Files/Autodesk/AutoCAD release/sample/3D House.dwg"

 ' Display current Block information for this drawing
 GoSub ListBlocks

 ' Add the external reference to the drawing
 Set insertedBlock = ThisDrawing.ModelSpace. _
 AttachExternalReference(PathName, "XREF_IMAGE", _
 InsertPoint, 1, 1, 1, 0, False)
 ZoomAll

 ' Display new Block information for this drawing
 GoSub ListBlocks
 Exit Sub
ListBlocks:
 msg = vbCrLf    ' Reset message
 For Each tempBlock In ThisDrawing.Blocks
 msg = msg & tempBlock.Name & vbCrLf
 Next
 MsgBox "The current blocks in this drawing are: " & msg
 Return

ERRORHANDLER:
 MsgBox Err.Description
End Sub

Topics in this section

  • About Overlaying Xrefs (VBA/ActiveX)

    Overlaying is similar to attaching, except when a drawing is attached or overlaid.


About Overlaying Xrefs (VBA/ActiveX)

Overlaying is similar to attaching, except when a drawing is attached or overlaid.

Any other overlays nested in it are ignored and, therefore, not displayed. In other words, nested overlays are not read in.

To overlay an xref, set the Overlay parameter of the AttachExternalReference method to TRUE.


About Detaching Xrefs (VBA/ActiveX)

You can detach an xref definition to remove the xrefs completely from your drawing.

You can also erase the individual xref instances. Detaching the xref definition removes all dependent symbols associated with that xref. If all the instances of an xref are erased from the drawing, AutoCAD removes the xref definition the next time the drawing is opened.

To detach an xref, use the Detach method. You cannot detach a nested xref.

Detach an xref definition

This example attaches an external reference and then detaches the external reference. This example uses the 3D House.dwg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the PathName variable.

Sub Ch10_DetachingExternalReference()
 On Error GoTo ERRORHANDLER

 ' Define external reference to be inserted
 Dim xrefHome As AcadBlock
 Dim xrefInserted As AcadExternalReference
 Dim insertionPnt(0 To 2) As Double
 Dim PathName As String
 insertionPnt(0) = 1
 insertionPnt(1) = 1
 insertionPnt(2) = 0
 PathName = "c:/Program Files/Autodesk/AutoCAD release/sample/3D House.dwg"

 ' Add the external reference
 Set xrefInserted = ThisDrawing.ModelSpace. _
 AttachExternalReference(PathName, "XREF_IMAGE", _
 insertionPnt, 1, 1, 1, 0, False)
 ZoomAll
 MsgBox "The external reference is attached."

 ' Detach the external reference definition
 Dim name As String
 name = xrefInserted.name
 ThisDrawing.Blocks.Item(name).Detach
 MsgBox "The external reference is detached."
 Exit Sub
ERRORHANDLER:
 MsgBox Err.Description
End Sub


About Reloading Xrefs (VBA/ActiveX)

If an externally referenced drawing os modified while you are working on the host drawing to which that xref is attached, you can update that xref drawing using the Reload method.

When you reload, the selected xref drawing is updated in your host drawing. Also, if you have unloaded an xref, you can choose to reload that externally referenced drawing at any time.

Reload an xref definition

This example attaches an external reference and then reloads the external reference. This example uses the 3D House.dwg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the PathName variable.

Sub Ch10_ReloadingExternalReference()
 On Error GoTo ERRORHANDLER

 ' Define external reference to be inserted
 Dim xrefHome As AcadBlock
 Dim xrefInserted As AcadExternalReference
 Dim insertionPnt(0 To 2) As Double
 Dim PathName As String
 insertionPnt(0) = 1
 insertionPnt(1) = 1
 insertionPnt(2) = 0
 PathName = "c:/Program Files/Autodesk/AutoCAD release/3D House.dwg"

 ' Add the external reference to the block
 Set xrefInserted = ThisDrawing.ModelSpace. _
 AttachExternalReference(PathName, "XREF_IMAGE", _
 insertionPnt, 1, 1, 1, 0, False)
 ZoomAll
 MsgBox "The external reference is attached."

 ' Reload the external reference definition
 ThisDrawing.Blocks.Item(xrefInserted.name).Reload
 MsgBox "The external reference is reloaded."
 Exit Sub
ERRORHANDLER:
 MsgBox Err.Description
End Sub


About Unloading Xrefs (VBA/ActiveX)

To unload an xref, use the Unload method.

When you unload a referenced file that is not being used in the current drawing, the AutoCAD performance is enhanced by not having to read and display unnecessary drawing geometry or symbol table information. The xref geometry and that of any nested xref is not displayed in the current drawing until the xref is reloaded.

Unload an xref definition

This example attaches an external reference and then unloads the external reference. This example uses the 3D House.dwg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the PathName variable.

Sub Ch10_UnloadingExternalReference()
 On Error GoTo ERRORHANDLER

 ' Define external reference to be inserted
 Dim xrefHome As AcadBlock
 Dim xrefInserted As AcadExternalReference
 Dim insertionPnt(0 To 2) As Double
 Dim PathName As String
 insertionPnt(0) = 1
 insertionPnt(1) = 1
 insertionPnt(2) = 0
 PathName = "c:/Program Files/Autodesk/AutoCAD release/3D House.dwg"

 ' Add the external reference
 Set xrefInserted = ThisDrawing.ModelSpace. _
 AttachExternalReference(PathName, "XREF_IMAGE", _
 insertionPnt, 1, 1, 1, 0, False)
 ZoomAll
 MsgBox "The external reference is attached."

 ' Unload the external reference definition
 ThisDrawing.Blocks.Item(xrefInserted.name).Unload
 MsgBox "The external reference is unloaded."
 Exit Sub
ERRORHANDLER:
 MsgBox Err.Description
End Sub


About Binding Xrefs (VBA/ActiveX)

Binding an xref to a drawing using the Bind method makes the xref a permanent part of the drawing and no longer an externally referenced file.

The externally referenced information becomes a block. When the externally referenced drawing is updated, the bound xref is not updated. This process binds the entire drawing's database, including all of its dependent symbols.

Dependent symbols are named objects such as blocks, dimension styles, layers, linetypes, and text styles. Binding the xref allows named objects from the xref to be used in the current drawing.

The Bind method requires only one parameter: bPrefixName. If bPrefixName is set to TRUE, the symbol names of the xref drawing are prefixed in the current drawing with <blockname>$x$, where x is an integer that is automatically incremented to avoid overriding existing block definitions. If the bPrefixName parameter is set to FALSE, the symbol names of the xref drawing are merged into the current drawing without the prefix. If duplicate names exist, AutoCAD uses the symbols already defined in the local drawing. If you are unsure whether your drawing contains duplicate symbol names, it is recommended that you set bPrefixName to TRUE.

Bind an xref definition

This example attaches an external reference and then binds the external -reference to the drawing. This example uses the 3D House.dwg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the PathName variable.

Sub Ch10_BindingExternalReference()
 On Error GoTo ERRORHANDLER

 ' Define external reference to be inserted
 Dim xrefHome As AcadBlock
 Dim xrefInserted As AcadExternalReference
 Dim insertionPnt(0 To 2) As Double
 Dim PathName As String
 insertionPnt(0) = 1
 insertionPnt(1) = 1
 insertionPnt(2) = 0
 PathName = "c:/Program Files/Autodesk/AutoCAD release/3D House.dwg"

 ' Add the external reference
 Set xrefInserted = ThisDrawing.ModelSpace. _
 AttachExternalReference(PathName, "XREF_IMAGE", _
 insertionPnt, 1, 1, 1, 0, False)
 ZoomAll
 MsgBox "The external reference is attached."

 ' Bind the external reference definition
 ThisDrawing.Blocks.Item(xrefInserted.name).Bind False
 MsgBox "The external reference is bound."
 Exit Sub
ERRORHANDLER:
 MsgBox Err.Description
End Sub


About Clipping Blocks and Xrefs (VBA/ActiveX)

ActiveX Automation does not provide a method to clip the boundaries of blocks and xrefs, instead use the XCLIP command.

Use the XCLIP command at the AutoCAD Command prompt, or send the XCLIP command to AutoCAD using the SendCommand method.


About Demand Loading and Xref Performance (VBA/ActiveX)

Through a combination of demand loading and saving drawings with indexes, you can increase the performance of drawings with external references.

Demand loading works in conjunction with the XLOADCTL and INDEXCTL system variables. When you turn on demand loading, if indexes have been saved in the referenced drawings, AutoCAD loads into memory only the data from the reference drawing that is necessary to regenerate the current drawing. In other words, referenced material is read in “on demand.”

To realize the maximum benefits of demand loading, you need to save the referenced drawings with layer and spatial indexes. The performance benefits of demand loading are most noticeable when you

  • Clip the xref to display a small fraction of it, and a spatial index is saved in the externally referenced drawing.
  • Freeze several layers of the xref, and the externally referenced drawing is saved with a layer index.

To turn on demand loading, use the XRefDemandLoad property. If you turn on demand loading with the acDemandLoadEnabledWithCopy option, AutoCAD makes a temporary copy of the externally referenced file and demand loads the temporary file. You can then demand load the xref while allowing the original reference drawing to be available for modification. When you disable demand loading, AutoCAD reads in the entire reference drawing regardless of layer visibility or clip instances.

To turn on layer and spatial indexes, set the INDEXCTL system variable using the SetVariable method. The following settings apply to the INDEXCTL system variable:

  • 0 = no indexes created
  • 1 = layer index created
  • 2 = spatial index created
  • 3 = both spatial and layer indexes created

By default, INDEXCTL is set to 0 when you create a new AutoCAD drawing.


About Assigning and Retrieving Extended Data (VBA/ActiveX)

You can use extended data (xdata) as a means for linking information with objects in a drawing.

Assign xdata to all objects in a selection set

This example prompts the user to select objects from the drawing. The selected objects are placed into a selection set, and the specified xdata is attached to all objects in that selection set.

Sub Ch10_AttachXDataToSelectionSetObjects()
 ' Create the selection set
 Dim sset As Object
 Set sset = ThisDrawing.SelectionSets.Add("SS1")

 ' Prompt the user to select objects
 sset.SelectOnScreen

 ' Define the xdata
 Dim appName As String, xdataStr As String
 appName = "MY_APP"
 xdataStr = "This is some xdata"
 Dim xdataType(0 To 1) As Integer
 Dim xdata(0 To 1) As Variant

 ' Define the values for each array
 '1001 indicates the appName
 xdataType(0) = 1001
 xdata(0) = appName
 '1000 indicates a string value
 xdataType(1) = 1000
 xdata(1) = xdataStr

 ' Loop through all entities in the selection
 ' set and assign the xdata to each entity
 Dim ent As Object
 For Each ent In sset
 ent.SetXData xdataType, xdata
 Next ent
End Sub

View the xdata of all objects in a selection set

This example displays the xdata attached with the previous example. If you attach xdata other than strings (type 1000), you will need to revise this code.

Sub Ch10_ViewXData()
 ' Find the selection created in previous example
 Dim sset As Object
 Set sset = ThisDrawing.SelectionSets.Item("SS1")

 ' Define the xdata variables to hold xdata information
 Dim xdataType As Variant
 Dim xdata As Variant
 Dim xd As Variant

 'Define index counter
 Dim xdi As Integer
 xdi = 0

 ' Loop through the objects in the selection set
 ' and retrieve the xdata for the object
 Dim msgstr As String
 Dim appName As String
 Dim ent As AcadEntity
 appName = "MY_APP"
 For Each ent In sset
 msgstr = ""
 xdi = 0

 ' Retrieve the appName xdata type and value
 ent.GetXData appName, xdataType, xdata

 ' If the xdataType variable is not initialized, there
 ' was no appName xdata to retrieve for that entity
 If VarType(xdataType) <> vbEmpty Then
 For Each xd In xdata
 msgstr = msgstr & vbCrLf & xdataType(xdi) _
 & ": " & xd
 xdi = xdi + 1
 Next xd
 End If

 ' If the msgstr variable is NULL, there was no xdata
 If msgstr = "" Then msgstr = vbCrLf & "NONE"
 MsgBox appName & " xdata on " & ent.ObjectName & _
 ":" & vbCrLf & msgstr
 Next ent
End Sub


Develop Applications with VBA

Topics in this section

  • Terminology Reference

    There are terms that you should be familiar with when reading the VBA and ActiveX documentation.

  • About Forms

    Forms are the basic building blocks through which you create your own custom dialog boxes for your application.

  • About Handling Errors

    Most development environments provide default error handling.

  • About Encrypting VBA Code Modules

    Although VBA does not support creation of executables, it does offer password protection for the visibility of the project forms, classes, and modules on a project basis.

  • About Runing a VBA Macro from a Toolbar or Menu

    You can run a VBA macro from an AutoCAD toolbar or menu by simply changing the Macro property for that toolbar or menu.

  • About Automatically Loading a VBA Project

    VBA project files can be automatically loaded into AutoCAD.

  • About Automatically Running a VBA Macro

    You can automatically run any macro in the acad.dvb file by calling it with the command line version of VBARUN from an AutoCAD startup facility like acad.lsp.

  • About Automatically Opening the VBA IDE Whenever a Project Is Loaded

    There is an option on the Open VBA Project dialog box that allows you to open the interactive development environment automatically.

  • About Working in a Zero Document State

    A zero document state is when there are no open drawings in AutoCAD.

  • About Distributing Your Application

    After you have tested a project, it is ready to be distributed to your users.

  • About Migrating VBA Projects and Other Applications that Use the ActiveX API

    Based on the changes made to the AutoCAD ActiveX API, you might need to make changes to your applications to run them with the latest release of the product


Terminology Reference (VBA)

There are terms that you should be familiar with when reading the VBA and ActiveX documentation.

The following terms will help you understand and work within the VBA environment.

Dialog box
A means by which information is displayed or gathered during application execution.
Form/UserForm
Container for dialog box controls.
Macro
A public subroutine or function. Macros are exposed to the user as an executable component of your project.
Module
A group of (usually related) subroutines and functions.
Project
A set of forms and modules grouped together in a single file.


About Forms (VBA)

Forms are the basic building blocks through which you create your own custom dialog boxes for your application.

Through custom forms you can provide information to users, get information from users, or have your users control activity in the application.

Forms are like an artist's canvas—they start out blank. To fill your canvas, you need a palette. In this case, your palette is the control toolbox. You, as the artist, place selected controls from the toolbox onto the form. You can add as many controls as you like. At any time you can adjust size and properties of the controls and even the form itself. Finally, you add the functionality (code) to the controls that brings your form to life.

Although VB.NET supports different types of forms, VBA supports only the UserForm. This means some forms have been created and exported in VB.NET that cannot be imported into VBA.

UserForms—or forms, as they are called in this guide—can be modal or modeless. The ShowModal property of a form determines whether it is modal or modeless. Modal forms displayed in your running application must be closed before users can perform any other action in the application.

Topics in this section

  • About Design and Run Mode (VBA)

    Design mode allows you to define a form directly in the UserForm window of the VBA IDE, while Run mode allows you to make changes to a form dynamically using the code of a program.

  • About Adding Controls to a Form (VBA)

    Controls placed on a form allow a program to request input from the user.

  • About Displaying and Hiding Forms (VBA)

    A VBA project must display a user form before it can be used and then hidden after you no longer need it.

  • About Loading and Unloading Forms (VBA)

    There may be times when you want to load a form into memory during runtime, but not show the form. You may choose to do this to better control when the load time occurs in your application, or when you need programmatic access to the form but do not want to display the form to the user.

  • About Modal Forms (VBA)

    When you define a dialog box as modal in AutoCAD VBA, the user must respond to the dialog box before any other part of the application is allowed to continue.

  • To create a new form in your project (VBA)

    Forms allow for input from the user.

  • To create a modeless form in your project (VBA)

    Modeless dialog boxes allow a form to remain displayed while the user interfaces with the drawing area, similar to a floating palette.


About Design and Run Mode (VBA)

Design mode allows you to define a form directly in the UserForm window of the VBA IDE, while Run mode allows you to make changes to a form dynamically using the code of a program.

While you are building your form you are working in Design mode, where you can

  • Add controls to the form
  • Change the properties of the form
  • Change the properties of controls on the form
  • Add code to the form module

While in Design mode there is no interaction among the user, the user interface of AutoCAD, and your form.

Once you run your application, or your user runs your application, the form is then in Run mode. While in Run mode you cannot make adjustments to the form directly. However, the form is now displayed in the AutoCAD user interface and the user can interact with the form as part of the normal operation of your application.


About Adding Controls to a Form (VBA)

Controls placed on a form allow a program to request input from the user.

Adding controls to a form is easy. Simply select a control from the control toolbox and drag it over to the form. When you release your mouse, a copy of the control will be placed on the form. Once the control is on the form, you can change the position and size of the control. You can copy over as many controls as you like.

In addition to the drag method previously mentioned, there are other ways of placing controls on a form.

Topics in this section

  • About Changing the Size and Placement of a Control (VBA)

    The size and placement of controls can be directly manipulated in the UserForm window of the VBA IDE.

  • About Formatting Controls (VBA)

    VBA provides several formatting controls to help you lay out your form.

  • About Changing the Properties of a Control (VBA)

    Properties control various characteristics of a control such as its size, shape, color, label, and default values.

  • About Adding Code to a Control (VBA)

    After a control has been added to a form, you can edit the code for an event that is triggered by a control when a user interacts with it.


About Changing the Size and Placement of a Control (VBA)

The size and placement of controls can be directly manipulated in the UserForm window of the VBA IDE.

To move a control, simply select it and drag it to its new position on the form.

To resize a control, first select the control by clicking on it once. When you select a control, its border becomes visible. To resize the control, simply select one of the sizing grips now visible on the border and drag the grip to a new position. When you release the grip, the control is resized to that location. (You can resize the form in the same manner.)

To move or resize several controls at once, select each control while holding down the Shift key. This will highlight all the controls. You can now move or resize the controls as a group.

Topics in this section

  • To size a control as you place it (VBA)

    As a control is placed, you can adjust is size and placement in the UserForm window of the VBA IDE.

  • To place several instances of the same control (VBA)

    A control can be copied to create multiple instances of the same control in the UserForm window of the VBA IDE.


About Changing the Size and Placement of a Control (VBA)
About Changing the Size and Placement of a Control (VBA)
To place several instances of the same control (VBA)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Develop Applications with VBA > About Forms (VBA) > About Adding Controls to a Form (VBA) > About Changing the Size and Placement of a Control (VBA) >

To size a control as you place it (VBA)

As a control is placed, you can adjust is size and placement in the UserForm window of the VBA IDE.

  1. Select the desired control in the control toolbox.
  2. On the form, press, drag, and release the mouse button. The selected control will be placed on the form. The size of the control depends on how far you drag the mouse.


To size a control as you place it (VBA)
About Changing the Size and Placement of a Control (VBA)
About Formatting Controls (VBA)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Develop Applications with VBA > About Forms (VBA) > About Adding Controls to a Form (VBA) > About Changing the Size and Placement of a Control (VBA) >

To place several instances of the same control (VBA)

A control can be copied to create multiple instances of the same control in the UserForm window of the VBA IDE.

  1. In the control toolbox, double-click on the control you want to place.
  2. On the form, click at the location you want a copy of the control placed. Move to another location on the form and click again. Another copy of the control will appear. You can add as many copies of the control as you need.
  3. When you are finished with the control, return to the control toolbox and click the control one more time to deselect it.


About Formatting Controls (VBA)

VBA provides several formatting controls to help you lay out your form.

These controls can be found on the Format menu of the VBA IDE. These controls allow you to align controls to each other, make two or more controls the same size, change the spacing between controls, and center controls on the form.

Remember when using the formatting controls that several controls can be selected at once by using Shift.


About Changing the Properties of a Control (VBA)

Properties control various characteristics of a control such as its size, shape, color, label, and default values.

You can set the properties of a control in design mode by using the Properties window.

Topics in this section

  • To change the property of a control (VBA)

    The properties of form controls can be edited using the Properties window in the VBA IDE.


About Changing the Properties of a Control (VBA)
About Changing the Properties of a Control (VBA)
About Adding Code to a Control (VBA)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Develop Applications with VBA > About Forms (VBA) > About Adding Controls to a Form (VBA) > About Changing the Properties of a Control (VBA) >

To change the property of a control (VBA)

The properties of form controls can be edited using the Properties window in the VBA IDE.

  1. On the form, select the desired control.
  2. Open the Properties window using F4 if it is not already open.
  3. In the Properties window, find the property you want to change and select the current value for that property.
  4. Change the value to the new desired value for the property.

    You can also change the property of a control at runtime by writing code to access that property. See the Microsoft documentation for more information on changing the property of a control at runtime.


About Adding Code to a Control (VBA)

After a control has been added to a form, you can edit the code for an event that is triggered by a control when a user interacts with it.

Now that you have your form looking the way you want, it is time to add some code behind your controls. To open the Code window for a control simply double-click on the control in the Form window. The Code window will open, with a subroutine created for that control and its default event.

You can add code to the default event, or choose a different event from the event drop-down list at the top-right corner of the Code window.


About Displaying and Hiding Forms (VBA)

A VBA project must display a user form before it can be used and then hidden after you no longer need it.

Now you have a beautifully designed form with fully functional code behind all the controls. The last step is getting the form displayed to the user at run-time. Displaying the form is accomplished through the VBA Show method. The Show method can be called from any code module in your application.

The form you created is modal by default, so the user will not be able to interact with AutoCAD directly while the form is displayed. For example, the user cannot select a point or object in the drawing with the form displayed. To allow the user access to the AutoCAD drawing, use the VBA Hide method. The Hide method hides the form and allows the user limited access to AutoCAD. When using the Hide method it is important to remember that the form is not unloaded from memory. It will retain all current values while hidden.

The Hide method is called in the same manner as the Show method.

Display a form

This example will display the form named “UserForm1”:

Public Sub MyApplication()
  UserForm1.Show
End Sub

The subroutine (and consequently the display of your form) is now callable as a macro from the VBARUN command or from the AutoCAD user interface.

Hide a form

This example hides the form named “UserForm1”:

Public Sub MyAppHide()
  UserForm1.Hide
End Sub


About Loading and Unloading Forms (VBA)

There may be times when you want to load a form into memory during runtime, but not show the form. You may choose to do this to better control when the load time occurs in your application, or when you need programmatic access to the form but do not want to display the form to the user.

To load a form, but not display it, use the VBA Load method. The Show method can then be used to make the form visible at the appropriate time in your application's execution. Remember, the user cannot interact with your form until it is visible.

If the Show method is called and the form has not been loaded, it will be loaded automatically.

There may also be times when you will want to unload a form specifically. Unloading a form removes that form from memory and all the memory associated with the form is reclaimed. Until the form is loaded again by using either the Load or Show method, a user cannot interact with the form, and the form cannot be manipulated programmatically. You may choose to unload a form when you know the form will not be used again in the application and you want to reclaim the memory.

The Hide method does not perform an unload. If your application ends and a form has not been unloaded, it will be unloaded automatically. The following table compares the VBA Show, Hide, Load, and Unload methods:

VBA Show, Hide, Load, and Unload methods
Method | Use
Show | Displays a form. If the form has not been loaded, it is loaded automatically.
Hide | Hides a form. The form is not unloaded from memory.
Load | Loads a form into memory but does not display it.
Unload | Unloads a form from memory. This can be done explicitly from the Unload method, or automatically at the termination of the application.


About Modal Forms (VBA)

When you define a dialog box as modal in AutoCAD VBA, the user must respond to the dialog box before any other part of the application is allowed to continue.

No subsequent code is executed until the modal dialog box is closed through either the Hide or Unload method. This requires that you, as the developer of the application, think carefully about how and when you implement dialog boxes.

For example, you may have a dialog box that requires the user to select an object in the AutoCAD drawing. For the user to be able to pick the object from the AutoCAD Application window, you must hide the form by calling the Hide method. Once the object has been selected you use the Show method to redisplay the form, with all of its data still current, and continue with the application.

NoteAlthough other forms in the application are disabled when a modal dialog box is displayed, other applications are not.


To create a new form in your project (VBA)

Forms allow for input from the user.

  1. Open the Project window of the VBA IDE and select the project you want to add the form to.
  2. From the Insert menu, click UserForm.

    A blank form is created and added to your project.


To create a modeless form in your project (VBA)

Modeless dialog boxes allow a form to remain displayed while the user interfaces with the drawing area, similar to a floating palette.

  1. Open the Project window of the VBA IDE and select the project you want to add the form to.
  2. From the Insert menu, choose UserForm, and change the ShowModal property to False.
  3. Add the AcFocusCtrl (AcFocusCtrl.dll) to the Toolbox, and drag the control onto the form.

    The AcFocusCtrl keeps the focus on the form during user interaction.


About Handling Errors (VBA)

Most development environments provide default error handling.

For VB and VBA, the default reaction to an error is to display an error message and terminate the application. While this behavior is adequate during the development phase of your application, it is not productive for your end user. There may be errors that you want to ignore, or that you want to provide special responses to. There may be errors that you will want to suppress the error message display for, or simply control the message that gets displayed to the user. In addition, automatically terminating the application is hardly ever acceptable to the end user.

In general, error handling is necessary whenever user input is required and whenever working with file I/O. Remember, even if you are sure a needed file is there and available for processing, there may be conditions you haven't thought of that could cause errors.

NoteMost of the code examples provided in the AutoCAD documentation do not use error trapping. This keeps the examples simple and to the point. However, as with all programming languages, proper error trapping and handling is essential for a robust application.

Topics in this section

  • Application Error Types Reference (VBA)

    There are three different types of errors you can encounter in your applications: compile-time errors, runtime errors, and logic errors.

  • About Trapping Runtime Errors (VBA)

    In VB and VBA, runtime errors are trapped using the On Error statement.

  • About Responding to Trapped Errors (VBA)

    After an error is trapped, you must determine what to do with the error and if program execution should continue.

  • About Responding to AutoCAD User Input Errors (VBA/ActiveX)

    The user-input methods provide a certain amount of inherent error trapping in that they require the user to enter a certain type of data.


Application Error Types Reference (VBA)

There are three different types of errors you can encounter in your applications: compile-time errors, runtime errors, and logic errors.

  • Compile-time errors occur during the construction of your application. These errors consist mostly of syntax mistakes, variable scoping problems, or data typing problems. In VBA, these types of errors are caught by the development environment. When you enter an incorrect line of code, the line is highlighted and an error message appears telling you the problem. Compile-time errors must be corrected before the application can run.
  • Runtime errors are a little more difficult to find and correct. They occur during the execution of your code, and often involve receiving information from the user. For example, if your application requires the user to enter the name of a drawing and the user enters a name for a drawing that didn't exist, a runtime error occurs. To handle runtime errors effectively, you must predict what kinds of problems could happen, trap them, and then write code to handle these situations.
  • Logic errors are the most difficult to find and correct. Symptoms of logic errors include situations in which there are no compile-time errors and no runtime errors, but the outcome of your program is still incorrect. This is what programmers refer to as a bug—and a bug can be very easy or very difficult to track down.

Information on finding and correcting all three types of errors can be found in documentation for your development environment. AutoCAD-specific errors fall into the runtime error category, so these types of errors will be covered more fully in this documentation.


About Trapping Runtime Errors (VBA)

In VB and VBA, runtime errors are trapped using the On Error statement.

This statement literally sets a trap for the system. When an error occurs, this statement automatically detours processing to your specially written error handler. The default error handling for the system is bypassed.

The On Error statement has three forms:

  • On Error Resume Next
  • On Error GoTo Label
  • On Error GoTo 0

The On Error Resume Next statement is used when you want to ignore errors. This statement traps the error and instead of displaying an error message and terminating the program, it simply moves on to the next line of code and continues processing. For example, if you wanted to create a subroutine to iterate through model space and change the color of each entity, you know that AutoCAD will throw an error if you try to color an entity on a locked layer. Instead of terminating the program, simply skip the entity on the locked layer and continue processing the remaining entities. The On Error Resume Next statement lets you do just that.

The On Error GoTo Label statement is used when you want to write an explicit error handler. This statement traps the error and instead of displaying an error message and terminating the program, it jumps to a specific location in your code. Your code can then respond to the error in whatever manner is appropriate for your application. For example, you can expand the example above to display a message containing the handle for each entity on the locked layer.

Handle errors with the On Error Resume Next statement

The following subroutine iterates model space and changes the color of each entity to red. Try running this subroutine on a drawing with several entities, some of which are on a locked layer. Next, comment out the On Error Resume Next statement and run the subroutine again. You will notice the subroutine terminates at the first entity on the locked layer.

Sub Ch11_ColorEntities()
  Dim entry As Object
  On Error Resume Next
  For Each entry In ThisDrawing.ModelSpace
    entry.Color = acRed
  Next entry
End Sub

Handle errors with the On Error GoTo statement

The following subroutine iterates model space and changes the color of each entity to red. For each entity on the locked layer, the error handler displays a custom error message and the handle of the entity. Try running this subroutine on a drawing with several entities, some of which are on a locked layer. Next, comment out the On Error GoTo MyErrorHandling statement and run the subroutine again. You will notice the subroutine terminates at the first entity on the locked layer.

Sub Ch11_ColorEntities2()
  Dim entry As Object
  On Error GoTo MyErrorHandler
  For Each entry In ThisDrawing.ModelSpace
    entry.Color = acRed
  Next entry

  ' Important! Exit the subroutine before the error handler
  Exit Sub
MyErrorHandler:
  Msgbox entry.EntityName + " is on a locked layer." + _
  " The handle is: " + entry.Handle
  Resume Next
End Sub

The On Error GoTo 0 statement cancels the current error handler. The On Error Resume Next and On Error GoTo Label statements remain in effect until the subroutine ends, another error handler is declared, or the error handler is canceled with the On Error GoTo 0 statement.


About Responding to Trapped Errors (VBA)

After an error is trapped, you must determine what to do with the error and if program execution should continue.

Now that you have trapped an error, what do you do with it? The answer depends on the nature of your application and the nature of the error.

VB and VBA provide information on the type of error that has been trapped by using the Err object. This object has several properties: Number, Description, Source, HelpFile, HelpContext, and LastDLLError. The properties of the Err object get filled in with the information for the most current error. The most important properties are the Number and Description properties. The Number property contains the unique error code associated with the error, and the Description property contains the error message that would normally be displayed.

In your error handler you can compare the Number property of the error to an expected value. This will help you determine the nature of the error that has occurred. Once you know what kind of error you are dealing with, you can take the appropriate action.


About Responding to AutoCAD User Input Errors (VBA/ActiveX)

The user-input methods provide a certain amount of inherent error trapping in that they require the user to enter a certain type of data.

If the user tries to enter some other data, AutoCAD rejects the input and reprompts the user. Using the InitializeUserInput method with the user input functions provides additional control of the user input but can also introduce additional conditions that must be verified through error trapping. For an example of error trapping that is required with certain types of user-input.


About Encrypting VBA Code Modules (VBA)

Although VBA does not support creation of executables, it does offer password protection for the visibility of the project forms, classes, and modules on a project basis.

You can find this Project Protection facility on the VBA IDE menu bar. Click the Tools menu [image] Project Properties [image] Protection.


About Runing a VBA Macro from a Toolbar or Menu (VBA)

You can run a VBA macro from an AutoCAD toolbar or menu by simply changing the Macro property for that toolbar or menu.

The Macro property must be set equal to

-VBARUN filename.dvb!modulename.macroname

where filename is the name of the project file, modulename is the name of the module containing the macro to be run, and macroname is the name of the macro. The file name is only required when the file is not loaded in the current session of AutoCAD. If the file name is provided, the file will be loaded.


About Automatically Loading a VBA Project (VBA)

VBA project files can be automatically loaded into AutoCAD.

There are two different ways to load a VBA project automatically:

  • When VBA is loaded it will look in the AutoCAD directory for a project named acad.dvb. This file is automatically loaded as the default project.
  • Any project other than the default, acad.dvb, can be used by explicitly loading that project at startup using the VBALOAD command. The following code sample uses the AutoLISP startup file to load VBA and a VBA project named myproj.dvb when AutoCAD is started. Start notepad.exe and create (or append to) acad.lsp the following lines:
    (defun S::STARTUP()
  (command "_VBALOAD" "myproj.dvb")
)


About Automatically Running a VBA Macro (VBA)

You can automatically run any macro in the acad.dvb file by calling it with the command line version of VBARUN from an AutoCAD startup facility like acad.lsp.

For example, to automatically run the macro named drawline, first save the drawline macro in the acad.dvb file. Next, invoke notepad.exe and create (or append to) acad.lsp the following lines:

(defun S::STARTUP()
  (command "_-vbarun" "drawline")
)

You can cause a macro to run automatically when VBA loads by naming the macro AcadStartup. Any macro in your acad.dvb file called AcadStartup will automatically get executed when VBA loads.


About Automatically Opening the VBA IDE Whenever a Project Is Loaded (VBA)

There is an option on the Open VBA Project dialog box that allows you to open the interactive development environment automatically.

Simply select the Open Visual Basic Editor check box found in the lower-left side of the dialog box and the VBA IDE will open automatically whenever a VBA project is loaded. This option will remain set until you turn it off again.

NoteTo access the Open VBA Project dialog box, enter VBALOAD at the command line. The dialog box will open and allow you to choose a project to load. If you do not see the Open VBA Project dialog box, it is most likely because the system variable FILEDIA is turned off. This system variable turns on and off the display of dialog boxes. To turn FILEDIA back on, set it to 1.


About Working in a Zero Document State (VBA)

A zero document state is when there are no open drawings in AutoCAD.

There are several important considerations to keep in mind when you are working with VBA in a zero document state:

  • The ThisDrawing object is undefined in a zero document state. Any attempt to use ThisDrawing will result in an error.
  • Objects that are document dependent are also not defined in a zero document state. Document dependent objects are those objects that fall below the Document object in the AutoCAD object model. Working with nondocument-dependent object, such as the Application or MenuBar objects, is allowed.
  • AutoCAD does not have a command line in a zero document state. Any attempt to access the AutoCAD Command prompt while AutoCAD is in a zero document state will result in an error.


About Distributing Your Application (VBA)

After you have tested a project, it is ready to be distributed to your users.

The method you use to distribute your application depends on if it is a VBA project, or an application developed with VB or VB.NET.

VBA Applications

VBA applications can be distributed two different ways:

  • Embedded in an AutoCAD drawing file
  • Stored in a VBA project file

You must choose a distribution option that is appropriate for your application. Applications that are applicable to the current drawing, and do not access other drawings, are often embedded in the drawing. By embedding the application in the drawing, you can always be sure the application is loaded, and therefore available to the user whenever the drawing is open.

Applications that are used by many people, are updated frequently, need to open and close other drawings, or are not used frequently you may want to store in a VBA project file. In this way, there is one central location for the application, and everyone can be sure to use the latest version.

Standalone Applications

Visual Basic or .NET applications, or any other out-of-process applications, cannot be stored within an AutoCAD drawing. These applications are compiled into standalone executables (EXEs).


About Migrating VBA Projects and Other Applications that Use the ActiveX API (VBA/ActiveX)

Based on the changes made to the AutoCAD ActiveX API, you might need to make changes to your applications to run them with the latest release of the product

AutoCAD Object Instantiation in VBA

64-bit operating systems can execute both 32-bit and 64-bit applications, but they cannot mix these types within a process. For example, you cannot load 32-bit DLLs into a 64-bit process, or vice versa. All executable components (EXE and DLL files) that are loaded into a process must match the binary type of the process. In-process components for your 64-bit applications should be ported to 64-bit processes as much as possible.

One error could occur when attempting to create a new object. VB’s New keyword will attempt to load 64-bit AutoCAD COM DLLs. Since VBA is a 32-bit application, it cannot load 64-bit DLLs. For example, code such as

Dim color As AcadAcCmColor
Set color = New AcadAcCmColor

or

Dim color As New AcadAcCmColor
color.SomeMethod()

needs to be modified and ported to

Dim color As AcadAcCmColor
Set color = AcadApplication.GetInterfaceObject("Autocad.AcCmColor.20")

The above issue should be resolved using AcadApplication.GetInterfaceObject("ProgIdOfAcAnyObject") for any object that is derived from IDispatch. Classes derived from IUnknown (e.g. AcSmSheetSet, AcSmSheetMgr etc) are not expected to have a 64-Bit VBA migration. It is recommended that you port such processes to VB.NET.

64-bit Migration

Microsoft is now providing a native 64-bit version of VBA for developers; therefore, you will need to maintain two versions of your VBA projects: 32-bit and 64-bit. In releases prior to AutoCAD 2014, VBA ran as an out-of-process component, accessed through a 32-bit-to-64-bit “thunking” layer which allowed existing 32-bit VBA projects to function as expected in AutoCAD 64-bit. VBA 64-bit requires the use of different libraries and controls for forms. Not all VBA libraries and form controls are available in 64-bit yet, and you might need to adjust some of your code to work correctly on both Windows 32-bit and Windows 64-bit.

Handling ObjectId

Beginning with AutoCAD 2009 64-bit through AutoCAD 2013 64-bit, object IDs are represented by a 64-bit integer datatype (__int64). Accessing these values in 32-bit VBA will result in a compilation error. As a resolution, a new set of method names suffixed with "32" corresponding to the old methods are used (e.g. ObjectID32(), OwnerID32()). These methods use the LONG data type, which internally maps to the 64-bit integer data type.

To be more precise, a 32-bit Object ID is created internally for each object ID required in VBA. This ID is mapped to its 64-bit actual ID, so that if the 32-bit ID is passed back to AutoCAD from VBA code, then the 64-bit object ID is returned and used internally for all purposes.

NoteObject IDs are no longer converted to the LONG data type for AutoCAD 32-bit.

The following sample gives an example of ported 32-bit Object ID code:

Original code 64-bit (AutoCAD 2009 through AutoCAD 2013):
Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID32
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject32(objectID)
Code ported for AutoCAD 2014 64-bit and later compatibility:
Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject(objectID)

VBA applications can also use an object’s handle instead of its object ID. The following sample shows how to use the handle instead of the object ID:

Original code using an object's Object ID:
Dim splineObj As AcadSpline
Dim objectID As Long
objectID = splineObj.objectID
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject(objectID)
Revised code using an object's handle:
Dim splineObj As AcadSpline
Dim objectHandle As String
objectHandle = splineObj.Handle
Dim tempObj As AcadObject
Set tempObj = ThisDrawing.HandleToObject(objectHandle)

Appendix of 32-bit Methods (Obsolete with AutoCAD 2014 64-bit and Later)

NoteObject IDs are no longer converted to the LONG data type for AutoCAD 32-bit.

The following table lists the methods that were used in AutoCAD 2009 64-bit through AutoCAD 2013 64-bit as 32-bit substitutions:

VBA Methods for a 64-bit System
Method - AutoCAD 2009 through 2013 | Method - AutoCAD 2014 and Later | Use
GetBlockAttributeValue32 | GetBlockAttributeValue | Returns the attribute value from the specified block cell for the attribute definition object contained in the block using its 32-bit object ID.
GetBlockTableRecordId32 | GetBlockTableRecordId | Gets the 32-bit object ID of the block table record associated to the block-type cell and nContent.
GetFieldId32 | GetFieldId | Returns the 32-bit object ID of the field object associated to the specified cell.
GetGridLinetype32 | GetGridLinetype | Returns the 32-bit object ID of the grid linetype object.
Key32 | Key | Specifies the object ID of the source object in the CopyObjects operation for a 64-bit system.
ObjectID32 | ObjectID | Gets the object ID for a 64-bit system.
ObjectIDtoObject32 | ObjectIDtoObject | Gets the object that corresponds to the given object ID for a 64-bit system.
OwnerID32 | OwnerID | Gets the object ID of the owner (parent) object for a 64-bit system.
SetBlockAttributeValue32 | SetBlockAttributeValue | Sets the attribute value from the specified block cell for the attribute definition object contained in the block and nContent using its 32-bit object ID.
SetBlockTableRecordId32 | SetBlockTableRecordId | Sets the 32-bit object ID block table record associated to the block-type cell and nContent.
SetFieldId32 | SetFieldId | Sets the 32-bit object ID of the field object associated to the specified cell and nContent.
SetGridLinetype32 | SetGridLinetype | Sets the 32-bit object ID of the grid line type object.
Value32 | Value | Specifies the current value for the property, or the object ID of the newly created cloned object, for a 64-bit system.


Interact with Other Applications and Window APIs

Topics in this section

  • About Interacting with Visual LISP Applications

    Visual LISP applications have access to the entire range of ActiveX objects.

  • About Interacting with Other Windows Applications

    AutoCAD ActiveX technology allows you to exchange information easily with other ActiveX-enabled applications such as Microsoft Excel or Microsoft Word.

  • About Accessing Windows APIs from VBA

    The Windows API procedures are available to most Windows applications. These procedures allow you to expand the capabilities of your application.


About Interacting with Visual LISP Applications (AutoLISP/ActiveX)

Visual LISP® applications have access to the entire range of ActiveX® objects.

They can call ActiveX methods, and set and retrieve ActiveX properties. In addition, Visual LISP applications can also run VBA macros through the VBARUN command.

ActiveX and VBA applications can execute Visual LISP applications through the SendCommand method. This method allows ActiveX and VBA applications to send a command to the AutoCAD Command prompt.


About Interacting with Other Windows Applications (ActiveX)

AutoCAD® ActiveX technology allows you to exchange information easily with other ActiveX-enabled applications such as Microsoft Excel or Microsoft Word.

This capability allows you to collect, store, and present AutoCAD information in formats other than the AutoCAD drawing. You can also read information from these applications back into AutoCAD to direct the creation or manipulation of AutoCAD objects. An example of using this technology is to create a bill of materials as a Microsoft Excel spreadsheet from the objects in an AutoCAD drawing.

You have already learned how to write code using the AutoCAD ActiveX Object Model. Exchanging information with other ActiveX-enabled applications involves simply referencing the other applications' ActiveX Object Model and writing the code necessary to utilize their objects.

NoteThis chapter provides only a brief introduction to the capabilities of cross-application programming. This material is not AutoCAD-specific, and as such it is discussed in both Microsoft documentation and independent programming guides.

Topics in this section

  • About Referencing the ActiveX Object Library of Other Applications (VBA/ActiveX)

    To write code that accesses another application, you must instruct VBA to make the objects in the other application available to you.

  • About Creating an Instance of the Other Application (VBA/ActiveX)

    Once you have referenced an application's object library you must create an instance of the application.

  • About Programming with Objects from Other Applications (VBA/ActiveX)

    Now that you have referenced the object library and created a new instance of the application, you can create and manipulate objects in that application.

  • To exchange information across ActiveX Object Models (ActiveX)

    Other programs that support ActiveX can communicate with AutoCAD using the AutoCAD ActiveX API.


About Interacting with Other Windows Applications (ActiveX)
About Interacting with Other Windows Applications (ActiveX)
To make a reference to another application's object library (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Interact with Other Applications and Window APIs > About Interacting with Other Windows Applications (ActiveX) >

About Referencing the ActiveX Object Library of Other Applications (VBA/ActiveX)

To write code that accesses another application, you must instruct VBA to make the objects in the other application available to you.

You do this by setting a reference in the other application's object library. This is a file on your computer where all the objects, methods, properties, constants, and events for that application are defined.

You make a reference to an object library through the VBA IDE. In the VBA IDE, under the Tools menu, there is a menu option called References. This menu option will bring up a dialog box that lists all of the object libraries VBA finds on your system. To make a reference to a library, simply select the library from the list. Libraries with check boxes that are selected are already referenced in the current project. For example, to add the Microsoft Excel object library, select the Microsoft Excel object library entry in the list.

Once you have created a reference to another application's object library, you can use the VBA Object Browser to view a list of the application's objects.

NoteYou must set the reference for each VBA project that will use this Object Model. Setting the reference for one project won't automatically set it for another project. This is for performance reasons.

Topics in this section

  • To make a reference to another application's object library (VBA/ActiveX)

    Third-party libraries that are registered on a workstation can be accessed from a VBA project.


About Referencing the ActiveX Object Library of Other Applications (VBA/ActiveX)
About Referencing the ActiveX Object Library of Other Applications (VBA/ActiveX)
About Creating an Instance of the Other Application (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Interact with Other Applications and Window APIs > About Interacting with Other Windows Applications (ActiveX) > About Referencing the ActiveX Object Library of Other Applications (VBA/ActiveX) >

To make a reference to another application's object library (VBA/ActiveX)

Third-party libraries that are registered on a workstation can be accessed from a VBA project.

  1. In the VBA IDE, on the menu bar, click the Tools menu [image] References.
  2. In the References dialog box, in the Available References list, locate and click the library you want to utilize with your application.
  3. Click OK to close the dialog box with your changes.


To make a reference to another application's object library (VBA/ActiveX)
About Interacting with Other Windows Applications (ActiveX)
About Programming with Objects from Other Applications (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Interact with Other Applications and Window APIs > About Interacting with Other Windows Applications (ActiveX) >

About Creating an Instance of the Other Application (VBA/ActiveX)

Once you have referenced an application's object library you must create an instance of the application.

This is just a fancy way of saying you need to start the other application programmatically so your code will have valid objects to work with.

To do this, first declare a variable that will represent the other application. You do this the same way as built-in objects, by using a Dim statement. You should qualify the type of application in your Dim statement. For example, this Dim statement declares an object variable of type Excel.Application:

Dim ExcelAppObj as Excel.Application

After you declare the variable, use the Set statement with the New keyword to set the variable equal to a running instance of the application. For example, the following Set statement sets the variable declared above equal to the Excel application. The New keyword starts a new session of Excel.

Set ExcelAppObj = New Excel.Application
NoteSome applications allow only one running instance of the application at a time. Using the New keyword on such an application will establish a reference to the existing instance and will not launch a new session of the application.


About Creating an Instance of the Other Application (VBA/ActiveX)
About Interacting with Other Windows Applications (ActiveX)
About Quitting the Other Application (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Interact with Other Applications and Window APIs > About Interacting with Other Windows Applications (ActiveX) >

About Programming with Objects from Other Applications (VBA/ActiveX)

Now that you have referenced the object library and created a new instance of the application, you can create and manipulate objects in that application.

All the objects, methods, and properties defined by the Object Model are available to you. For example, using the variable declarations from the previous section, the following line of code makes the Excel session visible to the user:

ExcelAppObj.Visible = TRUE

You should familiarize yourself with the Object Model of the application you are writing code for. You can use the VBA Object Browser or the application's help file to learn about any Object Model you are referencing.

Topics in this section

  • About Quitting the Other Application (VBA/ActiveX)

    When you start an application programmatically it takes up memory in the computer. You should quit the application when you have finished using it so system resources can be freed up.


About Programming with Objects from Other Applications (VBA/ActiveX)
About Programming with Objects from Other Applications (VBA/ActiveX)
Example: List AutoCAD attributes on an Excel spreadsheet (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Interact with Other Applications and Window APIs > About Interacting with Other Windows Applications (ActiveX) > About Programming with Objects from Other Applications (VBA/ActiveX) >

About Quitting the Other Application (VBA/ActiveX)

When you start an application programmatically it takes up memory in the computer. You should quit the application when you have finished using it so system resources can be freed up.

Although each Object Model is different, most have a Quit method from the Application object that can be used to close the application cleanly. For example, using the variable declarations from the previous section, the following line of code will quit Excel:

ExcelAppObj.Application.Quit
NoteDestroying or going beyond the scope of the object variable does not necessarily cause the application to terminate. You should always quit the application using the appropriate method to assure proper memory cleanup.

Topics in this section

  • Example: List AutoCAD attributes on an Excel spreadsheet (VBA/ActiveX)

    This example subroutine finds all the block references in the current drawing.


About Quitting the Other Application (VBA/ActiveX)
About Quitting the Other Application (VBA/ActiveX)
To exchange information across ActiveX Object Models (ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Interact with Other Applications and Window APIs > About Interacting with Other Windows Applications (ActiveX) > About Programming with Objects from Other Applications (VBA/ActiveX) > About Quitting the Other Application (VBA/ActiveX) >

Example: List AutoCAD attributes on an Excel spreadsheet (VBA/ActiveX)

This example subroutine finds all the block references in the current drawing.

It then finds the attributes attached to those block references and lists them in an Excel spreadsheet. To run this example, do the following:

  1. Open a drawing containing block references with attributes. (The sample drawing sample/activeX/attrib.dwg contains such block references.)
  2. At the AutoCAD Command prompt, enter VBAIDE and press Enter.

    The VBA IDE is displayed.

  3. In the VBA IDE, on the menu bar, click the Tools menu [image] References.
  4. In the References dialog box, select Microsoft Excel <version_number> Object Model. Click OK.
  5. Copy the following subroutine into a VBA Code window and run it.
    Sub ExtractAtts()
  Dim Excel As Excel.Application
  Dim ExcelSheet As Object
  Dim ExcelWorkbook As Object

  Dim RowNum As Integer
  Dim Header As Boolean
  Dim elem As AcadEntity
  Dim Array1 As Variant
  Dim Count As Integer

  ' Launch Excel.
  Set Excel = New Excel.Application

  ' Create a new workbook and find the active sheet.
  Set ExcelWorkbook = Excel.Workbooks.Add
  Set ExcelSheet = Excel.ActiveSheet
  ExcelWorkbook.SaveAs "Attribute.xls"

  RowNum = 1
  Header = False

  ' Iterate through model space finding
  ' all block references.
  For Each elem In ThisDrawing.ModelSpace
    With elem
      ' When a block reference has been found,
      ' check it for attributes
      If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
        If .HasAttributes Then
          ' Get the attributes
          Array1 = .GetAttributes

          ' Copy the Tagstrings for the
          ' Attributes into Excel
          For Count = LBound(Array1) To UBound(Array1)
            If Header = False Then
              If StrComp(Array1(Count).EntityName, "AcDbAttribute", 1) = 0 Then
                ExcelSheet.Cells(RowNum, Count + 1).value = Array1(Count).TagString
              End If
            End If
          Next Count

          RowNum = RowNum + 1
          For Count = LBound(Array1) To UBound(Array1)
            ExcelSheet.Cells(RowNum, Count + 1).value = Array1(Count).textString
          Next Count

          Header = True
        End If
      End If
    End With
  Next elem
  Excel.Application.Quit
End Sub


Example: List AutoCAD attributes on an Excel spreadsheet (VBA/ActiveX)
About Interacting with Other Windows Applications (ActiveX)
About Accessing Windows APIs from VBA (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > Interact with Other Applications and Window APIs > About Interacting with Other Windows Applications (ActiveX) >

To exchange information across ActiveX Object Models (ActiveX)

Other programs that support ActiveX can communicate with AutoCAD using the AutoCAD ActiveX API.

  1. Reference the other applications' ActiveX Object Model.

    This will make your code aware of the names and relationships of the objects in the other Object Model.

  2. Create an instance of the other application.

    This will create (instantiate) valid objects for the basic objects in the other Object Model.

  3. Write your code utilizing both the AutoCAD Object Model and the other applications' Object Model.

    This is where the exchange of data takes place.


About Accessing Windows APIs from VBA (VBA/ActiveX)

The Windows® API procedures are available to most Windows applications. These procedures allow you to expand the capabilities of your application.

Through the Windows APIs you can obtain information about the current system, such as which other programs are installed or running on the system, where information is located on a system, and what the current control settings are for the system. You can also access joystick, multimedia, and sound controls. These tasks represent but a few of the many capabilities provided by the Windows APIs.

To use a Windows API, you must first declare the API in your application. This is done with the Declare statement. The Declare statement requires several pieces of information:

  • The name of the dynamic link library (DLL) containing the procedure you want to use
  • The name of the procedure as it appears in the DLL
  • The name of the procedure as you want to use it in your application
  • The parameters the procedure expects to receive
  • The return value data type (if the procedure you are calling is a function)

You can place the Declare statement in any of your VBA modules. If you place it in a standard module, the procedure will be available to any module in your application, unless you limit its scope by using the keyword Private. If you place the Declare statement in a class or form module, the procedure will only be available in that module. Once a procedure has been declared, you can call that procedure as you would any other procedure in your application.

Getting a Declare statement just right is a difficult skill to learn. Getting a Declare statement wrong is easy, but it often comes with dire consequences. Be sure to save any information in active applications before you try out a new Declare statement.

To help you with your Declare statements, Microsoft provides a file listing of many of the declarations most commonly used. The file is called Win32api.txt and comes with Visual Basic 6 and Microsoft Office. You can search this file for the procedure you need and copy the Declare statement provided into your code.

The Microsoft VBA documentation contains more information on the Declare statement and an example of its use. The Microsoft Windows API Reference is available as part of the Microsoft Developer Network (MSDN) CD subscription and provides a reference to all the available procedures in the Windows APIs. Dan Appleman's book Visual Basic Programmer's Guide to the Win32 API is also an excellent resource directed at the Visual Basic 6 programmer.


ActiveX/VBA Tutorial: Design the Garden Path

Topics in this section

  • Tutorial: Design the Garden Path

    This tutorial demonstrates how to use ActiveX and Visual Basic for Applications and how to add a macro to AutoCAD.

  • About Checking Your Environment

    For the tutorial, you need the AutoCAD VBA integrated development environment (VBA IDE).

  • About Defining the Goal

    Your goal in this tutorial is to develop a new macro for AutoCAD that draws a garden path and fills it with circular concrete tiles.

  • About Writing the First Function

    You develop the Gardenpath macro using a series of functions and subroutines.

  • About Getting Input

    The Gardenpath macro asks the user where to draw the path, how wide to make the path, how large the concrete tiles are, and how closely to space those tiles.

  • About Drawing the Path Outline

    Now that you have acquired the location and width of the path, you can draw its outline.

  • About Drawing the Tiles

    Now that you have developed the user input subroutine, along with the subroutine to draw the outline, you are ready to fill the path with circular tiles. This task requires some geometry.

  • About Putting It All Together

    You are ready to combine the subroutines into the Gardenpath macro.

  • About Stepping Through the Code

    Now run the macro, stepping through the code as it executes.

  • About Executing the Macro

    You do not need to step through the code whenever you run the macro.

  • About Adding a Dialog Box Interface

    The Gardenpath macro has been written to accept command line input.


Tutorial: Design the Garden Path (VBA/ActiveX)

This tutorial demonstrates how to use ActiveX and Visual Basic for Applications (VBA) and how to add a macro to AutoCAD.

The tutorial is oriented toward landscape architecture, but the concepts in the tutorial are relevant to any application area.

Prerequisites

  • Proficient with AutoCAD
  • Novice VBA programmer


About Checking Your Environment (VBA/ActiveX)

For the tutorial, you need the AutoCAD® VBA integrated development environment (VBA IDE).

The VBA IDE is installed automatically with the Full option of the AutoCAD installation program. If you selected the Custom option when you installed AutoCAD, the VBA IDE might not be installed; you might need to install it by running the AutoCAD installation program again.

Topics in this section

  • To test if the VBA IDE is installed (VBA/ActiveX)

    Before you can create or load a VBA project, the VBA IDE must first be installed.


To test if the VBA IDE is installed (VBA/ActiveX)

Before you can create or load a VBA project, the VBA IDE must first be installed.

  • At the AutoCAD Command prompt, enter vbaide and press Enter.

    If the VBA IDE opens, the VBA IDE is installed. If you receive the message “AutoCAD VBA is not currently installed,” the VBA IDE is not installed.


About Defining the Goal (VBA/ActiveX)

Your goal in this tutorial is to develop a new macro for AutoCAD that draws a garden path and fills it with circular concrete tiles.

Your new macro will have the following prompt sequence:

Command: gardenpath

Start point of path: The user will specify the start point

Endpoint of path: The user will specify the endpoint

Half width of path: The user will specify a number

Radius of tiles: The user will specify a number

Spacing between tiles: The user will specify a number

Your macro will first prompt the user to enter the start point and endpoint to specify the centerline of a path. Next, it will prompt the user to enter the half width of the path and the radius of the circular tiles. Finally, the user will enter the spacing between the tiles. You are using the half width of the path rather than the full width because it is easier to visualize the half width from the centerline of the path.


About Writing the First Function (VBA/ActiveX)

You develop the Gardenpath macro using a series of functions and subroutines.

Many subroutines require the manipulation of angles. Because ActiveX specifies angles in radians, but most users think of angles in terms of degrees, begin by creating a function that converts degrees to radians.

Topics in this section

  • To convert degrees to radians (VBA/ActiveX)

    Many ActiveX methods that accept angular values require you to provide radians and not degrees.

  • To calculate the distance between two points (VBA/ActiveX)

    Calculating the distance between two points can be helpful in determining the midpoint along a given axis.


To convert degrees to radians (VBA/ActiveX)

Many ActiveX methods that accept angular values require you to provide radians and not degrees.

  1. At the AutoCAD Command prompt, enter vbaide and press Enter.
  2. In the VBA IDE, on the View menu, click Code to open the Code window.
  3. Enter the following code in the Code window:
    Const pi = 3.14159

' Convert angle in degrees to radians
Function dtr(a As Double) As Double
  dtr = (a / 180) * pi
End Function

    Notice that as soon as you press Enter after entering the line Function dtr(a As Double) As Double, End Function is added automatically. This ensures that all subroutines and functions have an associated End statement.

    Now look at the code. First, the constant pi is defined as the value 3.14159. This allows you to use the word pi instead of typing 3.14159 each time you need to use the value.

    Next, you are defining a function called dtr (short for degrees to radians). The function dtr takes one argument, a, which is the angle in degrees. The result is obtained by dividing the angle in degrees by 180, and then multiplying this value by pi. The line that begins with a single quote is a comment; VBA ignores all text on a line after a single quote.

    This function can now be used in other subroutines throughout your project

  4. Click File [image] Save Global1.
  5. In the Save As dialog box, in the File Name text box, enter gardenpath and specify a location for the project. Click Save.


To calculate the distance between two points (VBA/ActiveX)

Calculating the distance between two points can be helpful in determining the midpoint along a given axis.

  1. Enter the following code after the dtr function:
    ' Calculate distance between two points
Function distance(sp As Variant, ep As Variant) As Double
  Dim x As Double
  Dim y As Double
  Dim z As Double
  x = sp(0) - ep(0)
  y = sp(1) - ep(1)
  z = sp(2) - ep(2)

  distance = Sqr((Sqr((x ^ 2) + (y ^ 2)) ^ 2) + (z ^ 2))
End Function
  2. Save the project.


About Getting Input (VBA/ActiveX)

The Gardenpath macro asks the user where to draw the path, how wide to make the path, how large the concrete tiles are, and how closely to space those tiles.

You define a subroutine that asks the user for all of these items and then computes various numbers to use in the rest of the macro.

In this subroutine, you use the user input methods found in the Utility object.

Topics in this section

  • About Declaring Variables (VBA/ActiveX)

    The next subroutine uses several variables. All variables must be declared before the subroutine can access them.

  • About Defining the gpuser Subroutine (VBA/ActiveX)

    The gpuser subroutine prompts the user for information necessary for drawing a garden path.


About Declaring Variables (VBA/ActiveX)

The next subroutine uses several variables. All variables must be declared before the subroutine can access them.

In the VBA IDE, enter the following code in the Code window, immediately after the line Const pi = 3.14159:

Private sp(0 To 2) As Double
Private ep(0 To 2) As Double
Private hwidth As Double
Private trad As Double
Private tspac As Double
Private pangle As Double
Private plength As Double
Private totalwidth As Double
Private angp90 As Double
Private angm90 As Double

Now look at the two drop-down lists at the top of the Code window. These lists are called the Object Box and the Procedure/Event Box and currently display the terms (General) and (Declarations), respectively. These lists display the current section of the code you are working in, and enable you to move quickly to a different section by simply selecting one from the list. The (Declarations) section is the appropriate place to declare variables that you will use in more than one subroutine.


About Defining the gpuser Subroutine (VBA/ActiveX)

The gpuser subroutine prompts the user for information necessary for drawing a garden path.

Enter the following code after the distance function:

' Acquire information for garden path
Private Sub gpuser()
  Dim varRet As Variant

  varRet = ThisDrawing.Utility.GetPoint( , "Start point of path: ")
  sp(0) = varRet(0)
  sp(1) = varRet(1)
  sp(2) = varRet(2)

  varRet = ThisDrawing.Utility.GetPoint( , "Endpoint of path: ")
  ep(0) = varRet(0)
  ep(1) = varRet(1)
  ep(2) = varRet(2)

  hwidth = ThisDrawing.Utility.GetDistance(sp, "Half width of path: ")
  trad = ThisDrawing.Utility.GetDistance(sp, "Radius of tiles: ")
  tspac = ThisDrawing.Utility.GetDistance(sp, "Spacing between tiles: ")
  pangle = ThisDrawing.Utility.AngleFromXAxis(sp, ep)

  totalwidth = 2 * hwidth
  plength = distance(sp, ep)
  angp90 = pangle + dtr(90)
  angm90 = pangle - dtr(90)
End Sub

In the gpuser subroutine, the line Dim varRet As Variant declares the variable varRet. Because this variable is used only in this subroutine, it can be declared here locally, instead of in the (Declarations) section.

The next line, varRet = ThisDrawing.Utility.GetPoint( , "Start point of path: "), calls the GetPoint method. The underscore in the line is intended to make a long line easier to read, and tells VBA to read the next line as if it were on the same line. You can remove the underscore by placing the code all on one line.

To access the GetPoint method, you must first go through the ThisDrawing object that represents the current drawing. After entering ThisDrawing you enter a period (.), which means that you are going to access something within that object. After you type the period, you enter Utility and another period. Once again, you are going to access something within the Utility object. Finally, enter GetPoint, which is the name of the method you are calling.

The GetPoint method takes two parameters. The first parameter is optional and will not be used. Leave the parameter blank and simply type a comma to mark its spot. The second parameter is the prompt, which is also optional. For this parameter, you entered a string prompting the user to enter the start point. The point the user enters is put into the varRet variable. The next three lines of the subroutine copy the point returned by the user into the sp array.

The endpoint is returned in the same manner.

The GetDistance method is used to obtain the half width of the path (hwidth), the tile radius (trad), and the spacing between the tiles (tspac). The GetDistance method takes two parameters. The first parameter is a base point. For this value, you supply the start point. The second parameter is the prompt, for which you provide a string prompting the user for the appropriate input. The interesting thing about the GetDistance method is that it can return either a value entered on the command line or the distance between a point selected in AutoCAD and the start point.

The subroutine goes on to calculate several variables used later in the macro. The pangle variable is set to the angle from the start point to the endpoint and is found by using the AngleFromXAxis method. The width of the path is found by multiplying the half width by two. The plength variable is set to the length of the path and is found using the distance function you entered earlier. Finally, calculate and save the angle of the path plus and minus 90 degrees in angp90 and angm90, respectively.

The following illustration shows how the variables obtained by gpuser specify the dimensions of the path.

Save your work.


About Drawing the Path Outline (VBA/ActiveX)

Now that you have acquired the location and width of the path, you can draw its outline.

Add the following code below the gpuser subroutine:

' Draw outline of path
Private Sub drawout()
  Dim points(0 To 9) As Double
  Dim pline As AcadLWPolyline
  Dim varRet As Variant
  varRet = ThisDrawing.Utility.PolarPoint(sp, angm90, hwidth)
  points(0) = varRet(0)
  points(1) = varRet(1)
  points(8) = varRet(0)
  points(9) = varRet(1)

  varRet = ThisDrawing.Utility.PolarPoint(varRet, pangle, plength)
  points(2) = varRet(0)
  points(3) = varRet(1)

  varRet = ThisDrawing.Utility.PolarPoint(varRet, angp90, totalwidth)
  points(4) = varRet(0)
  points(5) = varRet(1)

  varRet = ThisDrawing.Utility.PolarPoint(varRet, pangle + dtr(180), plength)
  points(6) = varRet(0)
  points(7) = varRet(1)

  Set pline = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
End Sub

This subroutine draws the outline of the path using the AddLightweightPolyline method. This method takes one parameter: an array of points that make up the polyline. You must find all the points that make up the polyline object and place them into an array in the order they are to be drawn. For this polyline, the points needed are the corners of the path.

To find the corners of the path, use the PolarPoint method. This method finds a point that is a given angle and distance from a base point. Begin with the start point (sp) and find the first corner of the path, working in a counterclockwise direction. This corner will be at a distance of half the width of the path (hwidth) and at -90 degrees from the path angle. Because you want to draw a closed rectangle for the path, this point becomes the first and last point in the array. Hence, the X and Y coordinates returned from the PolarPoint method are moved into the first and last positions in the points array.

The remaining corners of the path are found in the same manner using the length and width of the path (plength and width), and the angle of the path. Every time the PolarPoint method is called, the coordinates returned (varRet) are copied into the points array.

Once all the corners have been identified in the points array, the AddLightweightPolyline method is called. Notice that this method is called from the ModelSpace object. If you were to run this macro, you would also notice that the polyline is not yet visible in AutoCAD. The polyline will not become visible until you update the display, which you will do later.


About Drawing the Tiles (VBA/ActiveX)

Now that you have developed the user input subroutine, along with the subroutine to draw the outline, you are ready to fill the path with circular tiles. This task requires some geometry.

In the VBA IDE, enter the following code in the Code window, after the drawout subroutine:

' Place one row of tiles the given distance along path
' and possibly offset it
Private Sub drow(pd As Double, offset As Double)
  Dim pfirst(0 To 2) As Double
  Dim pctile(0 To 2) As Double
  Dim pltile(0 To 2) As Double
  Dim cir As AcadCircle

  Dim varRet As Variant
  varRet = ThisDrawing.Utility.PolarPoint(sp, pangle, pd)
  pfirst(0) = varRet(0)
  pfirst(1) = varRet(1)
  pfirst(2) = varRet(2)

  varRet = ThisDrawing.Utility.PolarPoint(pfirst, angp90, offset)
  pctile(0) = varRet(0)
  pctile(1) = varRet(1)
  pctile(2) = varRet(2)
  pltile(0) = pctile(0)
  pltile(1) = pctile(1)
  pltile(2) = pctile(2)

  Do While distance(pfirst, pltile) < (hwidth - trad)
    Set cir = ThisDrawing.ModelSpace.AddCircle(pltile, trad)
    varRet = ThisDrawing.Utility.PolarPoint(pltile, angp90, (tspac + trad + trad))
    pltile(0) = varRet(0)
    pltile(1) = varRet(1)
    pltile(2) = varRet(2)
  Loop

  varRet = ThisDrawing.Utility.PolarPoint(pctile, angm90, tspac + trad + trad)
  pltile(0) = varRet(0)
  pltile(1) = varRet(1)
  pltile(2) = varRet(2)

  Do While distance(pfirst, pltile) < (hwidth - trad)
    Set cir = ThisDrawing.ModelSpace.AddCircle(pltile, trad)
    varRet = ThisDrawing.Utility.PolarPoint( _
    pltile, angm90, (tspac + trad + trad))
    pltile(0) = varRet(0)
    pltile(1) = varRet(1)
    pltile(2) = varRet(2)
  Loop
End Sub

' Draw the rows of tiles
Private Sub drawtiles()
  Dim pdist As Double
  Dim offset As Double
  pdist = trad + tspac
  offset = 0

  Do While pdist <= (plength - trad)
    drow pdist, offset
    pdist = pdist + ((tspac + trad + trad) * Sin(dtr(60)))

    If offset = 0 Then
      offset = (tspac + trad + trad) * Cos(dtr(60))
    Else
      offset = 0
    End If
  Loop
End Sub

To understand how these subroutines work, refer to the following illustration. The subroutine drow draws a row of tiles at a given distance along the path specified by its first argument, and offsets the row perpendicular to the path by a distance specified by its second argument. You want to offset the tiles on alternate rows to cover more space and make a more pleasing arrangement.

The drow subroutine finds the location for the first row by using the PolarPoint method to move along the path by the distance specified by the first argument. The subroutine then uses the PolarPoint method again to move perpendicularly to the path for the offset. The subroutine uses the While statement to continue to draw circles until the edge of the path is encountered. The PolarPoint method in the first While statement moves on to the next tile location by spacing a distance of two tile radii (trad) and one intertile space (tspac). A second while loop then draws the tiles in the row in the other direction until the other edge is encountered.

The drawtiles subroutine calls drow repeatedly to draw all the tile rows. The subroutine While loop steps along the path, calling drow for each row. Tiles in adjacent rows form equilateral triangles, as shown in the previous illustration. The edges of these triangles are equal to twice the tile radius plus the spacing between the tiles. Therefore, by trigonometry, the distance along the path between rows is the sine of 60 degrees multiplied by this quantity, and the offset for odd rows is the cosine of 60 degrees multiplied by this quantity.

The If statement is used in drawtiles to offset every other row. If the offset is equal to 0, set it to the spacing between the centers of tiles multiplied by the cosine of 60 degrees, as explained earlier. If the offset is not equal to 0, set it to 0. This alternates the offset on the rows as you want.

Save your work.


About Putting It All Together (VBA/ActiveX)

You are ready to combine the subroutines into the Gardenpath macro.

In the VBA IDE, enter the following code in the Code window, after the drawtiles subroutine:

' Execute command, calling constituent functions
Sub gardenpath()
  Dim sblip As Variant
  Dim scmde As Variant
  gpuser
  sblip = ThisDrawing.GetVariable("blipmode")
  scmde = ThisDrawing.GetVariable("cmdecho")
  ThisDrawing.SetVariable "blipmode", 0
  ThisDrawing.SetVariable "cmdecho", 0
  drawout
  drawtiles
  ThisDrawing.SetVariable "blipmode", sblip
  ThisDrawing.SetVariable "cmdecho", scmde
End Sub

The path subroutine calls gpuser to gather the necessary input. The GetVariable method is then used to obtain the current values of the BLIPMODE and CMDECHO system variables, and saves these values as sblip and scmde. The subroutine then uses the SetVariable method to set both of these system variables to 0, thereby disabling blips and command echoing. Next, the path is drawn using the drawout and drawtiles subroutines. Finally, the SetVariable method is used to reset the system variables to their original values.

You may notice that this is the only subroutine you have entered that did not begin with a Private keyword, which ensures the subroutine can only be called from within the current module. Because the gardenpath subroutine must be available to the user, you should omit the Private keyword.

Save your work.


About Stepping Through the Code (VBA/ActiveX)

Now run the macro, stepping through the code as it executes.

From AutoCAD, click Manage tab [image] Applications panel [image] Run VBA Macro. From the Macros dialog box select ThisDrawing.gardenpath and click Step Into.

The VBA IDE is brought to the front of the screen, with the first line of the gardenpath macro highlighted. The highlighted line is the line of code that is about to be executed. To execute the line, press F8. The next line of code to be executed is the gpuser subroutine. To step into the gpuser subroutine, press F8 again.

Now you are at the beginning of the gpuser routine. Press F8 one more time to highlight the first GetPoint method. Before you execute this line, open the Locals window by clicking View Locals Window. This window is displayed at the bottom of the VBA IDE. All the local variables and their values are displayed in the Locals window while the macro is executing.

Now press F8 to execute the GetPoint method. Notice that the highlight disappears and no new code is presented. This is because the GetPoint method is waiting for the user to enter a point in AutoCAD. Switch back to the AutoCAD window. You see the prompt you specified in the GetPoint call on the command line. Enter a point.

Control now returns to the macro. The line following the call to the GetPoint method is highlighted. Continue stepping through the code by pressing F8. Remember to switch back to the AutoCAD window when you are entering information.


About Executing the Macro (VBA/ActiveX)

You do not need to step through the code whenever you run the macro.

You can run the macro from AutoCAD by clicking Manage tab Applications panel Run VBA Macro, selecting a macro, and then clicking Run. This allows you to see the flow of execution the way a user would see it. Run the macro from AutoCAD, entering the following values:

Start point of the path: 2, 2

Endpoint of the path: 9, 8

Half width of the path: 2

Radius of tiles: .2

Spacing between tiles: .1

This example should draw a garden path as shown in the following figure:

You can experiment with the Gardenpath macro by specifying the various inputs.


About Adding a Dialog Box Interface (VBA/ActiveX)

The Gardenpath macro has been written to accept command line input.

To add dialog boxes, you use forms in the VBA IDE.

First, copy the finished version of gardenpath.dvb to another file, gpdialog.dvb. Then drag gpdialog.dvb into AutoCAD.

Topics in this section

  • About Creating the Dialog Box (VBA/ActiveX)

    The dialog box you create contains two option buttons (if you select one, the other is cleared) for choosing the tile shape: circle or polygon.

  • About Using the Project Window to Navigate Your Project (VBA/ActiveX)

    In the VBA IDE, the Project Explorer window contains the name and location of the project, a folder named AutoCAD Objects, and a folder named Forms. (You might need to click Toggle Folders to see the folders.)

  • To modify the existing code (VBA/ActiveX)

    Modifying code and the user form is handled using the Code and UserForm windows of the VBA IDE.

  • To add event handlers for the dialog box (VBA/ActiveX)

    Events are triggered when a control is interacted with.


About Adding a Dialog Box Interface (VBA/ActiveX)
About Adding a Dialog Box Interface (VBA/ActiveX)
To create a dialog box from the VBA IDE (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) >

About Creating the Dialog Box (VBA/ActiveX)

The dialog box you create contains two option buttons (if you select one, the other is cleared) for choosing the tile shape: circle or polygon.

The dialog box also contains three text boxes for entering the following numeric values: the radius of the tiles, the spacing between the tiles, and the number of sides on the tile (which is available only if the Polygon option button is selected).

Topics in this section

  • To create a dialog box from the VBA IDE (VBA/ActiveX)

    User forms for a project are created from the VBA IDE.

  • To set the properties for the radio button controls (VBA/ActiveX)

    Radio buttons allow you to provide basic and limited choices to a user form.

  • To set the properties for the label controls (VBA/ActiveX)

    Labels allow you to provide information about a control on a user form.

  • To set the properties for the text box controls (VBA/ActiveX)

    Text boxes allow the user to provide custom values to the program.

  • To set the properties for the command button controls and the form window (VBA/ActiveX)

    Command buttons allow for starting an action from a user form.


About Creating the Dialog Box (VBA/ActiveX)
About Creating the Dialog Box (VBA/ActiveX)
To set the properties for the radio button controls (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) > About Creating the Dialog Box (VBA/ActiveX) >

To create a dialog box from the VBA IDE (VBA/ActiveX)

User forms for a project are created from the VBA IDE.

  1. In the VBA IDE, on the menu bar, click Insert menu [image] User Form to open a new form.

    Two windows are displayed; a toolbox and a blank user form.

  2. One by one, select and drag the following controls from the toolbox and place them on the user form.

    You should place

    • Two option buttons ( [image])
    • Three labels ( [image])
    • Three text boxes ( [image])
    • Two command buttons ( [image])

    As illustrated on the following form:

  3. Close the toolbox.


To create a dialog box from the VBA IDE (VBA/ActiveX)
About Creating the Dialog Box (VBA/ActiveX)
To set the properties for the label controls (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) > About Creating the Dialog Box (VBA/ActiveX) >

To set the properties for the radio button controls (VBA/ActiveX)

Radio buttons allow you to provide basic and limited choices to a user form.

  1. On the user form, select the OptionButton1 control.
  2. On the menu bar, click the View menu [image] Properties Window.
  3. In the Properties window, change the following properties for OptionButton1:
    • (Name) = gp_poly
    • Caption = Polygon
    • ControlTipText = Polygon Tile Shape
    • Accelerator = P
  4. On the user form, select the OptionButton2 control.
  5. In the Properties window, change the following properties for OptionButton2:
    • (Name) = gp_circ
    • Caption = Circle
    • ControlTipText = Circle Tile Shape
    • Accelerator = I


To set the properties for the radio button controls (VBA/ActiveX)
About Creating the Dialog Box (VBA/ActiveX)
To set the properties for the text box controls (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) > About Creating the Dialog Box (VBA/ActiveX) >

To set the properties for the label controls (VBA/ActiveX)

Labels allow you to provide information about a control on a user form.

  1. On the user form, select the Label1 control.
  2. On the menu bar, click the View menu [image] Properties Window.
  3. In the Properties window, change the following properties for Label1:
    • (Name) = label_trad
    • Caption = Radius of tiles
    • TabStop = True
  4. On the user form, select the Label2 control.
  5. In the Properties window, change the following properties for Label2:
    • (Name) = label_tspac
    • Caption = Space between tiles
    • TabStop = True
  6. On the user form, select the Label3 control.
  7. In the Properties window, change the following properties for Label3:
    • (Name) = label_tsides
    • Caption = Number of sides
    • TabStop = True


To set the properties for the label controls (VBA/ActiveX)
About Creating the Dialog Box (VBA/ActiveX)
To set the properties for the command button controls and the form window (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) > About Creating the Dialog Box (VBA/ActiveX) >

To set the properties for the text box controls (VBA/ActiveX)

Text boxes allow the user to provide custom values to the program.

  1. On the user form, select the TextBox1 control.
  2. On the menu bar, click the View menu [image] Properties Window.
  3. In the Properties window, change the following properties for TextBox1:
    • (Name) = gp_trad
  4. On the user form, select the TextBox2 control.
  5. In the Properties window, change the following properties for TextBox2:
    • (Name) = gp_tspac
  6. On the user form, select the TextBox3 control.
  7. In the Properties window, change the following properties for TextBox3:
    • (Name) = gp_tsides


To set the properties for the text box controls (VBA/ActiveX)
About Creating the Dialog Box (VBA/ActiveX)
About Using the Project Window to Navigate Your Project (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) > About Creating the Dialog Box (VBA/ActiveX) >

To set the properties for the command button controls and the form window (VBA/ActiveX)

Command buttons allow for starting an action from a user form.

  1. On the user form, select the CommandButton1 control.
  2. On the menu bar, click the View menu [image] Properties Window.
  3. In the Properties window, change the following properties for CommandButton1:
    • (Name) = accept
    • Caption = OK
    • ControlTipText = Accept the options
    • Accelerator = O
    • Default = True
  4. On the user form, select the CommandButton2 control.
  5. In the Properties window, change the following properties for CommandButton2:
    • (Name) = cancel
    • Caption = Cancel
    • ControlTipText = Cancel the operation
    • Accelerator = C
  6. Select the user form itself by clicking on the background of the form, away from any control.
  7. In the Properties window, change the following properties for the form:
    • (Name) = gpDialog
    • Caption = Garden Path

    Your form should now look like this:

  8. Save the changes to the user form.


To set the properties for the command button controls and the form window (VBA/ActiveX)
About Adding a Dialog Box Interface (VBA/ActiveX)
To modify the existing code (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) >

About Using the Project Window to Navigate Your Project (VBA/ActiveX)

In the VBA IDE, the Project Explorer window contains the name and location of the project, a folder named AutoCAD Objects, and a folder named Forms. (You might need to click Toggle Folders to see the folders.)

When you open the AutoCAD Objects folder (it may already be open), you see a drawing icon and the name ThisDrawing. When you open the Forms folder (it may already be open), you see a form icon and the name gpDialog, the form you created.

You can use the Project Explorer window to navigate through code and help you identify where you are working. For example, to view the code associated with the form you created, highlight gpDialog in the Project Explorer window and click View Code.

The Code window for the form is displayed.

Now highlight ThisDrawing in the Project Explorer window. You can view the code by clicking View Code. All the code you have already entered is in this window.


About Using the Project Window to Navigate Your Project (VBA/ActiveX)
About Adding a Dialog Box Interface (VBA/ActiveX)
To add event handlers for the dialog box (VBA/ActiveX)
Autodesk AutoCAD 2015 : ActiveX Developer's Guide > ActiveX/VBA Tutorial: Design the Garden Path > About Adding a Dialog Box Interface (VBA/ActiveX) >

To modify the existing code (VBA/ActiveX)

Modifying code and the user form is handled using the Code and UserForm windows of the VBA IDE.

  1. Open the code for ThisDrawing, if it is not already open.
  2. Update the following lines in the Declarations section:
    Public trad As Double       ' Updated
Public tspac As Double      ' Updated
Public tsides As Integer    ' Add
Public tshape As String     ' Add

    Because the code in the form accesses trad and tspac, you update their definitions to make them public. Private variables are available only in the module in which they are defined, so the variables need to be changed to public. Additionally, you have added tsides for the number of polygon tile sides and tshape for the user's choice of tile shape, which is either circle or polygon.

  3. Go to the gpuser subroutine. Remove the two lines that obtain the radius of the tiles and the spacing between the tiles, because this information comes from the form. Specifically, remove the following:
    trad = ThisDrawing.Utility.GetDistance(sp, "Radius of tiles: ")
tspac = ThisDrawing.Utility.GetDistance(sp, "Spacing between tiles: ")
  4. Add the lines that load and display the form. Add the following lines in place of the lines removed in step 3:
    Load gpDialog
gpDialog.Show
  5. Add a subroutine to the end of the code file that draws either the circular tiles or the polygon tiles:
    ' Draw the tile with the designated shape
Sub DrawShape(pltile)
  Dim angleSegment As Double
  Dim currentAngle As Double
  Dim angleInRadians As Double
  Dim currentSide As Integer
  Dim varRet As Variant
  Dim aCircle As AcadCircle
  Dim aPolygon As AcadLWPolyline
  ReDim points(1 To tsides * 2) As Double

  ' Branch based on the type of shape to draw
  Select Case tshape
    Case "Circle"
      Set aCircle = ThisDrawing.ModelSpace.AddCircle(pltile, trad)
    Case "Polygon"
      angleSegment = 360 / tsides
      currentAngle = 0

      For currentSide = 0 To (tsides - 1)
        angleInRadians = dtr(currentAngle)
        varRet = ThisDrawing.Utility.PolarPoint(pltile, angleInRadians, trad)
        points((currentSide * 2) + 1) = varRet(0)
        points((currentSide * 2) + 2) = varRet(1)
        currentAngle = currentAngle + angleSegment
      Next currentSide

      Set aPolygon = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
      aPolygon.Closed = True
  End Select
End Sub

    This subroutine uses a Select Case statement to branch control of the program based on the type of shape to draw. The tshape variable is used to determine the type of shape.

  6. Next, go to the drow subroutine. Find the two occurrences of the following line:
    Set cir = ThisDrawing.ModelSpace.AddCircle(pltile, trad)

    Change these lines to draw the appropriate shape tile, as follows:

    DrawShape (pltile)       ' Updated


To add event handlers for the dialog box (VBA/ActiveX)

Events are triggered when a control is interacted with.

  1. Open the Code window for gpDialog.
  2. Enter the following code at the top of the window:
    Private Sub gp_poly_Click()
  gp_tsides.Enabled = True
  ThisDrawing.tshape = "Polygon"
End Sub

Private Sub gp_circ_Click()
  gp_tsides.Enabled = False
  ThisDrawing.tshape = "Circle"
End Sub

    Notice that the subroutines gp_poly_Click() and gp_circ_Click() are named after the two option controls you added earlier, with the addition of _Click. These subroutines are automatically executed when the user clicks the respective control. Also notice that the Object Box lists the controls on the form, sorted alphabetically by Name property.

  3. Place your cursor on the Private Sub gp_poly_Click() line and open the Procedure/Event Box.

    You see a list of all the events that you can respond to for the gp_polyoption control. The two subroutines you entered handle the Click event. You can also add code to respond to the DblClick event that would automatically be executed when the user double-clicked the control. You can add code for any of the events listed. These types of subroutines are called event handlers.

    Look at the code you entered for these two event handlers. The first event handler responds to the Click event for the gp_poly option control. The first line of code enables the text box for the number of sides. This text box is available only for polygons, so it is not enabled unless you select the Polygon control. The next line of code sets the tshape variable to Polygon.

    The second event handler responds to the Click event for the gp_circ option control. This handler disables the text box for the number of sides and sets the tshape variable to Circle.

  4. Add the following event handler for the OK button:
    Private Sub accept_Click()
  If ThisDrawing.tshape = "Polygon" Then
    ThisDrawing.tsides = CInt(gp_tsides.text)
    If (ThisDrawing.tsides < 3#) Or (ThisDrawing.tsides > 1024#) Then
      MsgBox "Enter a value between 3 and " & _
             "1024 for the number of sides."
      Exit Sub
    End If
  End If

  ThisDrawing.trad = CDbl(gp_trad.text)
  ThisDrawing.tspac = CDbl(gp_tspac.text)

  If ThisDrawing.trad < 0# Then
    MsgBox "Enter a positive value for the radius."
    Exit Sub
  End If

  If (ThisDrawing.tspac < 0#) Then
    MsgBox "Enter a positive value for the spacing."
    Exit Sub
  End If

  GPDialog.Hide
End Sub

    This code tests whether the final choice of shape was polygon. If so, the code retrieves the number of sides from the gp_tsides control. The value the user enters is stored in the Text property. Because it is stored as a text string, you convert the string to the integer equivalent using the CInt function. Once obtained, the event handler tests the range of the value to make sure it is between 3 and 1024. If it is not, a message is displayed and the event handler is exited without further processing. The result is that a message is displayed and the user is given an opportunity to change the value. After the OK button is clicked again, this event handler triggers and tests the value again.

    The macro obtains radius and spacing values, but these values are doubles, not integers, and are obtained using the CDbl function. These values are also tested to make sure they are positive.

    After the values are obtained and verified, the gpDialog.Hide statement hides the form, passing control back to the subroutine that first called the form.

  5. Add the following event handler for the Cancel button:
    Private Sub cancel_Click()
  Unload Me
  End
End Sub

    This simple event handler unloads the form and ends the entire macro.

    The only thing you have not done is add the initial values for the form. There is an event called Initialize that applies to the form. It is executed when the form is first loaded.

  6. Add the following event handler for the form initialization:
    Private Sub UserForm_Initialize()
  gp_circ.Value = True
  gp_trad.Text = ".2"
  gp_tspac.Text = ".1"
  gp_tsides.Text = "5"
  gp_tsides.Enabled = False
  ThisDrawing.tsides = 5
End Sub

    This code sets the initial values for the form and for the tsides variable. The tsides variable must be set to a positive number greater than 3, even if the user selects a circle. To understand this, look in the DrawShape subroutine that you entered earlier. There is a variable there called points that is defined using the number of sides for the polygon. That variable gets memory allocated to it whether or not a polygon shape has been requested. Because of this, tsides must have a valid range defined for it. The user is free to change this value during macro execution.

    You can now save and run the macro from AutoCAD.


Visual LISP and ActiveX/VBA Comparison

Topics in this section

  • AutoLISP and ActiveX/VBA Comparison Reference

    Comparison between the AutoLISP functions, and the similar ActiveX and VBA functions and operators.


AutoLISP and ActiveX/VBA Comparison Reference (VBA/ActiveX)

Comparison between the AutoLISP functions, and the similar ActiveX® and VBA functions and operators.

The ActiveX Automation equivalents are indicated by "AutoCAD.Application." and the VBA equivalents are listed as a function or operator.

Visual LISP and ActiveX/VBA Comparison
AutoLISP function | ActiveX or VBA equivalent
+ (addition) | + (addition operator)
- (subtraction) | - (subtraction operator)
* (multiplication) | * (multiplication operator)
/ (division) | / (division operator)
= (equal to) | = (equal to comparison operator)
/= (not equal to) | <> (not equal to comparison operator)
< (less than) | < (less than comparison operator)
<= (less than or equal to) | <= (less than or equal to comparison operator)
> (greater than) | > (greater than comparison operator)
>= (greater than or equal to) | >= (greater than or equal to comparison operator)
~ (bitwise not) | Not operator
1+ (increment) | Use + (addition operator)
1- (decrement) | Use - (subtraction operator)
abs | Abs function
acad_colordlg | Not provided
acad_helpdlg | Search for HELP in the online Help index
acad_strlsort | Search for SORT in the online Help index
action_tile | Use the Dialog Editor
add_list | Use the Dialog Editor
ads | AutoCAD.Application.ListADS method
alert | MsgBox function
and | And operator
angle | AutoCAD.Application.ActiveDocument.Utility.AngleFromXAxis method
angtof | AutoCAD.Application.ActiveDocument.Utility.AngleToReal method
angtos | AutoCAD.Application.ActiveDocument.Utility.AngleToString method
append | Use array manipulation functions
apply | Not provided
arx | AutoCAD.Application.ListARX method
arxload | AutoCAD.Application.LoadARX method
arxunload | AutoCAD.Application.UnloadARX method
ascii | Asc function
assoc | Not provided
atan | Atn function
atof | CDbl Function
atoi | CInt Function
atom | Search for IS in the online Help index
atoms-family | Not provided
autoarxload | Not provided
autoload | Not provided
boole | Use logical operators
boundp | Search for IS in the online Help index
car/cdr | Use array manipulation functions
chr | Chr function
client_data_tile | Use the Dialog Editor
close | AutoCAD.Application.Documents.Close method
command | AutoCAD.ActiveDocument.SendCommand method
cond | Select Case statement
cons | Use array manipulation functions or AutoCAD.Application.collection.Add<entityname> method
cos | Cos function
cvunit | Use the conversion functions
defun | The keywords Function and End Function
dictadd | AutoCAD.Application.ActiveDocument.Dictionaries.Add method
dictnext | AutoCAD.Application.ActiveDocument.Dictionaries.Item method
dictremove | AutoCAD.Application.ActiveDocument.Dictionaries.Dictionary.Delete method
dictrename | AutoCAD.Application.ActiveDocument.Dictionaries.Dictionary.Rename method
dictsearch | AutoCAD.Application.ActiveDocument.Dictionaries.Dictionary.GetName and GetObject methods
dimx_tile and dimy_tile | Use the Dialog Editor
distance | AutoCAD.Application.Utility.GetDistance for interactive method
distof | Not provided
done_dialog | Use the Dialog Editor
end_image | Use the Dialog Editor
end_list | Use the Dialog Editor
entdel | AutoCAD.Application.ActiveDocument.collection_object.Delete method
entget | AutoCAD.Application.ActiveDocument.collection_object.property properties
entlast | AutoCAD.Application.ActiveDocument.Modelspace.Item(count-1)
entmake | AutoCAD.Application.ActiveDocument.Modelspace.Add<entityname> method
entmakex | AutoCAD.Application.ActiveDocument.Modelspace.Add<entityname> method
entmod | Use any of the read-write properties for the object
entnext | AutoCAD.Application.ActiveDocument.collection.Item method
entsel | AutoCAD.Application.ActiveDocument.SelectionSets object/methods/properties
entupd | AutoCAD.Application.ActiveDocument.Modelspace.object.Update method
eq | Not provided
equal | Eqv operator
*error* | Error object/method/properties
eval | Not provided
exit | AutoCAD.Application.Quit method
exp | Exp function
expand | Not provided
expt | ^ (exponentiation operator)
fill_image | Use the Dialog Editor
findfile | Dir function
fix | Fix, Int, CInt functions
float | CDbl Function
foreach | For Each...Next statement
gc | AutoCAD.Application.ActiveDocument.PurgeAll method
gcd | Not provided
get_attr | Use the Dialog Editor
get_tile | Use the Dialog Editor
getangle | AutoCAD.Application.ActiveDocument.Utility.GetAngle method
getcfg | AutoCAD.Application.Preferences.property property
getcname | Not provided
getcorner | AutoCAD.Application.ActiveDocument.Utility.GetCorner method
getdist | AutoCAD.Application.ActiveDocument.Utility.GetDistance method
getenv | AutoCAD.Application.Preferences.property property
getfiled | Use the file dialog
getint | AutoCAD.Application.ActiveDocument.Utility.GetInteger method
getkword | AutoCAD.Application.ActiveDocument.Utility.GetKeyword method
getorient | AutoCAD.Application.ActiveDocument.Utility.GetOrientation method
getpoint | AutoCAD.Application.ActiveDocument.Utility.GetPoint method
getreal | AutoCAD.Application.ActiveDocument.Utility.GetReal method
getstring | AutoCAD.Application.ActiveDocument.Utility.GetString method
getvar | AutoCAD.Application.GetVariable method
graphscr | AppActivate AutoCAD.Application.Caption
grclear (obsolete) | Not provided
grdraw | Not provided
grread | Not provided
grtext | AutoCAD.Application.ActiveDocument.Utility.Prompt method
grvecs | Not provided
handent | AutoCAD.Application.ActiveDocument.ModelSpace.object.Handle property
help | Search for HELP in the online Help index
if | If… Then… Else statement
initget | AutoCAD.Application.ActiveDocument.Utility.InitializeUserInput method
inters | AutoCAD.Application.ActiveDocument.Modelspace.object.IntersectWith method
itoa | Str function
lambda | Not provided
last | arrayname(UBound(arrayname))
length | UBound function
list | ReDim statement
listp | IsArray function
load_dialog | Use the Dialog Editor
load | AutoLISP is not supported through Automation
log | Log function
logand | And function
logior | Or function
lsh | Imp function
mapcar | Not provided
max | Max function
mem | Not provided
member | Use collection
menucmd | AutoCAD.Application.MenuBar object
menugroup | AutoCAD.Application.MenuGroup object
min | Min function
minusp | Use < 0 syntax
mode_tile | Use the Dialog Editor
namedobjdict | AutoCAD.Application.ActiveDocument.Dictionaries collection
nentsel | AutoCAD.Application.ActiveDocument.SelectionSets.SelectionSet.SelectAtPoint method
nentselp | AutoCAD.Application.ActiveDocument.SelectionSets.SelectionSet.SelectAtPoint method
new_dialog | Use the Dialog Editor
not | Use the logical operators
nth | Use object(n) syntax
null | IsNull function
numberp | TypeName function
open | Open function
or | Use the logical operators
osnap | Not provided (You can use the AutoCAD.Application.SetVariable method to control the OSMODE system variable.)
polar | AutoCAD.Application.ActiveDocument.Utility.PolarPoint method
prin1 | AutoCAD.Application.ActiveDocument.Utility.Prompt method
princ | AutoCAD.Application.ActiveDocument.Utility.Prompt method
print | AutoCAD.Application.ActiveDocument.Utility.Prompt method
progn | Not provided
prompt | AutoCAD.Application.ActiveDocument.Utility.Prompt method
quit | AutoCAD.Application.Quit method
quote | Not provided
read | Not provided
read-char | Input function
read-line | Line Input function
redraw | AutoCAD.Application.ActiveDocument.Modelspace.object.Update method
regapp | AutoCAD.Application.ActiveDocument.RegisteredApplications.Add method
rem | Mod function
repeat | For… Each, While,
reverse | Not provided
rtos | AutoCAD.Application.ActiveDocument.Utility.RealToString method
set | Set function
set_tile | Use the Dialog Editor
setcfg | AutoCAD.Application.Preferences.property property
setfunhelp | Not provided
setq | Set function
setvar | AutoCAD.Application.SetVariable method
sin | Sin function
setview | AutoCAD.Application.ActiveDocument.Viewports.Viewport.SetView method
slide_image | Use the Dialog Editor
snvalid | Not provided
sqrt | Sqr function
ssadd | AutoCAD.Application.ActiveDocument.SelectionSets.Add method
ssdel | AutoCAD.Application.ActiveDocument.SelectionSets.SelectionSet.Delete method
ssget | AutoCAD.Application.ActiveDocument.SelectionSets.SelectionSet.SelectOnScreen method
ssgetfirst | Not provided
sslength | AutoCAD.Application.ActiveDocument.SelectionSets.SelectionSet.Count method
ssmemb | Compare ID of object with the SelectionSet members
ssname | AutoCAD.Application.ActiveDocument.SelectionSets.SelectionSet.Name property
ssnamex | Not provided
sssetfirst | AutoCAD.Application.ActiveDocument.PickfirstSelectionSet property
startapp | Shell function
start_dialog | Use the Dialog Editor
start_image | Use the Dialog Editor
start_list | Use the Dialog Editor
strcase | StrConv function
strcat | & operator
strlen | Len function
subst | Not provided
substr | Mid function
tablet | Not provided
tblnext | AutoCAD.Application.ActiveDocument.collection_object.Item method
tblobjname | AutoCAD.Application.ActiveDocument.collection_object.Name method
tblsearch | AutoCAD.Application.ActiveDocument.collection_object.Name method
term_dialog | Use the Dialog Editor
terpri | Not provided
textbox | AutoCAD.Application.ActiveDocument.space.object.GetBoundingBox method
textpage | Not provided
textscr | Not provided
trace | Not provided
trans | AutoCAD.Application.ActiveDocument.Utility.TranslateCoordinates method
type | TypeName function
unload_dialog | Use the Dialog Editor
untrace | Not provided
vector_image | Use the Dialog Editor
ver | AutoCAD.Application.Version property
vports | AutoCAD.Application.ActiveDocument.Viewports collection
wcmatch | Like operator
while | While… Wend
write-char | Print function
write-line | Print function
xdroom | Not provided
xdsize | Not provided
zerop | Use = 0 syntax


Comments?

Using this form sends your comments to the Autodesk Technical Publications group responsible for this documentation.

Topic title and location (do not edit):
Name (optional):
         Email (optional):
Comments:

Note: This form is not intended as a way for you to receive feedback or technical support. The information you provide will be used to enhance future updates to the documentation. Thanks!


IDH__DACADAPPLICATIONEVENTS_INTERFACE=GUID-208C641B-DDA2-40F6-89D7-DAA70AF64325.htm
IDH__DACADDOCUMENTEVENTS_INTERFACE=GUID-7888B99C-BE13-4ECD-A4F1-E2F349B78D55.htm
IDH_3DFACE_OBJECT=GUID-1DAB32FC-8C8A-4116-BD3A-CF733740DF8F.htm
IDH_3DPOLY_OBJECT=GUID-896C0FBC-6558-40BE-AD84-8F8BCC6BA62A.htm
IDH_3DSOLID_OBJECT=GUID-4EC0355F-A91B-4ADA-A346-05CCCD22259B.htm
IDH_ACADSTATE_OBJECT=GUID-0516563E-51BA-4040-A51A-06D4AB7C6188.htm
IDH_ACCMCOLOR_OBJECT=GUID-D24C6BB5-5F87-42E7-907F-F27226B330E3.htm
IDH_APPLICATION_OBJECT=GUID-0225808C-8C91-407B-990C-15AB966FFFA8.htm
IDH_ARC_OBJECT=GUID-3D31C05F-BFF7-41E3-8ACE-0F807731C913.htm
IDH_ATTRIBUTE_OBJECT=GUID-E24E7CA0-0120-4C55-BADB-46D701B8D4CB.htm
IDH_ATTRIBUTEREF_OBJECT=GUID-0630EFF2-51A2-46E4-A5A1-0377FB7E38E8.htm
IDH_BLOCK_OBJECT=GUID-E6F7B03B-F5CC-4A18-9C48-BBF1D32A31FD.htm
IDH_BLOCKREF_OBJECT=GUID-88EEBCA3-8AF5-4776-9D54-520B05AB9129.htm
IDH_BLOCKS_COLLECTION=GUID-E77CC5AD-74B8-472C-8270-32FD162D5653.htm
IDH_CIRCLE_OBJECT=GUID-18ADF171-166F-4FF0-8ED6-5F83153A5649.htm
IDH_DATABASE_OBJECT=GUID-31D8D654-572D-4D2B-A138-4D8793ECE135.htm
IDH_DATABASEPREFERENCES_OBJECT=GUID-B03F622D-9D1D-4149-A170-1DF2AC62DA37.htm
IDH_DGNUNDERLAY_OBJECT=GUID-70DBB31B-E1D1-4D8C-928C-B274E0D63E66.htm
IDH_DICTIONARIES_COLLECTION=GUID-C04BFB8A-8FDF-4D9E-8C0F-E1D2226FEC8A.htm
IDH_DICTIONARY_OBJECT=GUID-9FF18AA0-4E48-4F92-AC0D-FBBD4225D347.htm
IDH_DIM3POINTANGULAR_OBJECT=GUID-1EF38BC6-8057-4F4A-95BC-0624544A248F.htm
IDH_DIMALIGNED_OBJECT=GUID-38EB1E39-B67A-4B90-A394-5C3FA260F9F3.htm
IDH_DIMANGULAR_OBJECT=GUID-C832CDC5-59AA-466F-B4BA-EFC133834A1E.htm
IDH_DIMARCLENGTH_OBJECT=GUID-BAB6D518-BE01-494A-A8AC-8645A99369CE.htm
IDH_DIMDIAMETRIC_OBJECT=GUID-181A4644-B053-49D6-BB3C-35158B8794C3.htm
IDH_DIMORDINATE_OBJECT=GUID-35CE0F15-A136-4878-AEDC-FADC193E7ED2.htm
IDH_DIMRADIAL_OBJECT=GUID-037CC1EC-8183-49B3-9F51-69AE8B282CC4.htm
IDH_DIMRADIALLARGE_OBJECT=GUID-E44150ED-D643-4BC5-AD6B-E4724A109DA5.htm
IDH_DIMROTATED_OBJECT=GUID-93D19CB2-9A1F-4324-BD49-D241FD009C3C.htm
IDH_DIMSTYLE_OBJECT=GUID-3227408C-75A9-434C-BD3F-B189A2BE098A.htm
IDH_DIMSTYLES_COLLECTION=GUID-46478963-D723-44E1-92F2-3E28384E64EA.htm
IDH_DOCUMENT_OBJECT=GUID-9216BFCD-D358-4FC6-B631-B52E6693D242.htm
IDH_DOCUMENTS_COLLECTION=GUID-2C8C8291-16C9-4A9F-8399-58D5DE4B9589.htm
IDH_DWFUNDERLAY_OBJECT=GUID-1205069A-A64A-4E21-9B9A-3EAF58F2EF26.htm
IDH_DYNAMICBLOCKREFERENCEPROPERTY_OBJECT=GUID-ED753239-0C53-4741-BE13-99B21751C22F.htm
IDH_ELLIPSE_OBJECT=GUID-85D3077C-DAE6-4BB7-BB69-E8A8BD10FEA5.htm
IDH_EXTERNALREFERENCE_OBJECT=GUID-63129986-F84E-4674-8C90-EC1E0E627845.htm
IDH_EXTRUDEDSURFACE_OBJECT=GUID-03E55664-0EBE-4EF5-A51C-B0806FA5DC3C.htm
IDH_FILEDEPENDENCY=GUID-C18BBD6D-44DD-4AC6-B712-B613A8788251.htm
IDH_GROUP_OBJECT=GUID-1CA2C9D1-F8F7-4C11-B361-2998C4869119.htm
IDH_GROUPS_COLLECTION=GUID-B6B9B72E-31BC-41E0-B06B-17B1EE33FFB0.htm
IDH_HATCH_OBJECT=GUID-92A2B30F-1B74-4894-850A-5505F3B5944B.htm
IDH_HELIX_OBJECT=GUID-A8B144D8-EFC1-4D2D-B6F8-73C541906646.htm
IDH_HYPERLINK_OBJECT=GUID-6F5F717A-F3ED-453B-B59A-E10D89153591.htm
IDH_HYPERLINKS_COLLECTION=GUID-D92E9BFF-F5A0-49EC-9262-93EAD73F4780.htm
IDH_IACADDATABASE_INTERFACE=GUID-DEB4B47D-4ED8-49EB-8739-8902B6219622.htm
IDH_IACADDIMENSION_INTERFACE=GUID-A9836239-6EF2-4BB8-8F49-2CBD32675DD2.htm
IDH_IACADENTITY_INTERFACE=GUID-FCA7867D-E354-4F48-9C47-DB22C53A3460.htm
IDH_IACADOBJECT_INTERFACE=GUID-1C457D0A-9933-4A74-B3E9-A7F3483B3F34.htm
IDH_IACADOBJECTEVENTS_INTERFACE=GUID-62DB50E4-EE2E-479E-8489-3E8B59FD3131.htm
IDH_IDPAIR_OBJECT=GUID-0A0BD12B-1A83-47D9-9E4E-2F83213D5026.htm
IDH_LAYER_OBJECT=GUID-14F28A52-81E5-4CD0-AA79-ADC09E91BB8C.htm
IDH_LAYERS_COLLECTION=GUID-D9F62B4B-401E-4AE6-969F-3F7756819EB6.htm
IDH_LAYERSTATEMANAGER=GUID-930152BE-F356-44CF-8BD1-7121E9886157.htm
IDH_LAYOUT_OBJECT=GUID-EFC848F1-26BE-4EFA-BC0E-11F874D73842.htm
IDH_LAYOUTS_COLLECTION=GUID-0C5AF331-03C4-472B-BD30-78C8310822A2.htm
IDH_LEADER_OBJECT=GUID-E1EC4A71-6FC0-4B76-AD53-4DE561D6EE46.htm
IDH_LIGHTWEIGHTPOLYLINE_OBJECT=GUID-5A604B98-B6DE-42C3-97D9-98B8CAEBB507.htm
IDH_LINE_OBJECT=GUID-2A2C2B78-3B64-4083-A8EC-984DB223053F.htm
IDH_LINETYPE_OBJECT=GUID-16016CA5-0126-403B-844B-F6CABE117B50.htm
IDH_LINETYPES_COLLECTION=GUID-968A3D1F-8DEF-4B8B-8067-0B756A622D97.htm
IDH_LOFTEDSURFACE_OBJECT=GUID-D56F5C92-731E-4FA3-9FAE-82E97E388901.htm
IDH_MATERIAL_OBJECT=GUID-A7E5AA1A-D3C3-4AA3-A751-97768628D96C.htm
IDH_MATERIALS_OBJECT=GUID-4BC04C70-B2B0-4325-8042-CAD81F9058F1.htm
IDH_MENUBAR_OBJECT=GUID-AC709260-4F3A-4EC0-A542-78D0B43342F7.htm
IDH_MENUGROUP_OBJECT=GUID-3DA607BC-1868-4C64-AF79-7E24F30B58EA.htm
IDH_MENUGROUPS_COLLECTION=GUID-AAD2CED1-F82B-44E5-98C9-937A4F3BD2D9.htm
IDH_MINSERTBLOCK_OBJECT=GUID-0F4669CB-6769-4F40-A24F-7658FBD41518.htm
IDH_MLEADER_OBJECT=GUID-95FD33C2-DF78-4014-933C-9AC124E6A35D.htm
IDH_MLEADERSTYLE_OBJECT=GUID-14AC2D0B-EBFC-44B9-982D-9112539F8DE8.htm
IDH_MLINE_OBJECT=GUID-D91098F2-83AB-41A7-B9F8-929871B438FC.htm
IDH_MODELSPACE_COLLECTION=GUID-C541B6F2-1279-4D1C-8DC0-788F27F644EF.htm
IDH_MTEXT_OBJECT=GUID-2532B20E-413D-4F59-9E88-B40E8AABB9FF.htm
IDH_NURBSURFACE_OBJECT=GUID-5F16F644-F61B-45AC-BB3D-AF8221336072.htm
IDH_OLE_OBJECT=GUID-F22B8915-FE51-4650-A738-95C81019064E.htm
IDH_PAPERSPACE_COLLECTION=GUID-C5E998B5-6EB1-459A-98B1-444C74DB4516.htm
IDH_PDFUNDERLAY_OBJECT=GUID-54DEC47A-5FBB-4E9F-B206-502785568E91.htm
IDH_PLANESURFACE_OBJECT=GUID-8979D4B7-F581-4623-B66F-1FC24BA2CDC3.htm
IDH_PLOT_OBJECT=GUID-0A01876A-13D5-4938-8BEE-7712FD7C12CF.htm
IDH_PLOTCONFIGURATION_OBJECT=GUID-AF404266-C40A-4FB4-B4E0-1D1C83052B6D.htm
IDH_PLOTCONFIGURATIONS_COLLECTION=GUID-7337ECFB-B538-4C5D-AB7F-BD3C2F255B81.htm
IDH_POINT_OBJECT=GUID-B7F38E33-911A-4285-BCFC-EFB5F8EE260D.htm
IDH_POINTCLOUD_OBJECT=GUID-5142F98A-F959-4107-AF76-28813152F04C.htm
IDH_POLYFACEMESH_OBJECT=GUID-679AA72F-7A2F-468D-A2D5-E3F28425C35A.htm
IDH_POLYGONMESH_OBJECT=GUID-AEE2A5BA-D35B-4C92-881B-2B327F656B93.htm
IDH_POLYLINE_OBJECT=GUID-35D9E28C-38A8-477A-AFCE-F21952092190.htm
IDH_POPUPMENU_OBJECT=GUID-9075A49A-5E89-4489-B5D4-0749A833CB19.htm
IDH_POPUPMENUITEM_OBJECT=GUID-8ACA3C83-3640-44A8-9A5F-122DADBD180C.htm
IDH_POPUPMENUS_COLLECTION=GUID-041CC42A-EEAB-4686-B186-69C801CE8460.htm
IDH_PREFERENCES_OBJECT=GUID-D4DC625F-555F-4DD4-A60B-FC86A8CD55C0.htm
IDH_PREFERENCESDISPLAY_OBJECT=GUID-140B9E57-C5F3-4EFF-884B-6C11CD8DDDB0.htm
IDH_PREFERENCESDRAFTING_OBJECT=GUID-4429EDB1-FB82-4339-88D3-F2B6807255D3.htm
IDH_PREFERENCESFILES_OBJECT=GUID-539ADB58-295E-4BF1-A0CB-D104163409F9.htm
IDH_PREFERENCESOPENSAVE_OBJECT=GUID-00DB1AF2-D4B0-45ED-B89A-A30A8702DB09.htm
IDH_PREFERENCESOUTPUT_OBJECT=GUID-55D3071F-86C0-4974-B972-397C7D3DF78D.htm
IDH_PREFERENCESPROFILES_OBJECT=GUID-EE065355-4343-4954-8C5F-04E2BA87891F.htm
IDH_PREFERENCESSELECTION_OBJECT=GUID-413CD115-ED98-469E-AE74-7BB106D03C77.htm
IDH_PREFERENCESSYSTEM_OBJECT=GUID-F3EEF084-D027-4E12-B3F7-83B34E81D6EA.htm
IDH_PREFERENCESUSER_OBJECT=GUID-B5C4EB12-9316-4D21-A808-FA5337404E3B.htm
IDH_PVIEWPORT_OBJECT=GUID-63DF4686-8A79-4A39-8247-4A3565F31FAA.htm
IDH_RASTER_OBJECT=GUID-3613CF3F-EFC6-4E20-B875-D66B0494B94F.htm
IDH_RAY_OBJECT=GUID-365768B5-3A4E-4340-AA17-8FCA291BA87C.htm
IDH_REGION_OBJECT=GUID-DFE47717-F7AF-443B-AD78-4E0BB60121C7.htm
IDH_REGISTEREDAPP_OBJECT=GUID-62AD8980-F707-4906-8640-B3C54E9FC3F4.htm
IDH_REGISTEREDAPPS_COLLECTION=GUID-606BE79B-6E2C-4BAB-BFF7-F54B7167F96C.htm
IDH_REVOLVEDSURFACE_OBJECT=GUID-DD54DF69-8424-488B-BD7B-7642AD1D379F.htm
IDH_SECTION_OBJECT=GUID-5242921B-1A1B-47DF-B9B7-2932DB5227AA.htm
IDH_SECTIONMANAGER_OBJECT=GUID-A64E22B8-26B4-4D5F-89C7-C8E077F86BEC.htm
IDH_SECTIONSETTINGS_OBJECT=GUID-72C22774-0C07-4B54-8760-65ADCFC228DD.htm
IDH_SECTIONTYPESETTINGS_OBJECT=GUID-034FBB08-5E8B-48BD-AAAF-E18A9BCAE1D8.htm
IDH_SECURITYPARAMS=GUID-5DB358E5-F631-4172-8E70-04FD26AC4460.htm
IDH_SELECTIONSET_OBJECT=GUID-BF264239-CF7D-4BC8-8D37-69477862DB5A.htm
IDH_SELECTIONSETS_COLLECTION=GUID-5B8DDC53-D4CD-4121-B58D-66B48D343A24.htm
IDH_SHADOWDISPLAY_INTERFACE=GUID-38FA2CF6-BFAF-4A5C-8B16-EC6B22C43E62.htm
IDH_SHAPE_OBJECT=GUID-14883954-9C4B-4B8F-AC0C-4B44940B5932.htm
IDH_SOLID_OBJECT=GUID-1B207FF4-E441-4B3B-A677-BD5FE8CC479D.htm
IDH_SORTENTSTABLE_OBJECT=GUID-258B72FF-B29A-45D2-B972-B1776D9112A7.htm
IDH_SPLINE_OBJECT=GUID-B8FC11E4-3F6B-40CE-8AEC-D4CF669086A3.htm
IDH_SUBDMESH_OBJECT=GUID-B1E2F826-917B-4844-B1C1-E87E487F2AE4.htm
IDH_SUBDMESHEDGE_OBJECT=GUID-4F2C59C1-7FAB-4909-B03F-D522C23DD204.htm
IDH_SUBDMESHFACE_OBJECT=GUID-BEC1E125-5969-40AC-A1EF-8E3F035D4A74.htm
IDH_SUBDMESHVERTEX_OBJECT=GUID-5396D2DC-D68B-4EEC-AB57-602361BD7EEE.htm
IDH_SUBENTITY_OBJECT=GUID-66654E1B-7AAF-4FB0-ADFE-04A5CD6B81DB.htm
IDH_SUBENTSOLIDEDGE_OBJECT=GUID-3ED9DEF8-07A0-4BCD-B2BE-FD1537333044.htm
IDH_SUBENTSOLIDFACE_OBJECT=GUID-34B05634-08F5-4227-8FC1-298A8C0271DD.htm
IDH_SUBENTSOLIDNODE_OBJECT=GUID-71C9E9A5-3E76-4242-9177-3F8A6464822D.htm
IDH_SUBENTSOLIDVERTEX_OBJECT=GUID-0F2250AA-F112-43F1-8553-26DA71CBB44B.htm
IDH_SUMMARYINFO_OBJECT=GUID-A029FB49-B0DB-43E4-8888-698E1BF49878.htm
IDH_SURFACE_OBJECT=GUID-98BC3DD3-F913-494C-8559-EAFA0DDEFE3E.htm
IDH_SWEPTSURFACE_OBJECT=GUID-2E70AE24-0C8F-4124-84F2-F20A94EA6AF2.htm
IDH_TABLE_OBJECT=GUID-7B82400C-53D0-4D1A-94FA-66BB3040F0AA.htm
IDH_TABLESTYLE_OBJECT=GUID-409A6709-D3D9-4D7D-AC60-163444D58FBA.htm
IDH_TEXT_OBJECT=GUID-ED298AC7-19E0-4E54-8983-48439EF70116.htm
IDH_TEXTSTYLE_OBJECT=GUID-0531335D-26F3-404B-A4E1-1DE70BF0A307.htm
IDH_TEXTSTYLES_COLLECTION=GUID-22FC4F30-F03C-4D9C-83DE-FEAEB7135D7F.htm
IDH_TOLERANCE_OBJECT=GUID-89AF1685-5ACA-44F2-B741-D4C957C887F0.htm
IDH_TOOLBAR_OBJECT=GUID-5D9BE04E-A84F-48E9-AFB6-7C0BCAD3D0C1.htm
IDH_TOOLBARITEM_OBJECT=GUID-3148AF99-A0CD-4C4E-8680-0A7731959BC9.htm
IDH_TOOLBARS_COLLECTION=GUID-E3B81587-A244-4437-869D-A7C242B9A732.htm
IDH_TRACE_OBJECT=GUID-7113C9E5-6875-4ABB-A4DC-68F6C09C4D7D.htm
IDH_UCS_OBJECT=GUID-42778889-C568-4ABF-9CFA-63CC0D781794.htm
IDH_UCSS_COLLECTION=GUID-C7B1383E-9E7B-46AD-B821-0906421194E5.htm
IDH_UTILITY_OBJECT=GUID-DE118C17-4567-48CF-8EFA-CABB52A27275.htm
IDH_VIEW_OBJECT=GUID-1B9C7D36-0905-4C20-84C5-53714379B811.htm
IDH_VIEWPORT_OBJECT=GUID-2B609059-6B70-4C66-A442-F5917363462A.htm
IDH_VIEWPORTS_COLLECTION=GUID-5C011DBD-1D92-4DF6-B0D5-9C12CD913273.htm
IDH_VIEWS_COLLECTION=GUID-786FCD2B-E5F8-4BFA-B69F-F871AF4503CA.htm
IDH_IACADWIPEOUT_INTERFACE=GUID-C978B807-6636-4DE4-AC63-7ACFF232B9EB.htm
IDH_XLINE_OBJECT=GUID-A223EA11-306F-4685-AE56-72DC8D21CB46.htm
IDH_XRECORD_OBJECT=GUID-AF9C01F7-5BD9-4AF8-AB63-F58A997A5258.htm
IDH_APPACTIVATE=GUID-FA52F3C0-FE4E-4F35-A6AE-C2BAA1912031.htm
IDH_APPDEACTIVATE=GUID-EC60EA71-090D-4D96-B951-9465D877F97F.htm
IDH_ARXLOADED=GUID-726449E4-E027-4260-BD6F-1C0D4E27D065.htm
IDH_ARXUNLOADED=GUID-B30E5068-B18A-4179-B253-23FD4CC01894.htm
IDH_BEGINCLOSE=GUID-0B1114C2-35FD-4689-B031-62D489FF8A7E.htm
IDH_BEGINDOCCLOSE=GUID-EE0D8F0D-1132-4BCE-A68F-7125B97E737F.htm
IDH_BEGINDOUBLECLICK=GUID-0BBE54CD-0C3C-49E3-8F43-02C8D3219ED4.htm
IDH_BEGINFILEDROP=GUID-D14A002C-60EF-493A-A8FA-696B12F05D3D.htm
IDH_BEGINLISP=GUID-CF0D87BB-1E41-4F82-B007-409F794EC8EB.htm
IDH_BEGINMODAL=GUID-1A32712E-B2AB-4159-95F3-8C95BC22AB7F.htm
IDH_BEGINOPEN=GUID-BD420830-798B-4023-BD33-E1442D71D800.htm
IDH_BEGINPLOT=GUID-286CEEB9-3F3B-40AC-B148-E02335B74270.htm
IDH_BEGINQUIT=GUID-5315845E-EC1F-4D03-AAAB-D9E08EB0873D.htm
IDH_BEGINRIGHTCLICK=GUID-6AF4DAD7-96EF-4CFB-9FC5-43F0F017F5CA.htm
IDH_BEGINSAVE=GUID-E34B6863-298A-40A3-AA8F-327F5C5DACF0.htm
IDH_BEGINSHORTCUTMENUCOMMAND=GUID-B125BE98-E80D-41EE-A281-E2E8DFC4968E.htm
IDH_BEGINSHORTCUTMENUDEFAULT=GUID-5DF17EEA-9276-4E14-8FF3-96F738F7ED8D.htm
IDH_BEGINSHORTCUTMENUEDIT=GUID-D993E595-B28A-4486-956C-3B1B7583F6DB.htm
IDH_BEGINSHORTCUTMENUGRIP=GUID-6E178381-061D-48FB-95C9-3D077AB1A1EF.htm
IDH_BEGINSHORTCUTMENUOSNAP=GUID-A244B425-3107-4F3B-97C6-229FCA1286EA.htm
IDH_DEACTIVATE=GUID-22750180-C69B-42BB-9895-F865797D753C.htm
IDH_ENDCOMMAND=GUID-54741B8A-2A8F-46CC-B62C-1DAA182E7174.htm
IDH_ENDLISP=GUID-A6EA78E5-C0FC-4E71-9223-24E30C32E217.htm
IDH_ENDMODAL=GUID-B834BF42-B242-40EC-9093-2D830C62F71F.htm
IDH_ENDOPEN=GUID-1AEC7F00-981A-4517-A830-37CA653D336A.htm
IDH_ENDPLOT=GUID-BC920EE5-A616-449B-A8E4-9CAF0E588306.htm
IDH_ENDSAVE=GUID-D72C232D-82D9-4C63-9808-9E8CFE514B36.htm
IDH_ENDSHORTCUTMENU=GUID-8F40A4D3-75DF-4DC6-BC63-8E927A049641.htm
IDH_LAYOUTSWITCHED=GUID-32909BB0-81E6-4E41-816D-8B0C1EAB608F.htm
IDH_MODIFIED=GUID-5EF65D7D-F5B4-48FE-A9F6-CD5F7CF3C54B.htm
IDH_NEWDRAWING=GUID-2204099A-0E75-4FA9-93B9-2FC997916682.htm
IDH_OBJECTERASED=GUID-7A8EB01B-B793-46CC-A369-FD9B4DD98022.htm
IDH_OBJECTMODIFIED=GUID-554BCA2C-19B5-4445-95E4-5624FE7F290A.htm
IDH_SELECTIONCHANGED=GUID-2C0AED20-1D9A-41F9-B62A-467C6E16E6C7.htm
IDH_SYSVARCHANGED=GUID-275C46E6-15AA-4086-84F9-D4836E96C049.htm
IDH_WINDOWCHANGED=GUID-EADD41ED-CEB1-4D2D-A7F2-710863289795.htm