AddCustomObject Method (ActiveX)

Creates a custom object.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.AddCustomObject(ClassName)
object

Type: Block, ModelSpace, PaperSpace

The objects this method applies to.

ClassName

Access: Input-only

Type: String

The rxClassName must be defined in an ObjectARX® application (ObjectARX DLL) or the method will fail.

Return Value (RetVal)

Type: Custom object

The newly created Custom object.

Remarks

The ObjectARX DLL defining the rxClassName custom class must be loaded. Use the LoadARX method on the Application object to explicitly load the ObjectARX file.

Examples

VBA:

Sub Example_AddCustomObject()
    ' This example adds a custom object to model space.
    
    ' Load the ObjectARX application that defines the custom object.
    ' Note: The application listed here does not exist and
    ' will cause an error when run. Change the application name
    ' to the path and name of your ObjectARX Application.
    ThisDrawing.Application.LoadArx "MyARXApp.dll"
    
    ' Once the application has been loaded successfully,
    ' add the custom object to model space.
    Dim customObj As AcadObject
    Set customObj = ThisDrawing.ModelSpace.AddCustomObject("MyNewObject")
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddCustomObject()
    ;; This example adds a custom object to model space.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Load the ObjectARX application that defines the custom object.
    ;; Note: The application listed here does not exist and
    ;; will cause an error when run. Change the application name
    ;; to the path and name of your ObjectARX Application.
    (vla-LoadArx acadObj "MyARXApp.dll")
    
    ;; Once the application has been loaded successfully,
    ;; add the custom object to model space.
    (setq customObj (vla-AddCustomObject (vla-get-ModelSpace doc) "MyNewObject"))
)