Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

family-geometry

БесплатноБез исполняемых скриптовНе проверен

Creating content inside Revit families. Covers reference planes, labelled dimensions, locked extrusions, formulas, shared parameters, visibility and graphics…

pyrevitlabsот pyrevitlabs★ 2 094 звезды на GitHub

Об этом скилле

Family geometry

Read revit-scripting and family-editing first. Everything below runs in a family document: one the user has open, one from doc.EditFamily, or a new one from app.NewFamilyDocument(template_path). Pick template_path as the revit-files skill describes: template file names depend on the language of Revit, so check fam_doc.OwnerFamily.FamilyCategory after opening it.

from pyrevit.revit.db import create, query, update

The snippets were run in Revit 2024.1 on IronPython 2.7.12. The parametric box and the helpers were also run, with metric and imperial templates, in Revit 2024.1 (English) on IronPython 2.7.12 and CPython 3.12, and in Revit 2026 (English and German interface) on IronPython 3.4.2 and CPython 3.12. Nothing was run in Revit 2021 to 2023, 2025 or 2027.

Rules that decide whether a script works

  • Roll back before you close. If a script fails with a transaction open, fam_doc.Close(False) in finally raises "Close is not allowed when there is any open sub-transaction" and hides the real error. Keep the transaction in a variable and roll it back in except:

    fam_doc = app.NewFamilyDocument(template_path)
    t = DB.Transaction(fam_doc, "Build")
    try:
        t.Start()
        t.Commit()
    except Exception:
        if t.GetStatus() == DB.TransactionStatus.Started:
            t.RollBack()
        raise
    finally:
        fam_doc.Close(False)
    
  • Transactions on the family document are needed for Regenerate(), NewType and every edit. Setting fm.CurrentType outside one fails.

  • A family starts with no type. fm.CurrentType is None and SetFormula raises "There is no valid family type" until you call fm.NewType("name").

  • Plan views are DB.ViewPlan with ViewType.FloorPlan; the Generic Model template gives its floor plan and its ceiling plan the same name, so filter by ViewType, not by name. Elevations are ViewType.Elevation; pick one by ViewDirection: front (0, -1, 0), back (0, 1, 0), left (-1, 0, 0), right (1, 0, 0).

  • Names are localized. The names of template planes, views and line patterns, the label that AsValueString() gives an "Is Reference" setting, and the name of an unsaved family document (Familie24 in German) follow the language of Revit. Find the built-in center planes with query.get_reference_plane("center_left_right", doc=fam_doc) (also "center_front_back"). The API's exception messages stayed English in a German Revit.

  • Units are feet in the family document, as everywhere in the API, whether the template is metric or imperial; the template only changes how Revit displays them. Convert the user's lengths first: units.parse_length("600mm").

  • Revit versions: DB.GroupTypeId and DB.SpecTypeId, used by every AddParameter call below, exist from Revit 2022. Revit 2021 needs DB.BuiltInParameterGroup.PG_GEOMETRY and DB.ParameterType.Length in AddParameter instead (ParameterType is gone from 2023); test hasattr(DB, "GroupTypeId") to choose. That branch has not been run.

Parametric box: planes, dimensions, extrusion, locks

Build in this order, from an unhosted Generic Model template: it has no Width or Height parameter, so a template that already defines them makes AddParameter fail. The extrusion follows the parameters only when its faces are aligned to reference planes that dimensions drive.

fam_doc = app.NewFamilyDocument(template_path)
t = DB.Transaction(fam_doc, "Build box")
try:
    fm = fam_doc.FamilyManager
    plan = [v for v in DB.FilteredElementCollector(fam_doc).OfClass(DB.ViewPlan)
            if not v.IsTemplate and v.ViewType == DB.ViewType.FloorPlan][0]
    centre = query.get_reference_plane("center_left_right", doc=fam_doc)
    t.Start()
    width = fm.AddParameter("Width", DB.GroupTypeId.Geometry, DB.SpecTypeId.Length, False)
    height = fm.AddParameter("Height", DB.GroupTypeId.Geometry, DB.SpecTypeId.Length, False)
    fm.NewType("Default")
    fm.Set(width, 2.0)
    fm.Set(height, 3.0)

    left = create.create_reference_plane("Left", (-1, -2), (-1, 2), plan, reference="left", doc=fam_doc)
    right = create.create_reference_plane("Right", (1, -2), (1, 2), plan, reference="right", doc=fam_doc)
    fam_doc.Regenerate()
    create.create_labelled_dimension(plan, [left, right], (-1, -1.5), (1, -1.5), label=width, doc=fam_doc)
    create.create_labelled_dimension(plan, [left, centre, right], (-1, -2.5), (1, -2.5),
                                     equal_segments=True, doc=fam_doc)

    level = DB.FilteredElementCollector(fam_doc).OfClass(DB.Level).FirstElement()
    sketch_plane = DB.SketchPlane.Create(fam_doc, level.GetPlaneReference())
    profile = DB.CurveArrArray()
    profile.Append(create.create_curve_array([(-1, -0.5), (1, -0.5), (1, 0.5), (-1, 0.5)]))
    extrusion = fam_doc.FamilyCreate.NewExtrusion(True, profile, sketch_plane, 3.0)
    fam_doc.Regenerate()

    create.align_faces_to_planes(extrusion, plan,
Полный SKILL.md на GitHub

Установить family-geometry в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл family-geometry?

Creating content inside Revit families. Covers reference planes, labelled dimensions, locked extrusions, formulas, shared parameters, visibility and graphics, materials, and nested families. Use it for "build a parametric family", "add reference planes and dimensions", "lock the extrusion to the planes", "nest one family in another", "add a shared parameter to a family" and similar tasks. Read family-editing first for opening, saving and loading families.

Как установить скилл family-geometry?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл family-geometry запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить family-geometry с