بنقرة واحدة
revit-api
Practical guidance for implementing and reviewing Autodesk Revit 2025+ C# add-ins.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Practical guidance for implementing and reviewing Autodesk Revit 2025+ C# add-ins.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | revit-api |
| description | Practical guidance for implementing and reviewing Autodesk Revit 2025+ C# add-ins. |
Use this skill when the task involves Autodesk Revit 2025 or newer API code, Revit add-in architecture, Revit commands, transactions, element filtering, WPF UI in Revit, add-in packaging, or Revit assembly loading.
Use this skill for tasks involving:
Autodesk.Revit.DBAutodesk.Revit.UIIExternalCommandIExternalApplicationExternalEventTransactionFilteredElementCollector.addin manifestsElement references.UniqueId for persisted element identity.Document.Regenerate().When implementing a Revit feature:
UIApplicationUIDocumentDocumentUse this pattern for new external commands:
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Company.Product.Commands;
[Transaction(TransactionMode.Manual)]
public sealed class SampleCommand : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
var uiApplication = commandData.Application;
var uiDocument = uiApplication.ActiveUIDocument;
if (uiDocument is null)
{
message = "No active Revit document is available.";
return Result.Failed;
}
try
{
var document = uiDocument.Document;
// Delegate real work to a service.
var service = new SampleService();
service.Execute(document);
return Result.Succeeded;
}
catch (OperationCanceledException)
{
return Result.Cancelled;
}
catch (Exception exception)
{
message = exception.Message;
return Result.Failed;
}
}
}
Use this pattern for write operations:
using var transaction = new Transaction(document, "Update Revit data");
transaction.Start();
try
{
// Modify the document here.
transaction.Commit();
}
catch
{
if (transaction.GetStatus() == TransactionStatus.Started)
{
transaction.RollBack();
}
throw;
}
Do not use a transaction for read-only operations.
Prefer fast filters first:
var elements = new FilteredElementCollector(document)
.OfCategory(BuiltInCategory.OST_Walls)
.WhereElementIsNotElementType()
.ToElements();
Prefer class filters when possible:
var walls = new FilteredElementCollector(document)
.OfClass(typeof(Wall))
.WhereElementIsNotElementType()
.Cast<Wall>()
.ToList();
Avoid:
When reading parameters:
var parameter = element.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
if (parameter is null || parameter.StorageType != StorageType.String)
{
return;
}
var value = parameter.AsString();
When writing parameters:
var parameter = element.get_Parameter(BuiltInParameter.ALL_MODEL_MARK);
if (parameter is null || parameter.IsReadOnly || parameter.StorageType != StorageType.String)
{
return;
}
parameter.Set("New value");
Rules:
BuiltInParameter over name lookup.IsReadOnly.StorageType.Use modern Revit unit APIs:
var displayValue = UnitUtils.ConvertFromInternalUnits(internalValue, unitTypeId);
var internalValue = UnitUtils.ConvertToInternalUnits(displayValue, unitTypeId);
Rules:
ForgeTypeId-based APIs.DisplayUnitType.For modeless WPF UI:
ExternalEvent.Element references in view models.For dockable panes:
Page where Revit requires it.When working on Revit add-ins:
When the project supports several Revit versions:
#if REVIT2027
// Revit 2027-specific code
#elif REVIT2026
// Revit 2026-specific code
#else
// Revit 2025-compatible code
#endif
Rules:
When reviewing Revit code, check for:
ElementId for persistence (prefer UniqueId).When generating code:
using statements.