AddMacro Method


Adds a macro to the module.

Namespace: Autodesk.Revit.DB.Macros
Assembly: RevitAPIMacros (in RevitAPIMacros.dll) Version: 24.0.0.0 (24.0.0.0)
Since:  2014

Syntax

C#
public Macro AddMacro(
	string name,
	string description,
	string code
)
Visual Basic
Public Function AddMacro ( _
	name As String, _
	description As String, _
	code As String _
) As Macro
Visual C++
public:
Macro^ AddMacro(
	String^ name, 
	String^ description, 
	String^ code
)

Parameters

name
Type: SystemString
The macro name.
description
Type: SystemString
The description.
code
Type: SystemString
The code string, which should be the lines between the main bounding brackets of a method.

Return Value

The new macro.

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentNullException A non-optional argument was null
Autodesk.Revit.ExceptionsInvalidOperationException Cannot add the Macro due to no permission.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →