Understanding Com Wrappers

AutoCAD Land Desktop ActiveX & VBA

Understanding Com Wrappers

 

Overview

A COM wrapper provides an instance of an ActiveX object that represents a drawing entity. Your application uses the properties, methods, and events from this object to access and manage the corresponding entity in the drawing. COM wrappers are implemented for AeccDbContour, AeccDbPoint, and AecDbCurveText entities.

AutoCAD Land Desktop objects that are created in model space, use the AcadModelSpace collection to iterate through objects. For example:

Dim pnt As AeccPoint

Dim obj As AcadObject

For Each obj In ThisDrawing.ModelSpace

  If obj.ObjectName = "AeccDbPoint" Then

  Set pnt = obj

  End If

Next

Similarly, you can iterate existing entities in a selection set to access your custom ARX objects through their COM wrappers. When using the FilterData parameter for an AcadSelectionSet, specify the object name that appears in the Properties window (or when you list an object): AECC_CONTOUR, AECC_POINT, or AEC_CURVETEXT.

Object Creation

You can use the AcadModelSpace.AddCustomObject method to (1) create an instance of your ARX object and (2) return an instance of your COM wrapper so you can use its properties to initialize the object. Note that you cannot create AutoCAD Land Desktop objects in PaperSpace or Blocks. For example:

Dim pnt As AeccPoint

Set pnt = ThisDrawing.ModelSpace.AddCustomObject("AeccDbPoint")

pnt.Easting = 1000

pnt.Northing = 1000

pnt.Elevation = 100

pnt.Number = 1

pnt.Description = "test point"

Events

The AutoCAD Land Desktop objects support notification through the Modified event.

Contour Styles

Contour styles are saved on a per-drawing drawing basis in the dictionary. To facilitate the management of styles for contour objects, a COM wrapper for the contour style is provided. You can access any style loaded in the current drawing through the "AECC_CONTOUR_STYLE"; dictionary:

Dim cs As AeccContourStyle

Dim obj As AcadObject

For Each obj In ThisDrawing.Dictionaries("AECC_CONTOUR_STYLES")

  Set cs = obj

  If cs.Name = "Standard" Then

    Exit For

  End If

Next

 

Dim Contour As AeccContour

Set Contour = ThisDrawing.ModelSpace.AddCustomObject("AeccDbContour")

Contour.SetContourStyle cs